home contribute faq download

FunctX XSLT Functions

functx:open-ref-document

Resolves a relative URI and references it, returning an XML document

Google
Webdatypic.com

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 Type

NameTypeDescription
$refNode node() a node whose value is a relative URI reference
return value document-node()?

XSLT Function Declaration

See 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 ExampleResultsExplanation
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 Also

fn:docOpens a document based on a URI

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, https://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery