June 2008
Intermediate to advanced
986 pages
27h 8m
English
[2.0] document-uri()
Given a node, returns the document URI property for that node.
xs:anyURI?document-uri(node()?)
A node.
If the node is not a document node, document-uri() returns the empty
sequence. Otherwise, it
returns the document URI property for the node. If the argument is
the empty sequence, document-uri() returns the empty
sequence.
XQuery 1.0 and XPath 2.0 Functions and Operators section 2, “Accessors.”
Here’s a short stylesheet that returns the document URI for the XML document we’re processing:
<?xml version="1.0"?> <!-- document-uri.xsl --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>
A test of the document-uri() function:</xsl:text> <xsl:text>

 The document URI for the </xsl:text> <xsl:text>root element is:
 </xsl:text> <xsl:value-of select="document-uri(/)"/> </xsl:template> </xsl:stylesheet>
When we run this stylesheet against the file blank.xml, here are the results:
A test of the document-uri() function:
The document URI for the root element is:
file:/C:/projects/XSLTbookV2/AppendixC/blank.xmlRead now
Unlock full access