As part of our application we need to develop a module that takes in an XSD schema and gives out a sample XML. The XSD schemas will be supplied during runtime. So is there a
i found java API to generate XML sample from XSD http://code.google.com/p/jlibs/wiki/XSInstance,
There is no such API, but it's possible.
'gives out sample XML' means that you will have to implement generation of sample XML node(s) from XSD basic types like <xs:element name="value" type="xs:integer" minOccurs="0"/>
, taking care of minoccurs/maxoccurs attributes, not storing dates in xs:integer
nodes, etc, etc..
Once it's done, the rest is not a problem: traversing XSD with XPath
or org.w3c.dom.*
, flattening complex types and extensions will do the trick. I bet you'll receive working traversing code here on stackoverflow within minutes after posting question.