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

后端 未结 2 720
我在风中等你
我在风中等你 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: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 , 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.

提交回复
热议问题