You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Martin Renner <m....@tiscon.de> on 2001/02/08 14:07:31 UTC
[Xalan-J 2 BUG] ???
Hi.
I am using Xalan 2.0.0 in a Java application. From my application, I set a parameter
with some code like the following:
File contentDir = new File("subdir");
Transformer transformer = stylesheet.newTransformer();
transformer.setParameter("contentDir", contentDir.getAbsolutePath());
Then, in a xslt file ("webapp.xsl"), I have something like the following code:
<xsl:variable name="content" select="document(concat($contentDir, '/content.xml'))"/>
<xsl:template match="webapp">
<xsl:value-of select="$content/strings/blablabla"/>
When I start this application on my Linux machine, everything is just working fine.
However, calling exactly the same application on Windows is resulting in an error.
I traced down the exception in the source code of Xalan and I discovered, that the method
Node getDoc(XPathContext xctxt, Node context, String uri, String base)
in File "FuncDocument" is getting called with
Linux:
base=file:////home/mr/test/webapp.xsl
uri=/home/mr/test/subdir/content.xml
Windows:
base=null
uri=m:\test\subdir/content.xml
The exception on Windows is:
java.net.MalformedURLException: no protocol: m:/test/subdir/content.xml
at java.net.URL.<init>
at org.apache.xerces.readers.DefaultReaderFactory.createReader
at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument
at org.apache.xerces.framework.XMLParser.parseSomeSetup
at org.apache.xerces.framework.XMLParser.parse
at org.apache.xpath.SourceTreeManager.getDOMNode
at org.apache.xpath.SourceTreeManager.getSourceTree
at org.apache.xpath.SourceTreeManager.getSourceTree
at org.apache.xalan.templates.FuncDocument.getDoc
at org.apache.xalan.templates.FuncDocument.execute
...
Then I found the following code in FuncDocument.execute:
// From http://www.ics.uci.edu/pub/ietf/uri/rfc1630.txt
// A partial form can be distinguished from an absolute form in that the
// latter must have a colon and that colon must occur before any slash
// characters. Systems not requiring partial forms should not use any
// unencoded slashes in their naming schemes. If they do, absolute URIs
// will still work, but confusion may result.
int indexOfColon = ref.indexOf(':');
int indexOfSlash = ref.indexOf('/');
if ((indexOfColon != -1) && (indexOfSlash != -1)
&& (indexOfColon < indexOfSlash))
{
// The url (or filename, for that matter) is absolute.
base = null;
}
Exactly here, "base" is set to "null" on Windows. Just one line before it has the
content "file:///M:/test/webapp.xsl".
As java.net.URL is complaining about a missing protocol and as this protocol ("file")
is just set to "null" in the above code, I am wondering if this is correct.
I don't have any experience with Xalan and Xerces, so I am asking the "specialists"
here in this mailing list.
Martin