Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Won't Fix
-
2.6.1
-
None
-
None
-
Tested and reproduced on Linux and Windows 2000. In both cases, i was actually using an Ant 1.6.1 installation.
Description
The following description was posted in xerces-j-user and uses windows path conventions.
===========
Description
===========
[[[
I'm trying to patch up an xinclude task to automate some stuff but have "context" problems. My project structure (fragment):
xclude
└───testfiles
│ include1.xml
│ init.xml
My initial document (init.xml) is just
<?xml version="1.0" ?>
<test xmlns:xi="http://www.w3.org/2003/XInclude">
<xi:include href="include1.xml" />
</test>
the include1.xml indeed exists in the same directory as the nitial document, however i get the following error:
[Warning] :3:44: Include operation failed, reverting to fallback. Re
source error reading file as XML (href='include1.xml'). Reason: C:\tools
\eclipse\workspace\xclude\include1.xml (The system cannot find the path
specified)
So, although the init.xml was read from
C:\tools\eclipse\workspace\xclude\testfiles
the processor looks for the included file in
C:\tools\eclipse\workspace\xclude
]]]
=======================
Reproducing the problem
=======================
//Java code:
System.setProperty( "org.apache.xerces.xni.parser.XMLParserConfiguration", "org.apache.xerces.parsers.XIncludeParserConfiguration");
SAXParser parser = new SAXParser();
XMLSerializer serializer = new XMLSerializer(
new FileOutputStream(this.out),
new OutputFormat("XML", this.encoding, this.indent));
parser.setDocumentHandler(serializer.asDocumentHandler());
// THIS IS WHERE THE BUG IS, SEE WORKAROUNDS
// this.in is a java.io.File object
parser.parse(new InputSource(new FileInputStream(this.in)));
=================
Workarounds (two)
=================
1) Modify the initial document (init.xml above) by adding an xml:base in it's documentElement, having the absolut path of the file as the value.
2) Change the problematic line:
parser.parse(new InputSource(new FileInputStream(this.in)));
to this (the following works fine):
parser.parse(new InputSource(this.in.getAbsolutePath()));
=========
Diagnosis
=========
My guess is this has something to do with the implementation of xml:base and the initial value that gets in xinclude processing, or some Locator problem?