joe
joe

Reputation: 11

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 pointers to examples/documentation/api is highly appreciated.

Thanks in advance.

Upvotes: 1

Views: 487

Answers (1)

gto406
gto406

Reputation: 629

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!

Upvotes: 1

Related Questions