Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java API for XML Schema manipulation

Tags:

java

dom

xml

xsd

I am familiar with JAXB, JAXP and DOM. I know JAXB provides java2xml and xml2java generation(and validation against XML Schema(XSD)). What I want is convenient way to produce XML schema programmatically from scratch. I do not want to produce XSD from java classes. I want to have an object representing the schema itself. For example:

XMLSchemaFactory factory = XMLSchemaFactory.newInstance();
XMLSchema schema = factory.newSchema();
schema.setTargetNameSpace("http://www.example.com");
...
schema.addComplexType(complexTypeElement);
...
schema.addElement(name, type);
...
schema.export(new File("mySchema.xsd"));

I know XML schema is itself XML, so I can use Document, Element, Node and other classes/interfaces from org.w3c.dom, but I wonder is there something more convenient ? Why I want this - I have some IDL, which I have to translate to WSDL. I have lexer/parser for the IDL and I have convenient representation of it as java objects. Now I want to produce the WSDL using this objects => a lot of XML schemas have to be generated !

like image 669
egelev Avatar asked Apr 24 '26 19:04

egelev


1 Answers

From my point use WSDL4J it would be pretty easier for your xml manipulations.

Refer this pdf for more details.

http://wsdl4j.sourceforge.net/downloads/JSR110_proposed_final_draft.pdf

like image 141
ashokramcse Avatar answered Apr 27 '26 07:04

ashokramcse