# doc

Retrieves an XML document located at the specified URI, parses it, and returns its document node

doc($uri as xs:string?) → document-node()?

Arguments
| $uri | xs:string? | The URI of the required document (relative to the static base URI)
Result | document-node()?

Links to W3C specifications

Namespace: http://www.w3.org/2005/xpath-functions

Applies to: XPath 2.0, XSLT 2.0, XQuery 1.0 and later versions

XPath 2.0 Specification

XPath 3.0 Specification

Notes on the Saxon implementation

By default the URI is dereferenced using the conventional URL behaviour, as implement by the Java runtime library; this behaviour can be modified by means of a user-supplied URIResolver.

If the same URI is requested repeatedly, Saxon retains the document node in memory and returns the same instance each time.

The way the URI is handled depends on the `URIResolver` in use. The standard URI resolver has an option (set using -p on the command line, or via options on the `Configuration` or `TransformerFactory` classes) to recognize query parameters in the URI. These are keyword=value pairs, separated by semicolons or ampersand characters, giving options for parsing the file located via the URI. The options that are then recognized are:

- `validation=strict|lax|preserve|strip`: determines how the input document will be validated. The options "strict" and "lax" require Saxon-EE.

- `strip-space=yes|no|ignorable`: determines whether whitespace-only text nodes will be stripped from the source document. (Such nodes are stripped if this is requested either using this option, or using xsl:strip-space declarations in the stylesheet.) The value "ignorable" causes whitespace text nodes to be stripped if they belong to an element defined in a DTD or schema as having element-only content.

- `parser=full.class.name`: determines the name of the parser (XMLReader) to be used to parse this input file. For example, `parser=org.ccil.cowan.tagsoup.Parser` causes John Cowan's TagSoup parser for HTML to be used.

Next