Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XInclude inside jar file

Status
Not open for further replies.

jackdriver

Programmer
Sep 16, 2008
3
FI
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?
 
A jar file is not a tree strucure like directories. AFAIK, it's internally decompressed file by file and they don't keep hierarchical relationship.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top