2

I have several schemas that inherit one or more elements from a collection of 'common' schemas. In this particular instance, I'm importing one of these schemas to make use of a single complex type defined in it.

When I generate the java objects from the schema, I get my schema types, and the element I referenced as expected, however I also get objects generated for the 30+ other types from the common schema.

I want to use the common schema, because I want to rely on automated builds for updating my schema when the common schema changes, but I do not want the extra java classes generated.

Suggestions ?

JHarnach
  • 3,944
  • 7
  • 43
  • 48
  • @C.M.Sperberg-McQueen I'm sorry I don't know what that is. Can you explain more ? – JHarnach Feb 10 '15 at 19:39
  • The stream editor 'sed' is a standard tool on Unix (and other) systems; it is frequently used to automate transformations in character streams in situations like this one. The suggestion implicit in my slightly flippant original comment is that an automated transformation could be used to suppress the Java classes you don't want, or if necessary to suppress portions of the input schema before Java sees it. If you have not heard of 'sed', however, you are unlikely to find it a helpful tool in the short run. – C. M. Sperberg-McQueen Feb 10 '15 at 20:07

1 Answers1

2

There's no out of the box approach to achieve what you want. The reason I am offering an opinion here is rather to point out (maybe for others) some issues one needs to take into account no matter which route ones go.

The 'extra' label is not always straightforward. Substitution group members are interesting. In Java, think about a class (A) using an interface (I), and a class (B:I) implementing (I). Some may say there's no dependency between A and B, while others would require B in the distribution. If you replace (I) with a concrete class, things become even less clear - consider that the substitution group head doesn't need to be abstract; or if the type of the substitution group head is anyType (Object in Java).

More so, if the XML processing was designed to accommodate xsi:type then it is even harder to tell (by looking at the schema) what is expected to work where.

Tools such as QTAssistant (I am associated with it) have a default setting that will pull in all strict dependencies (A and I above); and either ALL that might work (B above), or nothing else. Anything in between, the user needs to manually define what goes in the release. This is called automatic XSD refactoring and could be used easily in your scenario.

Petru Gardea
  • 21,373
  • 2
  • 50
  • 62