How to use JAXB APIs to generate classes from xsd?

Posted by Simran on Stack Overflow See other posts from Stack Overflow or by Simran
Published on 2010-12-30T09:31:52Z Indexed on 2010/12/30 9:54 UTC
Read the original article Hit count: 192

Filed under:
|

I need to generate bean classes from .xsd without using xjc command or ant. i have found the implementation in Apache Axis2 but i am unable to generate the artifacts.

i have written the following code but i get NullPointerException :

SchemaCompiler sc = XJC.createSchemaCompiler();
 URL url = new URL("file://E:\\JAXB\\books.xsd");
 sc.parseSchema(new InputSource(url.toExternalForm()));
 S2JJAXBModel model = sc.bind();
 JCodeModel cm = model.generateCode(null, null);
 cm.build(new FileCodeWriter(new File("E:\\JAXBTest")));

Can anyone help me / provide some links???

© Stack Overflow or respective owner

Related posts about java

Related posts about jaxb