I have 3 xsd files:
- a.xsd
- b.xsd
- shared.xsd
shared.xsd is imported to both a.xsd and b.xsd using
<xs:import schemaLocation="shared.xsd"/>
shared.xsd defines
<xs:element name="item">
<xs:complexType> ....
If I generate java code using xjc a.xsd and b.xsd is generated into different packages and in each package a separate java class is generated for item. How would it be possible to have a single shared class for item and make a a开发者_运维问答nd b use it?
You can override the package that generated files are put into. This should allow both of the shared objects to go into the same place.
xjc -p com.test a.xsd b.xsd shared.xsd
I think that is what you are looking for.
Either do what @Chris Dail said, or merge a.xsd
and b.xsd
in one schema file since JAXB
looks a the namespace to create the package.
精彩评论