Loading TOC...

MarkLogic 10 Product Documentation
xdmp:quote

xdmp:quote(
   $arg as item()*,
   [$options as (element()|map:map)?]
) as xs:string

Summary

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

Parameters
arg Input to be quoted.
options Options with which to customize this operation. You can specify options as either an XML element in the "xdmp:quote" namespace, or as a map:map. The options names below are XML element localnames. When using a map, replace the hyphens with camel casing. For example, "an-option" becomes "anOption" when used as a map:map key. This function supports the following options:

<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.

<method>

Valid values are listed in xdmp:output in the XQuery and XSLT Reference Guide. This is like the corresponding part of both the XSLT xsl:output instruction. and the MarkLogic XQuery xdmp:output prolog statement.

<cdata-section-elements>

A list of space-separated QNames to output as CDATA sections. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<encoding>

The encoding. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<use-character-maps>

One or more of the following values, separated by spaces. Valid values are xdmp:sgml-entities-normal, xdmp:sgml-entities-math, and xdmp:sgml-entities-pub. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery prolog statement.

<media-type>

A mimetype representing a media type. For example, text/plain or application/xml (or other valid mimetypes). This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<byte-order-mark>

Valid values are yes or no. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<indent>

Specifies if typed XML (that is, XML for which there is an in-scope schema) should be pretty-printed (indented). Valid values are yes or no. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<indent-untyped>

Specifies if untyped XML (that is, XML for which there is no in-scope schema) should be pretty-printed (indented). Valid values are yes or no. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<indent-tabs>

Specifies if tab characters should be used instead of 8 consecutive spaces when indenting. Valid values are yes or no.

<include-content-type>

Include the content-type declaration when serializing the node. Valid values are yes or no.

<escape-uri-attributes>

Valid values are yes or no. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<doctype-public>

A public identifier, which is the public identifier to use on the emitted DOCTYPE. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<doctype-system>

A system identifier, which is the system identifier to use on the emitted DOCTYPE. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<omit-xml-declaration>

Valid values are yes or no. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<standalone>

Valid values are yes or no. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<normalization-form>

Valid values are NFC, NFD, and NFKD. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

<default-attributes>

Specifies whether attributes defaulted with a schema should be included in the serialization. Valid values are yes or no. This is like the corresponding part of both the XSLT xsl:output instruction and the MarkLogic XQuery xdmp:output prolog statement.

Example

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

(: returns the following output:
   (<a>aaa</a>, "<a>aaa</a>")
 :)

Example

xquery version "1.0-ml";

let $input-node := <parent><child>content</child></parent>
let $options :=
  <options xmlns="xdmp:quote">
    <indent-untyped>yes</indent-untyped>
    <omit-xml-declaration>no</omit-xml-declaration>
  </options>
return xdmp:quote($input-node, $options)

(: Returns the following (as a string value):
    <?xml version="1.0" encoding="UTF-8"?>
    <parent>
      <child>content</child>
    </parent>
 :)

Example

xquery version "1.0-ml";

let $input-node := <parent><child>content</child></parent>
let $options := 
  map:map() => map:with("indentUntyped", "yes")
            => map:with("omitXmlDeclaration", "no")
return xdmp:quote($input-node, $options)

(: Returns the following (as a string value):
    <?xml version="1.0" encoding="UTF-8"?>
    <parent>
      <child>content</child>
    </parent>
 :)

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.