{ "ns" : "http://zorba.io/modules/xml", "description" : "

\n This module provides functions for reading XML files from string inputs.\n It allows reading of well-formed XML documents as well as well-formed\n external parsed entities, described by\n XML 1.0 Well-Formed\n Parsed Entities. The functions can also perform Schema and DTD\n validation of the input documents.\n

\n

The following example parses a sequence of XML elements and returns\n them in a streaming fashion - each at a time:

\n
\n import module namespace x = \"http://zorba.io/modules/xml\";\n import schema namespace opt = \"http://zorba.io/modules/xml-options\";\n x:parse(\n   \"<from1>Jani</from1><from2>Jani</from2><from3>Jani</from3>\",\n   <opt:options>\n     <opt:parse-external-parsed-entity/>\n   </opt:options>\n )\n 
\n

Another useful option allows to skip an arbitrary number of levels\n before returning a sequence of nodes as shown in the following example:

\n
\n import module namespace x = \"http://zorba.io/modules/xml\";\n import schema namespace opt = \"http://zorba.io/modules/xml-options\";\n x:parse(\n   \"<root>\n     <from1>Jani1</from1>\n     <from2>Jani2</from2>\n     <from3>Jani3</from3>\n   </root>\",\n   <opt:options>\n     <opt:parse-external-parsed-entity opt:skip-root-nodes=\"1\"/>\n   </opt:options>\n )\n 
\n", "sees" : [ "XML 1.0 Well-Formed Parsed Entities", " fn:parse-xml() function in XPath and XQuery Functions and Operators 3.0", "LibXml2 parser" ], "authors" : [ "Nicolae Brinza, Juan Zacarias" ], "version" : null, "encoding" : "utf-8", "namespaces" : [ { "uri" : "http://www.w3.org/xqt-errors", "prefix" : "err" }, { "uri" : "http://zorba.io/modules/xml-options", "prefix" : "opt" }, { "uri" : "http://zorba.io/modules/schema", "prefix" : "schema" }, { "uri" : "http://zorba.io/options/versioning", "prefix" : "ver" }, { "uri" : "http://zorba.io/modules/xml", "prefix" : "x" }, { "uri" : "http://zorba.io/errors", "prefix" : "zerr" } ], "functions" : [ { "arity" : 1, "name" : "canonicalize", "qname" : "x:canonicalize", "signature" : "($xml-string as xs:string) as xs:string", "description" : "

A function to canonicalize the given XML string, that is, transform\n it into Canonical XML as defined by Canonical XML.

\n

Note: This function is not streamable. If a streamable string is used\n as input for the function it will be materialized.

\n

Note: This function sets the\n XML_PARSE_NOERROR\n option when parsing the XML input.

\n", "summary" : "

A function to canonicalize the given XML string, that is, transform\n it into Canonical XML as defined by Canonical XML .

", "annotation_str" : "", "annotations" : [ ], "updating" : false, "parameters" : [ { "name" : "xml-string", "type" : "xs:string", "occurence" : null, "description" : "
a string representation of a well formed XML to canonicalize. XML fragments are not allowed.
" } ], "returns" : { "type" : "xs:string", "description" : "the canonicalized XML string." }, "errors" : [ "err:CANO0001 invalid input." ] }, { "arity" : 2, "name" : "canonicalize", "qname" : "x:canonicalize", "signature" : "($xml-string as xs:string, $options as element(opt:options)) as xs:string", "description" : "

A function to canonicalize the given XML string, that is, transform\n it into Canonical XML as defined by Canonical XML.

\n

This version of the function allows specifying certain options to be\n used when initially parsing the XML string. These are of the same form\n as the options to x:parse#2(), although the following options are\n currently ignored for this function:\n

\n

\n

Note: This function is not streamable, if a streamable string is used\n as input for the function it will be materialized.

\n

Note: This function sets the\n XML_PARSE_NOERROR\n option when parsing the XML input.

\n", "summary" : "

A function to canonicalize the given XML string, that is, transform\n it into Canonical XML as defined by Canonical XML .

", "annotation_str" : "", "annotations" : [ ], "updating" : false, "parameters" : [ { "name" : "xml-string", "type" : "xs:string", "occurence" : null, "description" : "
a string representation of a well formed XML to canonicalize. XML fragments are not allowed.
" }, { "name" : "options", "type" : "element(opt:options)", "occurence" : null, "description" : "
an XML containg options for the canonicalize function.
" } ], "returns" : { "type" : "xs:string", "description" : "the canonicalized XML string." }, "errors" : [ "err:CANO0001 invalid input." ] }, { "arity" : 2, "name" : "parse", "qname" : "x:parse", "signature" : "($xml-string as xs:string?, $options as element(opt:options)?) as node()* external", "description" : "

A function to parse XML files and fragments (i.e.\n external general parsed\n entities).

\n

The functions takes two arguments: the first one is the\n string to be parsed and the second argument is an <options/> element that\n passes a list of options to the parsing function. They are described below.\n The options element must conform to the xml-options:options element type\n from the xml-options.xsd schema. Some of these\n will be passed to the underlying library (LibXml2) and further documentation\n for them can be found at \n LibXml2 parser.

\n The list of available options:\n \n

\n An example that sets the base-uri of the parsed external entities:\n

\n
\n   import module namespace x = \"http://zorba.io/modules/xml\";\n   import schema namespace opt = \"http://zorba.io/modules/xml-options\";\n   x:parse(\"<from1>Jani</from1><from2>Jani</from2><from3>Jani</from3>\",\n     <opt:options>\n       <opt:base-uri opt:value=\"urn:test\"/>\n       <opt:parse-external-parsed-entity/>\n     </opt:options>\n   )\n 
\n", "summary" : "

A function to parse XML files and fragments (i.

", "annotation_str" : "", "annotations" : [ ], "updating" : false, "parameters" : [ { "name" : "xml-string", "type" : "xs:string", "occurence" : null, "description" : "
The string that holds the XML to be parsed. If empty, the function will return an empty sequence
" }, { "name" : "options", "type" : "element(opt:options)", "occurence" : null, "description" : "
The options for the parsing
" } ], "returns" : { "type" : "node()*", "description" : "The parsed XML as a document node or a list of nodes, or an empty sequence." }, "errors" : [ "zerr:ZXQD0003 The error will be raised if the options to the function are inconsistent.", "err:FODC0006 The error will be raised if the input string is not a valid XML document or fragment (external general parsed entity) or if DTD validation was enabled and the document has not passed it.", "err:XQDY0027 The error will be raised if schema validation was enabled and the input document has not passed it or if the parsing options are not conformant to the xml-options.xsd schema." ] } ], "variables" : [ ] }