• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Generating xsd schema using schemagen command  RSS feed

 
xsunil kumar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to generate XSD schema from JAXB object. I have used SchemaOutputResolver to generate schema files and it is working fine.

But problem is that one, in my JAXB object, there are reference to other JAXB objects also. So in this case, SchemaOutputResolver is generating only one XSD file having the complex type of referenced object.

I want that it should generated another XSD file for the reference object and that should be imported into the parent XSD file.

Please provide your valuable Feedback.

-Sunil
 
g tsuji
Ranch Hand
Posts: 725
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the area of schema structuring into components, the only immutable rule is that each schema document can handle one and only one targetNamespace for by its global scope schema elements (whereas some null namespace structure can appear in it through the local scope schema elements controlled by the schema's element/attributeFormDefault attribute). If there are more than one namespace involved, xs:import is unavoidable somewhere in one or another or all of the schema documents.

As to splitting the document of the same targetNamespace, it can in principle potentially be done for each and every global element. Hence, there would hardly be any rule on how and which global elements should be splitted out into an external schema to be included into some others. Of course, to facilitate reuse is a valid guiding principle but that would really push the "artificial integence" of code-generation a bit too hard... Hence, jaxb schema generation generates one schema document for each namespaceUri it encounters. It cannot acquire enough information to split a schema out into smaller ones and integrate them through the use of xs:include.

Codewise, suppose Class A reference Class B and Class C (where B and C do not reference to each other, say) all belonging to the same namespace. The best one can do is to make out JAXBContext object, with a SchemaOutputResolver attached to it, for Class A, Class B and Class C separately where A would generate a bigger schema document integrating into it what would have been generated by B and C. It wouldn't be able to generate something like two xs:include to include what B and C would have generated. If one want to see how the smaller schema documents would look like for B and C, they can still be generated in that regard.

The above is how I would summarize to my understanding the general picture of jaxb schema generation mechanics.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!