cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Edwards, Jayme" <>
Subject Problem resolving base URI in document function
Date Thu, 13 Jul 2000 17:21:11 GMT

I'm using Cocoon 1.7.4, Tomcat 3.2 beta, Xerces 1.0.3, and Xalan 1.1. I have a project that
uses XML documents of a specific grammar to pass filenames to a stylesheet which then loads
them with the "document()" function relative to the source document. I'm having a problem
where Xalan's implementation of document() either isn't working properly, or I'm not understanding
the XSLT specification fully.

For example lets say I have a file:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="view/mydoc.xsl"?>
<mydoc filename="mydoc"/>

and it is located in /mydoc.xml (path on tomcat context) for which the REAL directory is:


and I have a file:

<?xml version="1.0"?>
  <myresource id="test">Testing, 1, 2, 3</myresource>

and it is located in /resources/mydoc_en.xml (path on tomcat context) for which the REAL directory


and I have a stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
  <xsl:variable name="myotherdoc" select="document(concat('resources/', /mydoc/@filename,
'_en.xml'), /mydoc)/myresources"/>

and it is located in /view/mydoc.xsl (path on tomcat context) for which the REAL directory


As per the XSL specification, the document() function can take one, or two parameters. If
it only takes one this can be 
an existing nodeset to be treated as a document with its own root or a string that specifies
a filename of an XML document 
to load. The spec also says if the second parameter is ommitted the base URI that will be
used to resolve the filename 
(if relative) is determined from the document that contains the call to the document() function.
This is not the case, in that 
I want to load the "resource" file for a document in a directory relative to my original mydoc.xml
file. Luckily, the spec also 
states that if you pass a nodeset as the second parameter to document(), the document from
which this nodeset was 
retrieved (the first node in document order) will be used to resolve the base URI. If you
look at the xsl:stylesheet, I do this 
by passing a second parameter to document with nodes from the original source document being
transformed. The problem 
is, I can tell it DOES use the second parameter to form the base URI, but the base URI comes
out relative to the web URI 
and not the URI on the filesystem. In the example above, Xalan tries to load the following


Which of course doesn't exist. It looks as though the base URI was determined as being different,
but went up too many levels.
Any help with this problem would be great. Its pretty critical to provide fully extensibly
data-to-style based web solutions with XSL.


View raw message