1

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);
Jens
  • 67,715
  • 15
  • 98
  • 113
Simran
  • 21
  • 4
  • Compare with [this](http://stackoverflow.com/questions/4248099/jaxb-dynamically-generate-java-sources-without-xjc) approach – jmj Dec 29 '10 at 09:45
  • Try with `is.setSystemId("E:\\product.xsd");` – jmj Dec 29 '10 at 09:52

1 Answers1

0

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!

Community
  • 1
  • 1
JesperSM
  • 1,418
  • 1
  • 11
  • 15