简体   繁体   中英

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 FileInputStream(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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM