开发者

Programatic generation of xml from a xsd that uses other xsds

I have a xsd that in turn uses/imports a set of xsds. I would like to programtically generate sample xml from the xsd. The xml must contain all elements and attributes populated with example data based on data type.

How can I do this using eclipse api classes? Also are there any other tools that accomplish this task and can be evoked in a java program or a batch file?

Any poi开发者_JAVA技巧nters to examples/documentation/api is highly appreciated.

Thanks in advance.


if I am reading your question correctly, I believe what you are trying to do is programmatically generate (i.e. using Java) XML documents based on an XML Schema Document (which may in turn import other supporting XSD's).

You may wish to have a look at Oracle/Sun's JAXB (Java Architecture for Xml Binding) which you can find more info about here:

http://jaxb.java.net/

JAXB works with J2SE-SDK and/or IDEs - such as Netbeans or Eclipse, and permits you to unmarshall (read XML documents into mapped Java Objects) or marshall (write Java objects as XML documents) as required. Standard mappings (known as binding declarations) are provided based on valid XML Schema provided to JAXB. You can also provide binding declarations through custom annotations directly within your XML Schema files or by using external JAXB declarations.

Another alternative (similar to JAXB) is Apache's XML-Beans.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜