This page was generated
August  8,  2011
2:23  AM
XQuery Built-In and Modules Function Reference

Built-In: Extension - XML Functions

The XML extension functions provide XML functionality such as parsing a string as XML.

Function Summary
xdmp:quote Returns the unevaluated serialized representation of the input parameter as a string.
xdmp:unquote Parses a string as XML, returning one or more document nodes.
Function Detail
xdmp:quote(
$arg as item()*,
[$options as node()?]
)  as   xs:string
Summary:

Returns the unevaluated serialized representation of the input parameter as a string.

Parameters:
$arg : Input to be quoted.
$options (optional): The options node for this quote operation. The default value is (). The node for the xdmp:quote options must be in the xdmp:quote namespace.

The xdmp:quote options include:

<output-encoding>

Specifies the encoding to use for this quote operation. This is only used to escape characters that cannot be represented.

<output-sgml-character-entities>

Specifies if character entities should be output upon serialization of the XML. Valid values are normal, none, math, and pub. By default (that is, if this option is not specified), no SGML entities are serialized on output, unless the App Server is configured to output SGML character entities.

Example:
  let $arg := <a>aaa</a>
  return ($arg, xdmp:quote($arg))
  => (<a>aaa</a>, "<a>aaa</a>")

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 (optional): Default namespace for nodes in the first parameter.
$options (optional): The options for getting this document. The default value is ().

Options include:

"repair-full"
Specifies that malformed XML content be repaired. This option has no effect on binary or text documents.
"repair-none"
Specifies that malformed XML content be rejected. 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.
"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 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.