Hello,
there are several ways to generate classes and XML descriptors:
- use Castor Maven (2.0.9) plugin
- Java (as you tried)
- Ant
I can't tell ad-hoc, why URL does not work in your example,
but you can download the schema and run this code, which works fine for me:
SourceGenerator generator = new SourceGenerator();
generator.setDestDir("./codegen/src/test/java");
//Load schema file from classpath
String xmlSchema =
getClass().getResource("myschema.xsd").toExternalForm();
InputSource inputSource = new InputSource(xmlSchema);
generator.generateSource(inputSource, "generated");
Regards,
Lukas
Amer Seifeddine schrieb:
> Hi All, I am simply trying to generate the source from a class at
> runtime using below code: URL url = new URL("http://xxxx/xxx.xsd");
> SourceGenerator srcGen = new SourceGenerator();
> srcGen.generateSource(new InputSource(url.openStream()), "test"); But I
> am getting a null pointer exception.. I am pretty new to Castor and I am
> looking for help. Please. Error: java.lang.NullPointerException at
> java.util.Hashtable.put(Unknown Source) at
> org.exolab.castor.builder.BuilderConfiguration.setLocationPackageMapping(BuilderConfiguration.java:618)
> at
> org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:702)
> at
> org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:651)
> XSD (xxx is internal address):
> ------------------------------------------------------------------------
> View this message in context: Error while generating source
> <http://www.nabble.com/Error-while-generating-source-tp20425041p20425041.html>
> Sent from the Castor - User mailing list archive
> <http://www.nabble.com/Castor---User-f2411.html> at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email