Question

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 and b use it?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top