Relative paths passed to the document() function are resolved against either the XML or the stylesheet depending on what is passed in: a node from the XML will mean the path is resolved against the XML, a string will mean it's resolved against the stylesheet.
The gotcha is this - if you modify this:
document(@path)
to this:
<xsl:variable name="path" select="@path" as="xs:string"/>
...
document($path)
and
@path
contains a relative path, then you could get a document not found error, or worse if your XML and XSLT are in the same directory, you won't notice...
3 comments:
You should probably mention the workaround to use document($path,.) instead.
Normally I find this hits when for example the source doesn't include an extension so you want to use document(concat(@file,'.xml')) which has the same effect of making it a string rather than a source document node.
Big thanks to you David and Andrew! This workaround is just what I needed.
Finding this yesterday would have saved me roughly 8 hours of productivity. Ah well. Thanks for the help!
Post a Comment