Dynamic generation of classes using JAXB
I am trying to generate classes from xsd using XJC
class of jaxb. however i am getting
java.lang.IllegalArgumentException
Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 2: E:\product.xsd
this is however the correct path where my xsd is present.
can anyone help me with this please.
my code is like :
File schemaFile = new File("E:\\product.xsd");
InputSource is;
is = new InputSource(new FileInputStrea开发者_开发技巧m(schemaFile));
is.setSystemId(schemaFile.getAbsolutePath());
// Parse & build
sc.parseSchema(is);
The systemId is a URL, not a file.
Instead, use:
is.setSystemId(schemaFile.toURI().toString())
See this answer for a working example. Happy path-mangling!
精彩评论