1

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

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.

Community
  • 1
  • 1
Josh Winkler
  • 166
  • 12
  • Can you please clarify if same-name files are identical, irrespective of folder path? Can you describe what do you see in the refactored set? For e.g., all content in the same namespace goes in one single XSD, what I would call most simple form, see [this](http://paschidev.com/Whitepapers/HowManyXSDs.html) as a starting point. Refactoring such as the one you described is possible with [QTAssistant](http://paschidev.com) - I am associated with it; however, I would expect some custom script... – Petru Gardea May 14 '12 at 17:09
  • For these purposes, it can be assumed that same-named files are identical. For the refactoring, I'm willing to accept just about any formatting. Putting them in single-namespace XSDs won't work, as Include_v02.xsd is the same as Include_v01.xsd, but wiht an extra element in v02. If I had them all in one single XSD, there would be colission between v1 and v2, and both would use the same name for the elements. A better solution would essentially leave the v1 XSDs, and v2 XSDs use the v1 elements as extensions and then add their respective new sub-elements. – Josh Winkler May 14 '12 at 17:14
  • As an examle: Include_v01.xsd could define As an examle: Include_v02.xsd could define So you can see the collision, and why I can't just point all to the latest version of each XSD – Josh Winkler May 14 '12 at 17:20
  • It is still not clear how you would go about this: what would be the new name for the "extended" type; what would then reference the new type? It causes a "chain reaction" that you need to carefully define. I am interested in learning more about your problem and should something be done about it, in return I am offering you the use of my tool for what you need. If you're interested, please contact me directly using the support email on my website. If something good comes out, I'll then post the solution as an answer here. – Petru Gardea May 14 '12 at 23:21
  • I would love to use QTAssistant, but we don't have any budget for new tools. I don't get enough space in a single comment, so I'll edit the question instead to add clarification. – Josh Winkler May 15 '12 at 14:56
  • If you end up using it based on this collaboration, I'll be offering a free license, so hopefully it should alleviate the budget constraint. – Petru Gardea May 15 '12 at 15:05
  • [Liquid XML Studio](http://www.liquid-technologies.com/Xml-Schema-Editor.aspx) alows XSD's to be refactored, name and type changes are reflected in there references and elements can be re-factored into complextypes. You can also easily cut and paste items between schemas. It also has a [XSD dependancy viewer](http://www.liquid-technologies.com/xml-schema-dependancy-viewer.aspx) that graphs the include tree. – Sprotty May 29 '12 at 11:29

0 Answers0