xdmp.quote

xdmp.quote(
   arg as Sequence,
   [options as Object?]
) as 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. This function supports the following options:

outputEncoding

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

outputSgmlCharacterEntities

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 the XSLT xsl:output instruction. and the MarkLogic XQuery xdmp:output prolog statement.

cdataSectionElements

A single QName or array of 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 the XSLT xsl:output instruction.

useCharacterMaps

One or more of the following values, as a string or an array of strings. Valid values are xdmp:sgml-entities-normal, xdmp:sgml-entities-math, and xdmp:sgml-entities-pub. This is like the corresponding part of the XSLT xsl:output instruction and the MarkLogic XQuery prolog statement.

mediaType

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

byteOrderMark

Valid values are yes or no. This is like the corresponding part of the XSLT xsl:output instruction.

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 the XSLT xsl:output instruction.

indentUntyped

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 the XSLT xsl:output instruction.

indentTabs

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

includeContentType

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

escapeUriAttributes

Valid values are yes or no. This is like the corresponding part of the XSLT xsl:output instruction.

doctypePublic

A public identifier, which is the public identifier to use on the emitted DOCTYPE. This is like the corresponding part of the XSLT xsl:output instruction.

doctypeSystem

A system identifier, which is the system identifier to use on the emitted DOCTYPE. This is like the corresponding part of the XSLT xsl:output instruction.

omitXmlDeclaration

Valid values are yes or no. This is like the corresponding part of the XSLT xsl:output instruction.

standalone

Valid values are yes or no. This is like the corresponding part of the XSLT xsl:output instruction.

normalizationForm

Valid values are NFC, NFD, and NFKD. This is like the corresponding part of the XSLT xsl:output instruction.

defaultAttributes

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 the XSLT xsl:output instruction.

Example

'use strict';
const arg = fn.head(xdmp.unquote('<a>aaa</a>')).root;
[arg, xdmp.quote(arg)];

// Returns the following output:
//  ["<a>aaa</a>", "<a>aaa</a>"]

Example

'use strict';

//Build an XML node of the form <parent><child>content</child></parent>
const builder = new NodeBuilder();
const inputNode = 
  builder.startElement('parent')
         .startElement('child')
         .addText('content')
         .endElement()
         .endElement()
         .toNode();

const options = {indentUntyped: 'yes', omitXmlDeclaration: 'no'};
xdmp.quote(inputNode, options);

// Returns the following output (as a string value):
// <?xml version="1.0" encoding="UTF-8"?>
// <parent>
//   <child>content</child>
// </parent>
Powered by MarkLogic Server | Terms of Use | Privacy Policy