Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Generating xsd schema using schemagen command

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic