Name

document( )

Synopsis

                     node-set document(string uri)
node-set document(node-set uris)
node-set document(string uri, node-set base)
node-set document(node-set uris, node-set base)

The document( ) function loads the XML document at the URI specified by the first argument and returns a node-set containing that document’s root node. The URI is normally given as a string, but it may be given as another type that is converted to a string. If the URI is given as a node-set, then each node in the set is converted to a string, and the returned node-set includes root nodes of all documents referenced by the URI argument.

If the URI contains a fragment identifier, then the node-set returned may indicate something other than the root node and thus contain more than one node. If an error occurs while retrieving a document, most XSLT processors stop processing the stylesheet.

The document( ) function may also take a node-set as an optional second argument, in which case the base URI of the first node (in document order) in this set is used to resolve relative URIs given in the first argument. If the second argument is omitted, then base URIs are resolved relative to the stylesheet’s location.

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.