Any Java “API” to generate Sample XML from XSD?

后端 未结 2 712
我在风中等你
我在风中等你 2021-01-02 10:23

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

相关标签:
2条回答
  • 2021-01-02 11:05

    i found java API to generate XML sample from XSD http://code.google.com/p/jlibs/wiki/XSInstance,

    0 讨论(0)
  • 2021-01-02 11:19

    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.

    0 讨论(0)
提交回复
热议问题