jackdriver
Programmer
hello,
In case of relative path XInclude looks for included file inside current working directory. Let's assume the following file structure:
somedir
|_sometest.xml
test.xml
and test.xml file like this:
<?xml version="1.0"?>
<test xmlns:xi=" <xi:include href="somedir/somefile.xml"/>
</test>
It works fine with JAXB:
JAXBContext jc = JAXBContext.newInstance( "com.xxx.yyy" );
Unmarshaller u = jc.createUnmarshaller();
Object o = u.unmarshal( new File( "test.xml" ));
But the situation is more complicated when our files structure is packed into jar:
test.jar
|_somedir
|_sometest.xml
|_test.xml
JarFile jar = new JarFile("test.jar");
ZipEntry zipEntry = jar.getEntry("test.xml");
InputStream stream = jar.getInputStream(zipEntry);
Object o = u.unmarshal( stream );
In this case the exception is thrown because href is not correctly resolved:
An 'include' failed, and no 'fallback' element was found.
Any hints?
In case of relative path XInclude looks for included file inside current working directory. Let's assume the following file structure:
somedir
|_sometest.xml
test.xml
and test.xml file like this:
<?xml version="1.0"?>
<test xmlns:xi=" <xi:include href="somedir/somefile.xml"/>
</test>
It works fine with JAXB:
JAXBContext jc = JAXBContext.newInstance( "com.xxx.yyy" );
Unmarshaller u = jc.createUnmarshaller();
Object o = u.unmarshal( new File( "test.xml" ));
But the situation is more complicated when our files structure is packed into jar:
test.jar
|_somedir
|_sometest.xml
|_test.xml
JarFile jar = new JarFile("test.jar");
ZipEntry zipEntry = jar.getEntry("test.xml");
InputStream stream = jar.getInputStream(zipEntry);
Object o = u.unmarshal( stream );
In this case the exception is thrown because href is not correctly resolved:
An 'include' failed, and no 'fallback' element was found.
Any hints?