Details
Description
The <xinclude> directive does not work when trying include relative resources where the compile is not run from the same directory as the installation file. The verify, using the sample, create locales.xml file in the same directory as the install.xml. The content of this file should look like:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<xfragment>
<langpack iso3="eng"/>
<langpack iso3="fra"/>
</xfragment>
and then change the <locales> component in install.xml to look like:
<locale>
<!--
<langpack iso3="eng"/>
<langpack iso3="fra"/>
-->
<xinclude href="locales.xml" parse="xml"/>
</locale>
Running the compiler on this produces this output:
c:\package\IzPack>compile sample/install.xml -b ./sample -o sample/install.jar
.:: IzPack - Version 3.11.0 ::.
< compiler specifications version: 1.0 >
- Copyright (c) 2001-2008 Julien Ponge
- Visit http://izpack.org/ for the latest releases
- Released under the terms of the Apache Software License version 2.0.
-> Processing : sample/install.xml
-> Output : sample/install.jar
-> Base path : ./sample
-> Kind : standard
-> Compression : default
-> Compr. level: -1
-> IzPack home : .
-> Fatal error :
Error parsing installation file
com.izforge.izpack.compiler.CompilerException: Error parsing installation file
at com.izforge.izpack.compiler.CompilerConfig.getXMLTree(CompilerConfig.java:1763)
at com.izforge.izpack.compiler.CompilerConfig.executeCompiler(CompilerConfig.java:316)
at com.izforge.izpack.compiler.CompilerConfig.main(CompilerConfig.java:2230)
at com.izforge.izpack.compiler.Compiler.main(Compiler.java:709)
Caused by: net.n3.nanoxml.XMLException: net.n3.nanoxml.XMLParseException: could not load content, SystemID='file:.', Line=30
at net.n3.nanoxml.StdXMLParser.parse(StdXMLParser.java:203)
at com.izforge.izpack.compiler.CompilerConfig.getXMLTree(CompilerConfig.java:1759)
... 3 more
(tip : use -? to get the commmand line parameters)
c:\package\IzPack>
The problem is that the "systemID" passed to the XMLElement constructor is "file:.". I tracked this down and found two problems. In CompilerConfig.java at line 1738, the code reads
reader = new StdXMLReader(new FileInputStream(filename));
this uses the StdXMLReader that takes an input stream. Inside that constructor, the systemID is set to "file:.". A second problem is that at the end of that constructor is a line that reads:
this.startNewStream(new StringReader(charsRead.toString()));
which pushes on the stream stack a input stream that will immediately see EOF because "charsRead" is a StringBuffer created right in this constructor and is empty.
I attempted to fix this problem by adding the line:
reader.setSystemID(file.toURL().toExternalForm());
at line 1739 in CompilerConfig.java, but that did not work because of the initial stream that is pushed on as mentioned above. As soon as one character was read from the reader, it would hit EOF, pop off the stream which would restore the "file:." systemID, undoing the the setting that I just did with the above line.
So the fix is to add the line that I added and to remove the start of the new stream in the StdXMLReader constructor.
More testing indicates that this is not the complete fix. I will update when I know more.