4. cs:parse-uri

Loads the document at the specified URI and attempts to parse it with the grammar provided. The result will be an XML document that is either the parsed result or a document that specifies that an error occurred.

The grammar provided must be in XML format. This can be obtained with the cs:grammar function or, in the case of XML format grammars, through any convenient means.

cs:parse-uri($grammar, $href)item()
$grammarnodeThe ixml grammar
$hrefxs:stringThe document location
cs:parse-uri($grammar, $href, $options)item()
$grammarnodeThe ixml grammar
$hrefxs:stringThe document location
$optionsmap(xs:string, xs:string)Parsing options

The following options are recognized:


If unspecified or specified with the value “true” or “yes”, the grammar will be cached. If any other value is specified, the grammar will not be cached.

Caching at this level saves the mapping between the XML representation of the grammar and the underlying Invisible XML parser object.


Specifies the encoding to use for the input document.


Identifies the format of the result:


Returns an XML node.

json or json-data

Returns a “data” map. This method will fail if the result contains mixed content.

json-text or json-text

Returns a “text” map. This map structure can represent any tree.

It is an error to specify any other value.