I've been trying to use JAXB-RI and it's xjc to generate classes for my XSDs (when I say my XSDs, I mean horribly done XSDs. More on that later).
The first problem I have is, I only have two total namespaces in the entire set up. Despite that, the same thing is defined sultiple times in seperate files, with slightly different names, but nothing in the XSD to differentiate. For example, I can have two XSDs
bar_v01_00.xsd
<xsd:schema xmlns="http://www.foo.com/" targetNamespace="http://www.foo.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="foo">
<xsd:complexType>
<xsd:complexContent>
<xsd:element name="elem1" type="xsd:string" />
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
bar_v02_00.xsd
<xsd:schema xmlns="http://www.foo.com/" targetNamespace="http://www.foo.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="foo">
<xsd:complexType>
<xsd:complexContent>
<xsd:element name="elem1" type="xsd:string" />
<xsd:element name="elem2" type="xsd:string" />
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
So, same name, same namespace, just different files. I get around this by specifying two different packages, so bar_v01_00.xsd would go in
package www.foo.com.bar.Major01.Minor00;
and bar_v02_00.xsd would compile into
package www.foo.com.bar.Major02.Minor00;
Inelegant, to be sure, but effective. Now, these files can have includes/imports, each of which itself can have even more includes/imports, some of which can go 32 levels deep! By and larger, these includes are includes for a reason, i.e. they are reused a number of times.
There are > 120 services I have, each of which has a Request and Response XSD, and maybe half have multiple versions as above. I've managed to refactor this down to 636 total files, which was no mean feat.
I don't want to have 300 copies of the same common things generated into seperate packages, so I tried using .episode files. That works, but only to a level of 3 deep worth of includes. If I try to include more than 3 .episodes, xjc dies. I tried putting the episodes into a jar file, and then realized it only looks for one episode that way. If I try and combine the episodes' content into a single file it doesn't work either.
Is there anything I can do, or am I stuck here?