You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Christian Bjørnbak <bj...@iuas.dk> on 2001/03/16 12:06:19 UTC
Problems in org.apache.xml.utils.SystemIDResolver.java
Hi I've found some problems (bugs) in
org.apache.xml.utils.SystemIDResolver.java...
I use Xerces and Xalan in Tomcat on Linix.
I use ServletContext.getRealPath("/home/docroot/template/adm/adm.xml") to
locate a XML, parse it a DOM and create a DOMSource with the constructor
DOMSource(DocumentNode, "/home/docroot/template/adm/adm.xml");
Then I use TransformerFactory.getAssociatedStylesheet(DOMSource, null, null,
null); to find the stylesheet.
In the xml file the stylesheet tag is the following:
<?xml-stylesheet type="text/xsl" href="xslt/html.xsl"?>
But trying to run Transformer.transform() I get a:
javax.xml.transform.TransformerConfigurationException: File
"file:////var/tomcat//home/docroot/template/adm/xslt/html.xsl" not found.
Where /var/tomcat is the directory where I started tomcat from (a.k.a. the
user-dir).
I checked out org.apache.xml.utils.SystemIDResolver.java and found the
following problems (bugs?).
In getAbsoluteURI the following test is made to decide whether a url is
absolute or relative
if ((urlString.indexOf(':') < 0) && (null != base)
&& (base.indexOf(':') < 0))
{
base = getAbsoluteURIFromRelative(base);
}
If there is a : (colon) it's an absolute URI..
Problems:
1. If no colon is present it's considered a relative url and
getAbsoluteURIFromRelative() prepends file:// and userdir. But my path is
and absolute except for missing "file://".
2. If I was running on Windows the path would have been
C:\home\docroot\template\adm\xslt\html.xsl it would have been concidered an
absolute url eventhough it doesn't contain a file://....
Maybe the tes could be replaced by the following rules:
If it doesn't contain file://, http://, ftp:// or another URI prefix
(generalized to something+://) concidered a incomplete URI.
If it on a Unix platform starts with / it's a absolutepath and a file:// is
simply prepended.
If it on a Windows platform starts with letter+colon it's a absolutepath and
a file:// is simply prepended.
Does this make sence?? Or am I using Xalan wrong???
/Christian