3. cs:parse-string

Attempts to parse the input string 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-string($grammar, $input)item()
$grammarnodeThe ixml grammar
$inputxs:stringThe input
cs:parse-string($grammar, $input, $options)item()
$grammarnodeThe ixml grammar
$inputxs:stringThe input
$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.


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-tree or json-text

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

It is an error to specify any other value.