xdmp.save(
path as String,
node as Node,
[options as Object?]
) as null
Summary
Serializes a node as text and saves it to a file. The node can be any
node, including a document node, an element node, a text node, or a binary
node.
Parameters |
path |
The output file pathname. The path can be fully qualified or relative.
Relative pathnames are resolved from the directory in which
MarkLogic Server is installed.
|
node |
The node to be serialized.
|
options |
Options with which to customize this operation.
This function supports the following options:
- outputEncoding
- Specifies the encoding to use when saving the document.
- 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
xml , html ,
xhtml , and text . This is like the
corresponding part of both 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 both the XSLT
xsl:output
instruction and the MarkLogic XQuery
xdmp:output prolog
statement.
- 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 both the XSLT
xsl:output instruction and the MarkLogic XQuery
xdmp:output 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 both 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 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.
- 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 both the XSLT
xsl:output
instruction and the MarkLogic XQuery xdmp:output prolog
statement.
- 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 both the XSLT
xsl:output
instruction and the MarkLogic XQuery xdmp:output prolog
statement.
- doctypePublic
- 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.
- doctypeSystem
- 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.
- omitXmlDeclaration
- 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.
- normalizationForm
- 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.
- 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 both the XSLT
xsl:output
instruction and the MarkLogic XQuery xdmp:output prolog
statement.
|
Required Privileges
http://marklogic.com/xdmp/privileges/xdmp-save
Example
// serialize a JSON document in the database to a file on disk
xdmp.save('/space/hello.txt', cts.doc('/mydocs/example.json'));
Example
// save a text file
const textnode = xdmp.toJSON('hello');
xdmp.save('/space/hello.txt', textnode);
Example
// save a text document stored in the database to
// disk, explicitly specifying the output encoding
xdmp.save('mystuff.txt',
cts.doc('/mydocs/stuff.txt'),
{"outputEncoding": "utf-8"});
Copyright © 2024 MarkLogic Corporation. MARKLOGIC is a
registered trademark of MarkLogic Corporation.