Description
The functx:open-ref-document function takes the value of $refNode , which is a relative URI reference, resolves it to the base URI to form an absolute URI, then calls the fn:doc function to retrieve the document at that URI.
It uses the base URI of the node itself if available (usually the URI the document was retrieved from). If the node doesn't have a base URI, the base URI of the static context is used (which is defined in the prolog or outside the scope of the query by the processor.
Arguments and Return TypeName | Type | Description |
$refNode |
node() |
a node whose value is a relative URI reference |
return value |
document-node()? |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:open-ref-document" as="document-node()"
xmlns:functx="http://www.functx.com">
<xsl:param name="refNode" as="node()"/>
<xsl:sequence select="
if (base-uri($refNode))
then doc(resolve-uri($refNode, base-uri($refNode)))
else doc(resolve-uri($refNode))
"/>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <a href="temp/other.html">Some other file</a> |
| </xsl:variable> |
XPath Example | Results | Explanation |
---|
functx:open-ref-document(
$in-xml/@href) |
The document node of the document at the relative URI temp/other.html . |
If the base URI of the $in-xml node is http://datypic.com , it would return http://datypic.com/temp/other.html , assuming it's well-formed XML. |
See Alsofn:doc | Opens a document based on a URI |
History |
Recommended Reading:
|