MarkLogic 12 EA 1 Product Documentation
xdmp:unquote

xdmp:unquote(
   $arg as xs:string,
   [$default-namespace as xs:string?],
   [$options as xs:string*]
) as document-node()+

Summary

Parses a string as XML, returning one or more document nodes.

Parameters
arg Input to be unquoted.
default-namespace Default namespace for nodes in the first parameter.
options The options for getting this document. The default value is ().

Options include:

"repair-full"
Specifies that malformed XML content be repaired. XML content with multiple top-level elements will be parsed as multiple documents. This option has no effect on binary or text documents.
"repair-none"
Specifies that malformed XML content be rejected. XML content will be parsed as a single document, so a maximum of one document node will be returned. This option has no effect on binary or text documents.
"format-text"
Specifies to get the document as a text document, regardless of the URI specified.
"format-binary"
Specifies to get the document as a binary document, regardless of the URI specified.
"format-xml"
Specifies to get the document as an XML document, regardless of the URI specified.
"format-json"
Specifies to get the document as a JSON document, regardless of the URI specified.
"default-language=xx"
If the root element node specified in the first parameter does not already have an xml:lang attribute, the language to specify in an xml:lang attribute on the root element node. If default-language is not specified, then nothing is added to the root element node. Some examples are default-language=en and default-language=fr.

Usage Notes

If no format is specified in $options, it is inferred from the input. If the first non-whitespace character is either '{' or '[' it is JSON. Otherwise it is XML.

If neither "repair-full" nor "repair-none" is present, the default is specified by the XQuery version of the caller. In XQuery version 1.0 and 1.0-ml the default is "repair-none". In XQuery version 0.9-ml the default is "repair-full".

If $arg is the empty string, xdmp:unquote returns an empty document node.

Example

xdmp:unquote("<foo/>")
=> <foo/>
  It returns this as a document node.

Example

  xdmp:unquote('<foo>hello</foo>', "",
          ("repair-none", "default-language=en"))
  => <foo xml:lang="en">hello</foo>
  It returns this as a document node and does
  not perform tag repair on the node.
Powered by MarkLogic Server | Terms of Use | Privacy Policy