I have been given a legacy set of XSDs for services my app is providing that are in DIRE need of refactoring. As some of the consumer apps have no development team, I cannot change the resultand schema. I can, however, do whatever I want to the actual files.
Here is my directory setup:
- root
- subdir1
- common
- development
- subdir2
- common
- development
- subdir1
Assume, for simplicity, that an increment in version between files adds an element to a complexType, so that a previous version can reapply be considered like a base/super class.
Now, in subdir1/common, I can have Include_v01.xsd and Include_v02.xsd. In subdir1/development, I can have svc1_v01.xsd which uses Include_v01.xsd, and svc1_v02.xsd which uses Include_v02.xsd
In Subdir2/common, I can have Include_v02.xsd and Include_v03.xsd In subdir2/developmen, I can have svc2_v01.xsd which uses Include_v02.xsd, and svc2_v02.xsd which uses include_v03.xsd
I have ~20 such subdirs. I have about 1500 or so XSD files in those directories. Each xsd can have several includes, which can themselves have multiple includes, which can themselves have multiple includes, etc.
Ultimately, I'd like to refactor these to their most simple form, where I'd have only one copy of Include_v02.xsd, for example, and where Include_v02.xsd actually builds off of Include_v01.xsd instead of is a fully seperate copy. Yes, some jerk just copied the file, renamed it, and added one field. Then he copied it to every subdir it would be used in.
More important even than that, is to be able to generate java classes in a similar structure.
Right now, the best I can do is run xjc on the directories, and compile each service's schema into a different package, so I now have tons of copies of the Include_v02 object, in various java packages. I have to do it this way because the schema was not versioned or remaned between versions. The same idiot just copide the file, renamed it, and added a new element, keeping the root element the same and no other distinguishing characteristics.
It's a tall order, and I would settle for some way to easily copy/merge the java objects, or even to simply copy between to identical java objects in different packages.
Episode files, like refered to here, doesn't seem like it would be any better than the script I use to generate things now, as I'd have to very deliberately figure out each root element, given the multi-layered nesting that is used.
EDIT============================= If I had, in Include_v01.xsd, the following:
<complexType name="cmplxtp">
<complexContent><sequence>
<element name="st1" type="string"/>
</complexContent></sequence>
</complexType>
and, in Include_v02.xsd, I had something like
<complexType name="cmplxtp">
<complexContent><sequence>
<element name="st1" type="string"/>
<element name="st2" type="string"/>
</complexContent></sequence>
</complexType>
I would love some combination of
either the XSD refactored to be
Include_v01.xsd the same Include_v02.xsd
OR
All the individual elements (complex, or simple) left in Include_v01.xsd Include_v02 to include Include_v01.xsd, with only the new elements added
OR
two java classes
package pack1;
class cmplxtp {
public String st1;
}
and
package pack2;
class cmplxtp extends pack1.cmplxtp {
public String st2;
}
The java classes are the most important to me, but anything that helps to get there would be outstanding.
If none of that is at all possible, simple, or worth it, I'd also be more than grateful for some simple way of copying identical objects from one to another if they exist in different packages. I just really want to simplify my codebase, I have 160 or so services, with many versions each, and each versoin can include the SAME EXACT file. This means in my gen'd code, I can have maybe 300 or more definitions of the same class, but in different packages because of the copied includes.