Maybe you could use JAXB.
xjc
With xjc, you can convert your XSD file into JAXB annotated Java classes.
xjc -d src -p com.example.jaxb.beans schema.xsd
This would take the types defined in schema.xsd
, and generate in the src
folder the corresponding classes in the com.example.jaxb.beans
package.
JAXBContext & Marshaller
With the generated classes, JAXBContext and Marshaller you can generate some XML output.
JAXBContext jc = JAXBContext.newInstance("com.example.jaxb.beans");
Marshaller m = jc.createMarshaller();
OutputStream os = new FileOutputStream("output.xml");
m.marshal(element, os);
element
being an instance of one of the classes generated previously.