
Built-In: Extension
|
|
The extension built-in functions are miscellaneous extensions to the
XQuery core library, including functions for evaluating
strings as XQuery expressions and functions to get information about
documents in the database.
EXSLT extension functions are extensions to XSLT spec as a community initiative.
They are defined at
EXSLT Extensions.
The JSON built-in functions serialize XQuery items to JSON and
read a JSON string and create XQuery items from it. JSON (JavaScript
Object Notation) is a data-interchange format popular mechanism for passing
data from JavaScript to other programming environments.
|
|
|
Function Summary
|
|
exsl:node-set
|
Returns a sequence of nodes based on the input object.
|
|
exsl:object-type
|
Returns a string that contains the type-name of the object passed as the argument.
|
|
json:array
|
Creates a (JSON) array, which is like a sequence of values, but allows
for nesting.
|
|
json:array-pop
|
Pop a value from the end of the array.
|
|
json:array-push
|
Push a value to the end of the array, increasing the size of the array
by one.
|
|
json:array-resize
|
Resize the array to the new size.
|
|
json:array-size
|
Returns the size of the array.
|
|
json:array-values
|
Returns the array values as an XQuery sequence.
|
|
json:object
|
Creates a JSON object, which is a kind of map with a fixed and ordered set of
keys.
|
|
json:object-define
|
Creates a JSON object.
|
|
json:set-item-at
|
Sets a value in an array at a specified position.
|
|
json:subarray
|
Extract a subarray from an array, producing a new array.
|
|
json:to-array
|
Constructs an array from a sequence of items.
|
|
xdmp:access
|
Returns whether a given action on the specified document URI would succeed.
|
|
xdmp:add64
|
Add two 64-bit integer values, discarding overflow.
|
|
xdmp:and64
|
AND two 64-bit integer values.
|
|
xdmp:annotation
|
Returns the named annotation from the function.
|
|
xdmp:apply
|
Applies an xdmp:function with the given parameters.
|
|
xdmp:architecture
|
Returns the hardware architecture upon which MarkLogic Server is running.
|
|
xdmp:atomizable
|
Returns true if a value could be atomized without error.
|
|
xdmp:base64-decode
|
Converts base64-encoded string to plaintext.
|
|
xdmp:base64-encode
|
Converts plaintext into base64-encoded string.
|
|
xdmp:binary-decode
|
Converts an encoded byte sequence, passed in as a binary node, from the
specified encoding to a unicode string.
|
|
xdmp:binary-is-external
|
Test whether or not a binary node represents an external binary.
|
|
xdmp:binary-is-large
|
Check whether a binary node is a large binary.
|
|
xdmp:binary-is-small
|
Check whether a binary node is a small binary.
|
|
xdmp:binary-size
|
Returns the size of the data, in bytes, represented by a binary node.
|
|
xdmp:bootstrap-hosts
|
Returns a sequence of the IDs of all the bootstrap hosts in the cluster.
|
|
xdmp:castable-as
|
Returns true if a value is castable.
|
|
xdmp:cluster
|
Returns the ID of the cluster named in the parameter.
|
|
xdmp:cluster-name
|
Returns the name of the cluster with the specified ID.
|
|
xdmp:collation-canonical-uri
|
Returns the canonical URI for the given URI, if it represents a
valid collation.
|
|
xdmp:collection-locks
|
Returns locks of documents in a collection.
|
|
xdmp:collection-properties
|
Returns a sequence of properties documents, one for each document in the
specified collection(s) that has a corresponding properties document.
|
|
xdmp:configuration-timestamp
|
Returns timestamp of last configuration changed
.
|
|
xdmp:crypt
|
Calculates the password hash for the given password and salt.
|
|
xdmp:crypt2
|
Calculates the password hash for the given plain-text password.
|
|
xdmp:current-last
|
Returns the size of the current node list.
|
|
xdmp:current-position
|
Returns the position of the current item.
|
|
xdmp:database
|
Returns the ID of the database named in the parameter.
|
|
xdmp:database-forests
|
Returns a sequence of forest IDs in the specified database.
|
|
xdmp:database-global-nonblocking-timestamp
|
Returns the most recent commit timestamp for which a query on the database
including its foreign database will not block waiting for transactions to commit
or journal frames to arrive from a foreign master.
|
|
xdmp:database-is-replica
|
Tests if a database is a replica of a foreign database.
|
|
xdmp:database-name
|
Return the name of the database with the given ID.
|
|
xdmp:database-nonblocking-timestamp
|
Returns the most recent commit timestamp for which a query on the database
will not block waiting for transactions to commit or journal frames to arrive
from a foreign master.
|
|
xdmp:database-path-namespaces
|
Returns the list of path namespaces for the given database id.
|
|
xdmp:databases
|
Returns a sequence of the IDs of all the databases in the system.
|
|
xdmp:decode-from-NCName
|
Invertible function that decodes characters an NCName produced by
xdmp:encode-for-NCName.
|
|
xdmp:describe
|
Returns a string representing the
description of a given item sequence.
|
|
xdmp:diacritic-less
|
Returns the specified string, converting all of the characters with diacritics
to characters without diacritics.
|
|
xdmp:directory
|
Returns the documents in a directory.
|
|
xdmp:directory-locks
|
Returns locks of documents in a directory.
|
|
xdmp:directory-properties
|
Returns a sequence of properties documents, one for each document in
the specified directory that has a corresponding properties document.
|
|
xdmp:document-forest
|
Returns the forest ID of the forest in which a document (or a lock or a
property) with the specified URI is stored.
|
|
xdmp:document-get
|
Returns the document in the file specified by $location.
|
|
xdmp:document-get-collections
|
Returns the collections to which a given document belongs.
|
|
xdmp:document-get-properties
|
Returns the property values for a document's property.
|
|
xdmp:document-get-quality
|
Returns the quality of the specified document if the document exists.
|
|
xdmp:document-locks
|
Returns the locks for one or more documents or directories.
|
|
xdmp:document-properties
|
Returns a sequence of properties documents, one for each of the specified
documents that has a corresponding properties document.
|
|
xdmp:document-timestamp
|
Returns timestamp of the most recent visible update to a
document, lock, or property.
|
|
xdmp:eager
|
Returns the value of its argument, evaluated eagerly.
|
|
xdmp:elapsed-time
|
Returns the elapsed time since the start of processing of this query.
|
|
xdmp:element-content-type
|
Returns the schema-defined content-type of an element
("empty", "simple", "element-only", or "mixed").
|
|
xdmp:email
|
Send an email in an XQuery program.
|
|
xdmp:encode-for-NCName
|
Invertible function that escapes characters required to be part of an NCName.
|
|
xdmp:encoding-language-detect
|
Analyzes binary, text, or XML data and suggests possible pairs of encoding
and language, with a confidence score for each pair.
|
|
xdmp:estimate
|
Returns the number of fragments selected by an expression.
|
|
xdmp:eval
|
Returns the result of evaluating a string
as an XQuery module.
|
|
xdmp:eval-in
|
[DEPRECATED: use xdmp:eval with the
database option instead] Returns the result of evaluating a string as
an XQuery module in a given database.
|
|
xdmp:exists
|
Returns true if any fragment is selected by an expression, false if no
fragments are selected.
|
|
xdmp:external-binary
|
Returns an external binary node.
|
|
xdmp:external-binary-path
|
Return the path to the external file associated with an external
binary document.
|
|
xdmp:foreign-clusters
|
Returns the IDs of the foreign clusters.
|
|
xdmp:forest
|
Returns the ID of the forest specified as the parameter.
|
|
xdmp:forest-databases
|
Returns the database ID corresponding to the database to which
the specified forest belongs.
|
|
xdmp:forest-host
|
Return the host of the forest with the given id.
|
|
xdmp:forest-name
|
Return the name of the forest with the given id.
|
|
xdmp:forest-updates-allowed
|
Return updates allowed state of the forest with the given ID.
|
|
xdmp:forests
|
Returns a sequence of the IDs of all the forests in the system.
|
|
xdmp:format-number
|
Returns a formatted number value based on the picture argument.
|
|
xdmp:from-json
|
Parses a string as JSON, returning an item sequence.
|
|
xdmp:function
|
Returns a function value as an xdmp:function type.
|
|
xdmp:function-module
|
Returns the module location (if any) that the xdmp:function value refers to.
|
|
xdmp:function-name
|
Returns the QName of the function(s) that the xdmp:function refers to.
|
|
xdmp:function-parameter-name
|
Returns the name of the parameter at the designated (1-based) position from the given function's signature.
|
|
xdmp:function-parameter-type
|
Returns the type of the parameter at the designated (1-based) position from the given function's signature.
|
|
xdmp:function-return-type
|
Returns the return type from the given function's signature.
|
|
xdmp:function-signature
|
Returns the signature of the function that the argument refers to.
|
|
xdmp:functions
|
Returns all in-scope functions.
|
|
xdmp:get
|
[DEPRECATED: use xdmp:document-get
instead] Returns the document in the XML file specified by $path.
|
|
xdmp:get-orphaned-binaries
|
Returns a sequence of the IDs of all orphaned large binaries in a given forest.
|
|
xdmp:group
|
Returns the ID of the group specified in the parameter.
|
|
xdmp:group-hosts
|
Returns the IDs of all hosts belonging to the group with the given ID.
|
|
xdmp:group-name
|
Returns the name of the group with the given ID.
|
|
xdmp:group-servers
|
Returns the IDs of all App Servers belonging to the group with
the given ID.
|
|
xdmp:groups
|
Returns a sequence of the IDs of all the groups in the system.
|
|
xdmp:hash32
|
Returns the 32-bit hash of a string.
|
|
xdmp:hash64
|
Returns the 64-bit hash of a string.
|
|
xdmp:hex-to-integer
|
Parses a hexadecimal string, returning an integer.
|
|
xdmp:hmac-md5
|
Calculates the Hash-based Message Authentication Code (HMAC) using the md5 hash function of the given secret key and message arguments.
|
|
xdmp:hmac-sha1
|
Calculates the Hash-based Message Authentication Code (HMAC) using the SHA1 hash function of the given secret key and message arguments.
|
|
xdmp:hmac-sha256
|
Calculates the Hash-based Message Authentication Code (HMAC) using the SHA256 hash function of the given secret key and message arguments.
|
|
xdmp:hmac-sha512
|
Calculates the Hash-based Message Authentication Code (HMAC) using the SHA512 hash function of the given secret key and message arguments.
|
|
xdmp:host
|
Returns the ID of the host named in the parameter.
|
|
xdmp:host-forests
|
Returns a sequence of forest IDs in the specified host.
|
|
xdmp:host-group
|
Returns the ID of the group that the specified host belongs to.
|
|
xdmp:host-name
|
Returns the name of the specified host.
|
|
xdmp:hosts
|
Returns a sequence of the IDs of all the hosts in the cluster.
|
|
xdmp:http-delete
|
Sends an http DELETE request to the http server specified in the URI
to delete the specified resource.
|
|
xdmp:http-get
|
Sends the http GET method to the specified URI.
|
|
xdmp:http-head
|
Sends the http HEAD method to the specified URI.
|
|
xdmp:http-options
|
Sends the http OPTIONS method to the specified URI.
|
|
xdmp:http-post
|
Sends the http POST request to the server.
|
|
xdmp:http-put
|
Sends an HTTP PUT request to an HTTP server.
|
|
xdmp:initcap
|
Returns the string where the first letter of each token has been uppercased.
|
|
xdmp:integer-to-hex
|
Returns a hexadecimal representation of an integer.
|
|
xdmp:integer-to-octal
|
Returns an octal representation of an integer.
|
|
xdmp:invoke
|
Returns the result of evaluating a module at the given path.
|
|
xdmp:invoke-function
|
Returns the result of evaluating a function value.
|
|
xdmp:invoke-in
|
[DEPRECATED: use xdmp:invoke with the
database option instead] Returns the result of evaluating a module
at the given path.
|
|
xdmp:key-from-QName
|
Construct a context-independent string from a QName.
|
|
xdmp:lazy
|
Returns the value of its argument, evaluated lazily.
|
|
xdmp:ldap-lookup
|
Returns an ldap entry.
|
|
xdmp:ldap-search
|
Returns ldap search result.
|
|
xdmp:log
|
Logs a debug message to the log file
<install_dir>/Logs/ErrorLog.txt.
|
|
xdmp:log-level
|
Retrieves the current server log level.
|
|
xdmp:lshift64
|
Left-shift a 64-bit integer value.
|
|
xdmp:md5
|
Calculates the md5 hash of the given argument.
|
|
xdmp:modules-database
|
Returns the database ID of the modules database.
|
|
xdmp:modules-root
|
Returns the current root path for modules.
|
|
xdmp:mul64
|
Muliply two 64-bit integer values, discarding overflow.
|
|
xdmp:multipart-decode
|
Extract the parts from a multipart encoding.
|
|
xdmp:multipart-encode
|
Create a multipart encoding of the specified node.
|
|
xdmp:node-database
|
Returns the database id where the parameter is stored.
|
|
xdmp:node-kind
|
Returns an xs:string representing the node's kind: either
"document", "element", "attribute", "text", "namespace",
"processing-instruction", "binary", or "comment".
|
|
xdmp:node-uri
|
Returns the document-uri property of the parameter or its ancestor.
|
|
xdmp:not64
|
NOT a 64-bit integer value.
|
|
xdmp:octal-to-integer
|
Parses an octal string, returning an integer.
|
|
xdmp:or64
|
OR two 64-bit integer values.
|
|
xdmp:parse-dateTime
|
Parses a string containing date, time or dateTime using the supplied
picture argument and returns a dateTime value.
|
|
xdmp:parse-yymmdd
|
Parses a string containing date, time or dateTime using the supplied
picture argument and returns a dateTime value.
|
|
xdmp:path
|
Returns a string whose value corresponds to the
path of the node.
|
|
xdmp:plan
|
Returns an XML element recording information about how the given
expression will be processed by the index.
|
|
xdmp:plannable
|
Returns a boolean showing whether the given expression is suitable to use
with xdmp:plan.
|
|
xdmp:platform
|
Returns the operating-system platform upon which MarkLogic Server is running
("solaris", "winnt", "linux", or "macosx").
|
|
xdmp:position
|
Returns an integer value representing the starting position of a
string within the search string.
|
|
xdmp:pretty-print
|
Returns a well-formatted XQuery module.
|
|
xdmp:product-edition
|
Returns the current MarkLogic product edition.
|
|
xdmp:product-environment
|
Returns the current MarkLogic product environment.
|
|
xdmp:QName-from-key
|
Construct a QName from a string of the form "{namespaceURI}localname".
|
|
xdmp:query-meters
|
Returns the current value of the resource meters for this
query sequence.
|
|
xdmp:query-trace
|
Enables or disables tracing of this query.
|
|
xdmp:quote
|
Returns the unevaluated serialized representation
of the input parameter as a string.
|
|
xdmp:random
|
Returns a random unsigned integer between 0 and a number up to 64 bits long.
|
|
xdmp:remove-orphaned-binary
|
Remove an orphaned large binary
.
|
|
xdmp:request
|
Returns the unique key of the current request.
|
|
xdmp:request-timestamp
|
Returns the system timestamp for this request if the request is a query
statement.
|
|
xdmp:resolve-uri
|
Resolves a relative URI against an absolute URI.
|
|
xdmp:rethrow
|
Within the catch section of a try-catch expression,
re-throw the currently caught error.
|
|
xdmp:rshift64
|
Right-shift a 64-bit integer value.
|
|
xdmp:schema-database
|
Returns the database ID of the schema database
associated with the current database.
|
|
xdmp:security-database
|
Returns the database ID of the security database
associated with the current database.
|
|
xdmp:server
|
Return the ID(s) of the App Servers, XDBC Servers, ODBC Servers,
or Task Servers with the given name.
|
|
xdmp:server-collation
|
Return the default collation of the App Server, XDBC Server, ODBC Server,
or Task Server with the given ID.
|
|
xdmp:server-database
|
Return the database ID of the App Server, XDBC Server, ODBC Server, or Task Server
with the given ID.
|
|
xdmp:server-default-xquery-version
|
Return the default xquery version of the App Server, XDBC Server, ODBC Server,
or Task Server with the given ID.
|
|
xdmp:server-group
|
Return the ID of the group for an App Server, XDBC Server, ODBC Server,
or Task Server.
|
|
xdmp:server-modules-database
|
Return the modules database ID of the App Server, XDBC Server, ODBC Server,
or Task Server with the given ID.
|
|
xdmp:server-name
|
Return the name of the App Server, XDBC Server, ODBC Server, or Task Server
with the given ID.
|
|
xdmp:server-port
|
Return the port of the App Server, XDBC Server, ODBC Server, or Task Server
with the given ID.
|
|
xdmp:server-root
|
Return the root of the App Server, XDBC Server, ODBC Server,
or Task Server with the given ID.
|
|
xdmp:server-ssl-certificate-template
|
Return the SSL certificate template ID of the App Server, XDBC Server,
ODBC Server, or Task Server with the given ID.
|
|
xdmp:servers
|
Returns a sequence of the IDs of all the App Servers in the system.
|
|
xdmp:set
|
Set the value of a variable to the specified expression.
|
|
xdmp:sha1
|
Calculates the SHA1 hash of the given argument.
|
|
xdmp:sha256
|
Calculates the SHA256 hash of the given argument.
|
|
xdmp:sha384
|
Calculates the SHA384 hash of the given argument.
|
|
xdmp:sha512
|
Calculates the SHA512 hash of the given argument.
|
|
xdmp:sleep
|
Delays for a specific amount of time.
|
|
xdmp:spawn
|
Place the specified module on the task queue for evaluation.
|
|
xdmp:spawn-function
|
Place the specified function value on the task queue for evaluation.
|
|
xdmp:spawn-in
|
[DEPRECATED: use xdmp:spawn with the
database option instead] Place the specified module on the task
queue for evaluation.
|
|
xdmp:sql
|
Executes an ad hoc SQL query.
|
|
xdmp:step64
|
Combines an initial hash with a subsequent hash.
|
|
xdmp:strftime
|
Formats a dateTime value using POSIX strftime.
|
|
xdmp:subbinary
|
Returns a binary node made up of a subset of the given binary node.
|
|
xdmp:timestamp-to-wallclock
|
Converts a 64 bit timestamp value to an xs:dateTime.
|
|
xdmp:to-json
|
Returns a string representing a JSON
serialization of a given item sequence.
|
|
xdmp:trace
|
Signal a trace event.
|
|
xdmp:triggers-database
|
Returns the database ID of the triggers database
associated with the current database.
|
|
xdmp:type
|
Returns the name of the simple type of the atomic value argument as an xs:QName.
|
|
xdmp:unpath
|
Evaluate a string as an XPath and return the corresponding node(s).
|
|
xdmp:unquote
|
Parses a string as XML, returning one or more document nodes.
|
|
xdmp:uri-content-type
|
Returns the content type of the given URI as matched in the mimetypes
configuration.
|
|
xdmp:uri-format
|
Returns the format of the given URI as matched in the mimetypes
configuration.
|
|
xdmp:user-last-login
|
Returns the last-login node for the specified user ID.
|
|
xdmp:validate
|
Returns an element containing a summary of validation errors in a node.
|
|
xdmp:value
|
Evaluate an expression in the context of the current evaluating statement.
|
|
xdmp:version
|
Returns the current MarkLogic Server version.
|
|
xdmp:wallclock-to-timestamp
|
Converts an xs:dateTime to a 64 bit timestamp value.
|
|
xdmp:with-namespaces
|
Evaluates the expression in the context of a specific set of namespace
bindings.
|
|
xdmp:xor64
|
XOR two 64-bit integer values.
|
|
xdmp:xquery-version
|
Returns the XQuery language version of the calling module.
|
|
xdmp:xslt-eval
|
Executes an XSLT stylesheet against a node.
|
|
xdmp:xslt-invoke
|
Executes an XSLT stylesheet against a node.
|
|
 |
|
Function Detail
|
|
|
json:set-item-at(
|
|
$array as json:array,
|
|
$pos as xs:double,
|
|
$value as item()*
|
| ) as empty-sequence() |
|
 |
Summary:
Sets a value in an array at a specified position.
|
Parameters:
$array
:
An array.
|
$pos
:
The position to update. Invalid positions throw XDMP-ARRAYINDEXOUTOFBOUNDS
|
$value
:
A value. Empty sequences are allowed.
|
|
Example:
let $array := json:to-array( ("a","b","c"), 5 )
let $put := json:set-item-at($array, 5 , <info>45683</info>)
return
<result>{$array}</result>
=>
<result>
<json:array xmlns:json="http://marklogic.com/xdmp/json">
<json:value xsi:type="xs:string">a</json:value>
<json:value xsi:type="xs:string">b</json:value>
<json:value xsi:type="xs:string">c</json:value>
<json:value xsi:nil="true"/>
<json:value><info>45683</info></json:value>
</json:array>
</result>
|
Example:
xquery version "1.0-ml";
let $array := json:to-array(("a", "z", "c"))
return (
$array[2],
json:set-item-at($array, 2, "b"),
$array[2]
)
=>
z
b
|
|
|
|
xdmp:document-get(
|
|
$location as xs:string,
|
|
[$options as node()?]
|
| ) as node()? |
|
 |
Summary:
Returns the document in the file specified by $location.
|
Parameters:
$location
:
The location of the input document. If the scheme of the location is
HTTP (that is, if the string starts with "http://"), then the document is
requested over HTTP. If the scheme is file (that is, if the string starts
with "file://"), then the document is requested over file protocol from
the local filesystem.
Otherwise, the document is fetched from the local
filesystem. On the filesystem, the path can be fully qualifed or relative.
Relative pathnames are resolved from the directory in which
MarkLogic Server is installed.
|
$options
(optional):
The options node for getting this document. The default value is ().
The node for the xdmp:document-get options must be in the
xdmp:document-get namespace. This parameter can also include
option elements in the xdmp:http
namespace for the HTTP parameters.
The xdmp:document-get options include:
<default-namespace>
- The namespace to use if there is no namespace at the root node of
the document. The default value is "".
<repair>
- A value of
full specifies that malformed XML content be
repaired. A value of none specifies that malformed
XML content is rejected.
If no repair option is explicitly specified, the default is
implicitly specified by the XQuery version of the caller.
In XQuery 1.0 and 1.0-ml the default
is none. In XQuery 0.9-ml the
default is full.
This option has no effect on binary or text documents.
<format>
- A value of
text specifies to get the document as a
text document, regardless of the URI specified. A value of
binary specifies to get the document as a binary
document, regardless of the URI specified. A value of xml
specifies to get the document as an XML document, regardless of the
URI specified.
<default-language>
- The language to specify in an
xml:lang attribute on the
root element node if the root element node does not already have an
xml:lang attribute. If default-language is
not specified, then nothing is added to the root element node.
<encoding>
- Specifies the encoding to use when reading the document into MarkLogic
Server. Supported values include
UTF-8,
ISO-8859-1, as well as many other popular encodings.
See the Search Developer's Guide for a list of character
set encodings by
language. All encodings will be translated into UTF-8
from the specified encoding. The string specifed for the
encoding option will be matched to an encoding name according
to the Unicode Charset Alias Matching rules
(http://www.unicode.org/reports/tr22/#Charset_Alias_Matching).
An automatic encoding detector will be used if the value auto
is specified.
If no encoding can be detected, the encoding defaults to UTF-8.
If no encoding option is specified, the encoding defaults to the
encoding specified in the http header (if using with one of the http
functions, for example, xdmp:http-get), otherwise it defaults
to UTF-8; any encoding http headers are ignored if there is any
value specified for the encoding option.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-document-get
|
Usage Notes:
If no format is specified in $options, and the document is from
an HTTP server, the format is specified by the document content type
from the HTTP response.
If no format is specified in $options, and the document is from
the filesystem, the format is specified by the document content type
from the filename extension.
The mimetype extensions and corresponding content types are set in the
Admin Interface.
If no repair option is specified,
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</repair>. In XQuery version
0.9-ml the default is
<repair>full</repair>.
When the document is from an HTTP server,
xdmp:document-get will always return the response from the
HTTP server, even if it is an error response such as 404 or 500. If you
want to be able to examine the response header in your application, use
the xdmp:http-get instead, which
returns both the response header and the response.
|
Example:
xdmp:document-get("myDocument.xml")
=> the xml contained in myDocument.xml,
for example, <myDocument/>
|
Example:
xdmp:document-get("myDocument.html",
<options xmlns="xdmp:document-get">
<repair>full</repair>
</options>)
=> myDocument.html as an XML document that has gone
through any needed tag repair
|
Example:
xdmp:document-get("http://myCompany.com/file.xml",
<options xmlns="xdmp:document-get"
xmlns:http="xdmp:http">
<format>xml</format>
<http:authentication>
<http:username>user</http:username>
<http:password>pass</http:password>
</http:authentication>
</options>)
=> gets an XML document named file.xml, sending the
authentication credentials user/pass to the
http://myCompany.com server
|
|
|
|
xdmp:document-locks(
|
|
[$uri as xs:string*]
|
| ) as document-node()* |
|
 |
Summary:
Returns the locks for one or more documents or directories.
Returns the locks for all documents and directories
in the database if no parameter is given.
|
Parameters:
$uri
(optional):
A document URI.
|
|
Usage Notes:
Note that the locks described here are relatively heavy persistent
document locks for file system emulation through WebDAV, not relatively
light transaction locks for database consistency.
|
Example:
xdmp:document-locks("example.xml")
=>
<?xml version="1.0" encoding="ASCII"?>
<lock:lock xmlns:lock="http://marklogic.com/xdmp/lock">
<lock:lock-type>write</lock:lock-type>
<lock:lock-scope>exclusive</lock:lock-scope>
<lock:active-locks>
<lock:active-lock>
<lock:depth>0</lock:depth>
<lock:owner>
<DAV:href xmlns:DAV="DAV:">http://example.com/~user</DAV:href>
</lock:owner>
<lock:timeout>120</lock:timeout>
<lock:lock-token>http://marklogic.com/xdmp/locks/1c267a036b8480c3
</lock:lock-token>
<lock:timestamp>1290136652</lock:timestamp>
<sec:user-id xmlns:sec="http://marklogic.com/xdmp/security">
893641342095093063</sec:user-id>
</lock:active-lock>
</lock:active-locks>
</lock:lock>
|
Example:
xquery version "1.0-ml";
(:
The time is in epoch time, which is seconds from the start
of 1970, so this code does a little math on the values in
the lock document to figure out how many seconds are left
for the lock. Assumes a lock on /example.xml, for example
by running the following:
xquery version "1.0-ml";
declare namespace DAV="DAV:";
xdmp:lock-acquire("/example.xml",
"exclusive",
"0",
<DAV:href>http://example.com/~user</DAV:href>,
xs:unsignedLong(120))
:)
let $lock := xdmp:document-locks("/example.xml")
let $lock-duration :=
$lock/lock:lock/lock:active-locks/lock:active-lock/
lock:timeout/fn:data(.)
let $current-epoch-time :=
fn:round(
( fn:current-dateTime() - xs:dateTime("1970-01-01T00:00:00-00:00") )
div xs:dayTimeDuration('PT1S') )
let $start-time :=
$lock/lock:lock/lock:active-locks/lock:active-lock/
lock:timestamp/fn:data(.)
let $end-time := $start-time + $lock-duration
let $seconds-left := $end-time - $current-epoch-time
return
($current-epoch-time, $start-time, $seconds-left)
=>
1290136837
1290136832
115
|
|
|
|
xdmp:elapsed-time( ) as xs:dayTimeDuration
|
|
 |
Summary:
Returns the elapsed time since the start of processing of this query. Gives
the same information as the elapsed-time element of the
xdmp:query-meters output, but has less overhead than calling
xdmp:query-meters.
|
Usage Notes:
Certain operations are run concurrently with the timing operations,
and if those operations are not actually used in the query, they might not
be included in the timings. This occurs for operations like
xdmp:estimate, xdmp:exists, and lexicon calls
(for example, cts:element-values). If you want to see the
total timings that include calls that are not used, you can form some other
expression with the results of the calls. For example, if you have an
expression that calls xdmp:estimate in a let
expression, you can add 0 to the output, which causes it to be included in
the timings (something like xdmp:estimate($query) + 0).
|
Example:
xquery version "1.0-ml";
fn:count(collection()),
xdmp:elapsed-time()
=> The count of the number of documents in the database followed by
the elapsed-time of the query:
153
PT0.04S
|
|
|
|
xdmp:email(
|
|
$message as node()
|
| ) as empty-sequence() |
|
 |
Summary:
Send an email in an XQuery program. A valid SMTP Relay must be
configured in the Groups page of the Admin Interface for the email to be
sent. The format of the email message must be an XML file that
complies with the schema files listed below.
|
Parameters:
$message
:
An XML representation of an email message to send. The message must
comply with the XML schemas defined in the following schema files:
install_dir/Config/email-xml.xsd
install_dir/Config/rfc822.xsd
where install_dir is the directory in which
MarkLogic Server is installed.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-email
|
Example:
This example demonstrates sending a message with
HTML content.
xdmp:email(
<em:Message
xmlns:em="URN:ietf:params:email-xml:"
xmlns:rf="URN:ietf:params:rfc822:">
<rf:subject>Sample HTML Email</rf:subject>
<rf:from>
<em:Address>
<em:name>MarkLogic</em:name>
<em:adrs>marklogic@yourdomain</em:adrs>
</em:Address>
</rf:from>
<rf:to>
<em:Address>
<em:name>System Administrator</em:name>
<em:adrs>admin@yourdomain</em:adrs>
</em:Address>
</rf:to>
<em:content>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test HTML message</title>
</head>
<body>
<h1>Test HTML message</h1>
<p>Here is a simple paragraph</p>
</body>
</html>
</em:content>
</em:Message>)
|
Example:
This example demonstrate sending a message with
plain text content.
xdmp:email(
<em:Message
xmlns:em="URN:ietf:params:email-xml:"
xmlns:rf="URN:ietf:params:rfc822:">
<rf:subject>Sample Plain Text Email</rf:subject>
<rf:from>
<em:Address>
<em:name>MarkLogic</em:name>
<em:adrs>marklogic@yourdomain</em:adrs>
</em:Address>
</rf:from>
<rf:to>
<em:Address>
<em:name>System Administrator</em:name>
<em:adrs>admin@yourdomain</em:adrs>
</em:Address>
</rf:to>
<em:content xml:space="preserve">
This is a sample email with a plain text body.
</em:content>
</em:Message>)
|
Example:
This example demonstrates sending a message with
attachments.
let $newline := " "
let $boundary := concat("blah", xdmp:random())
let $content-type := concat("multipart/mixed; boundary=",$boundary)
let $attachment1 := xs:base64Binary(doc("/space/binaries/testdata1/Bon-Jovi.jpeg"))
let $attachment2 := xs:base64Binary(doc("/space/binaries/testdata1/logo.gif"))
let $content := concat(
"--",$boundary,$newline,
$newline,
"This is a test email with two images attached.", $newline,
"--",$boundary,$newline,
"Content-Type: image/jpeg", $newline,
"Content-Disposition: attachment; filename=Bon-Jovi.jpeg", $newline,
"Content-Transfer-Encoding: base64", $newline,
$newline,
$attachment1, $newline,
"--",$boundary,$newline,
"Content-Type: image/gif", $newline,
"Content-Disposition: attachment; filename=logo.gif", $newline,
"Content-Transfer-Encoding: base64", $newline,
$newline,
$attachment2, $newline,
"--",$boundary,"--", $newline)
return
xdmp:email(
<em:Message
xmlns:em="URN:ietf:params:email-xml:"
xmlns:rf="URN:ietf:params:rfc822:">
<rf:subject>Sample Email</rf:subject>
<rf:from>
<em:Address>
<em:name>MarkLogic</em:name>
<em:adrs>marklogic@yourdomain</em:adrs>
</em:Address>
</rf:from>
<rf:to>
<em:Address>
<em:name>System Administrator</em:name>
<em:adrs>admin@yourdomain</em:adrs>
</em:Address>
</rf:to>
<rf:content-type>{$content-type}</rf:content-type>
<em:content xml:space="preserve">
{$content}
</em:content>
</em:Message>)
|
|
|
|
xdmp:eval(
|
|
$xquery as xs:string,
|
|
[$vars as item()*],
|
|
[$options as node()?]
|
| ) as item()* |
|
 |
Summary:
Returns the result of evaluating a string
as an XQuery module.
|
Parameters:
$xquery
:
The XQuery string to be evaluated. If the XQuery string contains
double quotes ("), surround the string with single quotes (').
|
$vars
(optional):
The external variable values for this evaluation.
This can either be a sequence of map:map objects, or a sequence of even
length, alternating QNames and items.
Each key in the map(s) is a string representing the name of the parameter
in Clark notation: "{namespaceURI}localname". The function
xdmp:key-from-QName
is a convenient way to generate these keys.
Each entry in the map is the value of the corresponding external variable.
Alternatively, the alternating sequence should contain QName and item
pairs that specify a variable name and value for an external variable.
|
$options
(optional):
The options node. The default value is ().
The node for the xdmp:eval options must be in the
xdmp:eval namespace. The following is a sample options
node:
<options xmlns="xdmp:eval">
<isolation>different-transaction</isolation>
<prevent-deadlocks>true</prevent-deadlocks>
</options>
The xdmp:eval options include:
<database>
- The database ID, from
xdmp:database("db_name"),
xdmp:security-database(),
or xdmp:schema-database(). To specify a database other
than the context database, the
http://marklogic.com/xdmp/privileges/xdmp-eval-in privilege
is required.
<modules>
- The modules database ID for processing module imports.
Specifying no
<modules> element in the
options node specifies the current modules database. Specifying
0 specifies using the file system to process
module imports. You must have the
http://marklogic.com/xdmp/privileges/xdmp-eval-modules-change
(for xdmp:eval),
http://marklogic.com/xdmp/privileges/xdmp-invoke-modules-change
(for xdmp:invoke), or the
http://marklogic.com/xdmp/privileges/xdmp-spawn-modules-change
(for xdmp:spawn)
privilege to change either the modules database to another database
or to change the root to another path. You must have the
http://marklogic.com/xdmp/privileges/xdmp-eval-modules-change-file
(for xdmp:eval),
http://marklogic.com/xdmp/privileges/xdmp-invoke-modules-change-file
(for xdmp:invoke), or the
http://marklogic.com/xdmp/privileges/xdmp-eval-modules-change-file
(for xdmp:spawn)
privilege to change the modules database to the file
system or to change a root on the filesystem.
<root>
- The root path for modules.
Specifying no
<root> element in the options
node specifies the current root. You need the same privileges
to modify the root as you need to change the module
option.
<timestamp>
- The system timestamp to use for this evaluation. Specifying
no
<timestamp> element in the
options node specifies the most recent timestamp. You may only
specify a timestamp for a query statement, not for an
update statement. The timestamp is a number that is incremented by
1 each time any configuration or content change is made to the system.
Specifying a timestamp of 0 uses the current system timestamp (the
value returned by xdmp:request-timestamp()). Specifying
a timestamp requires the xdmp:timestamp execute
privilege.
<ignore-amps>
- (Only valid with
xdmp:eval, xdmp:invoke,
xdmp:xslt-eval, xdmp:xslt-invoke;
does not apply to xdmp:spawn, dbg:eval or
dbg:invoke) Either
true or
false. When set to
true, the statement is evaluated without using any Amps
from the caller.
The default value for the ignore-amps option
is false.
<isolation>
- (Only valid with
xdmp:eval or xdmp:invoke;
does not apply to xdmp:spawn.) Either
same-statement or
different-transaction. When set to
same-statement, the statement is evaluated in the same
transaction as the one from which it is called, and subsequent
expressions in the calling statement will not see any updates performed
in the eval/invoke/spawn. You can only use same-statement
isolation with update statements; query statements with
same-statement isolation will throw an exception. When set to
different-transaction, the statement is evaluated in
a separate transaction from the one in which it is called, making those
updates available to subsequent expressions in the calling statement
(assuming the calling statement is an update statement; if the calling
statement is not an update, then subsequent expressions will see the
version of the database at the system timestamp when the calling statement
begins its evaluation).
When using different-transaction in an update statement that
calls another update statement, do not update the same document as
the calling statement is updating; doing so can cause a deadlock.
You cannot evaluate a statement in a different database with the
isolation option set to same-statement.
The default value for the isolation option
is different-transaction. For more details, see the
"Understanding Transactions in MarkLogic Server" chapter of the
Developer's Guide.
<static-check>
-
Specify
true to only perform static
checks on the module, and not to actually execute it.
<prevent-deadlocks>
- (Only valid with
xdmp:eval or xdmp:invoke;
does not apply to xdmp:spawn.)
Specify true for the server to disallow update requests
from an update transaction. Only has an effect when the
isolation option is set to different-transaction
as there is no possibility of a deadlock if the isolation
option is set to same-statement.
When set to true in an update request calling another
update request, MarkLogic Server throws the
XDMP-PREVENTDEADLOCKS
exception. Setting this option to true prevents
the possibility of deadlocks occurring when running eval/invoke of
an update transaction from another update transaction. The default value
for the prevent-deadlocks option is false.
<default-xquery-version>
- The default XQuery language version to use for the query, if the query
does not contain an explicit version declaration. If this option is not
provided, the defaults are:
xdmp:eval: The XQuery language version of the module
that called eval. This version may vary module-by-module if
a query consists of modules written in multiple language versions.
It may also vary from run to run if the app-server default is changed.
-
xdmp:invoke: The default XQuery version for the
app server that the invocation occurs on. Note that this may be
different than the XQuery version of the module that calls
xdmp:invoke.
-
xdmp:spawn: The XQuery version default set on the
app server that called xdmp:spawn. The Task Server
has no default XQuery version, the version to use is passed as a
part of the task request.
Allowable values for this option are "0.9-ml", "1.0-ml", "1.0" and
the special value "app-server". The first three are XQuery language
versions. The last indicates that the default XQuery language
version set on this app-server should be used. This is useful if code
written in an older XQuery version needs to call xdmp:eval
on strings that may have been passed as parameters, but should be
interpreted in the app-server's default language version. A module
may discover its own XQuery language version with
xdmp:xquery-version.
<time-limit>
- Override the default time limit with this time limit, in seconds,
for this evaluation. You can set the
value up to the maximum-time-limit value for the App Server in which
the request is evaluated or to a lower value than the default time
limit. This option only applies to
xdmp:spawn, not to
xdmp:invoke or xdmp:eval.
<user-id>
- Specifies the user ID for the user to run the request being
evaluated (the request specified in the
$xquery parameter).
If no user-id is specified, then the
request is run as the current user. You need to have the
xdmp:login
(http://marklogic.com/xdmp/privileges/xdmp-login)
privilege to use the user-id option. Be aware that this
is a very privileged operation, as it allows a user with this
privilege to evaluate requests as any other user. For an example,
see the fourth example below.
<default-collation>
- Specifies the collation to use for this context, unless a collation is
explicitly specified in the XQuery prolog or in a function call that
allows you to specify a collation.
<priority>
- Specify the priority of the spawned task.
Allowable values for this option are "normal" and "higher".
This option only applies to
xdmp:spawn, not to
xdmp:invoke or xdmp:eval.
<result>
- Return a value future for the result of the spawned task.
This value future can bound be to a variable without waiting so
that work can proceed concurrently with the spawned task.
When the calling request uses the value future in any operation,
it will automatically wait for the spawned task to complete and it will
use the result.
This option only applies to
xdmp:spawn, not to
xdmp:invoke or xdmp:eval. For an example, see
The second xdmp:spawn
example.
<transaction-mode>
- Explicitly set the transaction mode for this context.
Valid values are
auto, query,
update-auto-commit, and update.
The default is auto.
For simple updates to be implicitly committed, specify a transaction
mode of update-auto-commit.
A transaction mode of update creates a new multi-statement update
transaction and requires an explicit commit in the code.
Within a session there can be only one active multi-statement
transaction at a time.
If a new multi-statement transaction is specified nested inside a
multi-statement transaction, an XDMP-NESTEDMULTI error
is returned.
If a new multi-statement transaction is specified but another has
already been concurrently created in the same session by another request,
an XDMP-SESSIONTXN error is returned and the current request
is retried.
An xdmp:transaction-mode prolog option in evaluated
XQuery will override any transaction mode specified with this
option.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-eval
You must have the
http://marklogic.com/xdmp/privileges/xdmp-eval-in privilege to
specify the <database> option with a database other than the context database.
You must have the
http://marklogic.com/xdmp/privileges/xdmp-eval-modules-change
(for xdmp:eval),
http://marklogic.com/xdmp/privileges/xdmp-invoke-modules-change
(for xdmp:invoke), or the
http://marklogic.com/xdmp/privileges/xdmp-spawn-modules-change
(for xdmp:spawn)
privilege to change either the modules database to another database
or to change the root to another path. You must have the
http://marklogic.com/xdmp/privileges/xdmp-eval-modules-change-file
(for xdmp:eval),
http://marklogic.com/xdmp/privileges/xdmp-invoke-modules-change-file
(for xdmp:invoke), or the
http://marklogic.com/xdmp/privileges/xdmp-eval-modules-change-file
(for xdmp:spawn)
privilege to change the modules database to the file
system or to change a root on the filesystem.
You must have the
http://marklogic.com/xdmp/privileges/xdmp-login
privilege to use the user-login option.
|
Example:
|
Example:
xquery version "1.0-ml";
declare namespace my='http://mycompany.com/test';
let $s :=
"xquery version '1.0-ml';
declare namespace my='http://mycompany.com/test';
declare variable $my:x as xs:string external;
concat('hello ', $my:x)"
return
(: evaluate the query string $s using the variables
supplied as the second parameter to xdmp:eval :)
xdmp:eval($s, (xs:QName("my:x"), "world"))
=> hello world
|
Example:
xdmp:eval("doc('/docs/mydoc.xml')", (),
<options xmlns="xdmp:eval">
<database>{xdmp:database("otherdb")}</database>
</options>)
=> The '/docs/mydoc.xml' document from the
otherdb database.
|
Example:
xdmp:eval('xdmp:get-current-user()', (),
<options xmlns="xdmp:eval">
<user-id>{xdmp:user("someuser")}</user-id>
</options>)
(:
returns "someuser", assuming "someuser" exists in the
security database and the user running the eval request has the
xdmp:login privilege.
:)
|
|
|
|
xdmp:eval-in(
|
|
$xquery as xs:string,
|
|
$ID as xs:unsignedLong,
|
|
[$vars as item()*],
|
|
[$modules as xs:unsignedLong?],
|
|
[$root as xs:string?]
|
| ) as item()* |
|
 |
Summary:
[DEPRECATED: use xdmp:eval with the
database option instead] Returns the result of evaluating a string as
an XQuery module in a given database.
|
Parameters:
$xquery
:
The XQuery string to be evaluated. If the XQuery string contains
double quotes ("), surround the string with single quotes (').
|
$ID
:
The database ID, from xdmp:database("db_name"),
xdmp:security-database(),
or xdmp:schema-database().
|
$vars
(optional):
The external variable values for this evaluation.
This must be a sequence of even length, alternating QNames and items.
Each QName and item pair specify a variable name and value.
|
$modules
(optional):
The modules database for processing module imports.
The empty sequence specifies the current modules database.
|
$root
(optional):
The root path for modules.
The empty sequence specifies the current root.
|
|
Example:
xdmp:eval-in("1+1",2348790529)
=> 2
|
Example:
xquery version "0.9-ml"
declare namespace my='http://mycompany.com/test'
let $s :=
"xquery version '0.9-ml'
declare namespace my='http://mycompany.com/test'
define variable $my:x as xs:string external
concat('hello ', $my:x)"
return
(: evaluate the query string $s using the variables
supplied as the second parameter to xdmp:eval :)
xdmp:eval-in($s,
xdmp:database("Documents"),
(xs:QName("my:x"),
"world"))
=> hello world
|
|
|
|
xdmp:external-binary(
|
|
$path as xs:string,
|
|
[$starting-location as xs:double],
|
|
[$length as xs:double]
|
| ) as binary() |
|
 |
Summary:
Returns an external binary node.
|
Parameters:
$path
:
Filesystem path to the external binary file.
|
$starting-location
(optional):
The new binary node starts at the byte position indicated by
starting-location. The first byte is at location 1.
The default value is 1.
|
$length
(optional):
The length in bytes of the content in the new binary node. Omitting
the length has performance implications; see usage notes.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-external-binary
|
Usage Notes:
If no length is provided, the length is calculated from the starting
position and the filesystem length of the external file. If the file
does not exist when the length is calculated, XDMP-MISSINGFILE
is thrown.
If a length is provided, the length is trusted. That is, no attempt is
made to confirm the existence or read the length of the external file.
Therefore, including the length in the call (if known) results in the
best performance during document creation.
|
Example:
xdmp:external-binary("/testdata1/logo.gif", 1, 2456))
=> A binary node representing the external file at
/testdata1/logo.gif, beginning at offset 1, with
a length of 2456 bytes.
|
|
|
|
xdmp:format-number(
|
|
$value as numeric,
|
|
[$picture as xs:string?],
|
|
[$language as xs:string?],
|
|
[$letter-value as xs:string?],
|
|
[$ordchar as xs:string?],
|
|
[$zero-padding as xs:string?],
|
|
[$grouping-separator as xs:string?],
|
|
[$grouping-size as xs:string?]
|
| ) as xs:string |
|
 |
Summary:
Returns a formatted number value based on the picture argument.
The difference between this function and the W3C standards
fn:format-number function is that this function imitates
the XSLT xsl:number instruction, which has richer
formatting options than the fn:format-number function.
This function can be used for spelled-out and ordinal numbering
in many languages. This function is
available in XSLT as well as in all dialects of XQuery.
|
Parameters:
$value
:
The given numeric $value that needs to be formatted. The
type of this argument must be a numeric type (for example, xs:integer,
xs:float, xs:double, or xs:decimal).
|
$picture
(optional):
The desired string representation of the given numeric $value.
The picture string is a sequence of characters, in which the
characters represent variables such as, decimal-separator-sign,
grouping-sign, zero-digit-sign, digit-sign, pattern-separator,
percent sign and per-mille-sign. For details on the picture string, see
http://www.w3.org/TR/xslt20/#date-picture-string.
Unlike fn:format-number(), here the picture string allows
spelled-out (uppercase, lowercase and Capitalcase) formatting.
|
$language
(optional):
The desired language for string representation of the numeric
$value.
An empty sequence must be passed in even if a user doesn't want to
specifiy this argument.
|
$letter-value
(optional):
Same as letter-value attribute in xsl:number. This argument is
ignored during formatting as of now. It may be used in future.
An empty sequence must be passed in even if a user doesn't want to
specifiy this argument.
|
$ordchar
(optional):
If $ordchar is "yes" then ordinal numbering is attempted. If this
is any other string, including an empty string, then then cardinal
numbering is generated.
An empty sequence must be passed in even if a user doesn't want to
specifiy this argument.
|
$zero-padding
(optional):
Value of $zero-padding is used to pad integer part of a number on
the left and fractional part on the right, if needed.
An empty sequence must be passed in even if a user doesn't want to
specifiy this argument.
|
$grouping-separator
(optional):
Value of $grouping-separator is a character, used to groups of digits,
especially useful in making long sequence of digits more readable.
For example, 10,000,000- here "," is used as a separator after
each group of three digits.
An empty sequence must be passed in even if a user doesn't want to
specify this argument.
|
$grouping-size
(optional):
Represents size of the group, i.e. the number of digits before after
which grouping separator is inserted.
An empty sequence must be passed in even if a user doesn't want to
specifiy this argument.
|
|
Usage Notes:
Most, but not all formatting combinations work. The following table
shows formatting options by language, and lists what is supported and
what is not.
| Language |
Numeric Cardinals |
Numeric Ordinals |
Spelled Out Cardinals |
Spelled Out Ordinals |
| en |
Yes |
Yes |
Yes |
Yes |
| fr |
Yes |
Yes |
Yes |
No |
| it |
Yes |
Yes |
Yes |
No |
| de |
Yes |
No |
Yes |
Yes |
| ru |
Yes |
No |
Yes |
No |
| es |
Yes |
Yes |
Yes |
No |
| ar |
Yes |
Yes |
Yes |
No |
| zh |
Yes |
Yes |
Yes |
Yes |
| ko |
Yes |
Yes |
Yes |
Yes |
| fa |
Yes |
No |
Yes |
No |
| nl |
Yes |
Yes |
Yes |
Yes |
| ja |
Yes |
Yes |
Yes |
Yes |
| pt |
Yes |
Yes |
Yes |
No |
|
Example:
xdmp:format-number(29,"01","en","",(),'0',",",3),
xdmp:format-number(09,"W","en","",(),'"',",",3),
xdmp:format-number((5),"w","es",(),(),"0",",",3)
=>
29
NINE
cinco
|
|
|
|
xdmp:from-json(
|
|
$arg as xs:string
|
| ) as item()* |
|
 |
Summary:
Parses a string as JSON, returning an item sequence.
|
Parameters:
$arg
:
JSON input to be parsed.
|
|
Usage Notes:
A JSON object or string is parsed as a json:object.
The JSON null value is represented as the empty sequence, and serializes
in a way that indicates it is a null value. Therefore, when the null value
is returned to JSON via xdmp:to-json, the null value is
preserved.
Nested arrays in JSON are turned into nested sets of
json:arrays.
Any codepoints in the JSON string that aren't allowed in XML are
rejected and an error is thrown.
|
Example:
xdmp:from-json('["a", null, false]')
=>
json:array(
<json:array xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:json="http://marklogic.com/xdmp/json">
<json:value xsi:type="xs:string">a</json:value>
<json:value xsi:nil="true"/>
<json:value xsi:type="xs:boolean">false</json:value>
</json:array>)
|
Example:
xquery version "1.0-ml";
let $json :=
'[{"some-key":45683}, "this is a string", 123]'
return
xdmp:from-json($json)
=>
json:array(
<json:array xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:json="http://marklogic.com/xdmp/json">
<json:value>
<json:object>
<json:entry key="some-key">
<json:value xsi:type="xs:integer">45683</json:value>
</json:entry>
</json:object>
</json:value>
<json:value xsi:type="xs:string">this is a string</json:value>
<json:value xsi:type="xs:integer">123</json:value></json:array>)
Note that what is shown above is the serialization of the XQuery items to
a json:array. You can also use some or all of the items in the XQuery data
model. For example, consider the following, which adds to the map based on the
other values:
xquery version "1.0-ml";
let $json :=
'[{"some-key":45683}, "this is a string", 123]'
let $items := xdmp:from-json($json)
let $put := map:put($items[1], xs:string($items[3]), $items[2])
return
($items[1], xdmp:to-json($items[1]))
(: returns the following json:array and JSON string:
json:object(
<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:json="http://marklogic.com/xdmp/json">
<entry key="some-key">
<json:value xsi:type="xs:integer">45683</json:value>
</entry>
<entry key="123">
<json:value xsi:type="xs:string">this is a string</json:value>
</entry>
</json:object>)
{"some-key":45683, "123":"this is a string"}
This query uses the map functions to modify the first json:object
in the json:array.
:)
|
|
|
|
xdmp:get(
|
|
$path as xs:string,
|
|
[$default-namespace as xs:string?],
|
|
[$options as xs:string*]
|
| ) as node()? |
|
 |
Summary:
[DEPRECATED: use xdmp:document-get
instead] Returns the document in the XML file specified by $path.
This function is deprecated and will be removed from a future release.
Use xdmp:document-get instead.
|
Parameters:
$path
:
The path to the input file. The path can be fully qualifed or relative.
Relative pathnames are resolved from the directory in which MarkLogic
Server is installed.
|
$default-namespace
(optional):
Default namespace for nodes in the first parameter. If $default-namespace is
specified and the root node of the loaded document does not explicitly
specify a namespace, $default-namespace will be applied to the root node.
The default value for $default-namespace is "".
|
$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.
- "lang=en"
- Specifies that the document is in english.
|
|
Usage Notes:
If no format is specified in $options, it is specified by the
document content type specified by the extension of the document URI.
The mimetype extensions and corresponding content types are set in the
Admin Interface.
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".
|
Example:
xdmp:get("foo.xml")
=> <foo/>
|
Example:
xdmp:get("foo.html", "", ("repair-full", "format-xml"))
=> foo.html as an XML document that has gone through any
needed tag repair
|
|
|
|
xdmp:http-get(
|
|
$uri as xs:string,
|
|
[$options as node()?]
|
| ) as item()+ |
|
 |
Summary:
Sends the http GET method to the specified URI. Returns the http response
as well as whatever information is identified by the specified URI
(for example, an html document).
|
Parameters:
$uri
:
The URI of the requested document.
|
$options
(optional):
The options node for this request. The default value is ().
The node for the xdmp:http-get options must be in the
xdmp:http namespace. This parameter can also include
certain option elements (for example, repair,
encoding, default-language) in the
xdmp:document-load and
xdmp:document-get
namespaces.
The xdmp:http-get options include:
<headers>
- A sequence of <name>value</name> pairs. The names can be
anything, but many HTTP servers understand HTTP names such as
content-type. These are turned into name:value HTTP
headers. An error is raised if the child elements of the
<headers> option are not of the form
<name>value</name>.
<authentication>
- The credentials and the authentication method to use for
this request. This option has child elements for the
username and password.
The username is the name of the user to be authenticated
on the http server. The password is that user's password.
You can optionally specify a method attribute on the
<authentication> element. If it is specified it must be either
'basic' or 'digest'. If a method is specified and the HTTP server
requests a different type of authentication, then an error is raised.
If the attribute is not specified, or matches the server's requested
method, the authentication proceeds.
<timeout>
- The amount of time, in seconds, to wait until the HTTP connection
times out. The default value is the
http timeout for the
group.
<ciphers>
- A standard cipher string. For details on legal ciper strings, see
http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS.
<client-cert>
- A PEM encoded client certificate for identifying the client to
the remote server.
<client-key>
- The private key that corresponds to
client-cert.
<pass-phrase>
- A pass phrase, if one is needed to decrypt client-key.
<method>
- The authentication method, which can be "basic", "digest", "aws", or
"aws4".
<username>
- A user name, if required for authentication.
<password>
- A password, if required for authentication.
<allow-sslv3>
- A boolean value to specify whether to communicate using the SSL v3 protocol.
The default is
true, which indicates communication using the
SSL v3 protocol.
<allow-tls>
- A boolean value to specify whether to communicate using the TLS protocol.
The default is
true, which indicates communication using the
TLS protocol.
<verify-cert>
- A boolean value to specify whether the server's certificate should be
verified. The default value is
true. A value of false
should only be specfied after careful consideration of the security risks since it
permits communication with servers whose certificates are expired, revoked,
or signed by unknown or untrusted authorities. A value of false
also removes protection against a man-in-the-middle attack.
<ssl-session-cache>
- A boolean value to specify whether ssl session should be cached and
reused. The default value is
true. A value of false
should only be specfied if ssl session cache causes problem with a url.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-http-get
|
Usage Notes:
The http functions only operate on URIs that use the http or https
schemes; specifying a URI that does not begin with http://
or https:// throws an exception.
If an http function times out, it throws a socket received
exception (SVC-SOCRECV).
An automatic encoding detector will be used if the value auto
is specified for the encoding option (in the
xdmp:document-get
namespace). If no option is specified, the encoding defaults to
the encoding specified
in the http header. If there is no encoding in the http header, the encoding
defaults to UTF-8.
The first node in the output of xdmp:http-get is the
response header from the http server.
The second node in the output of xdmp:http-get is the
response from the http server. The response is treated as
text, XML, or binary, depending on the content-type header sent from the
http server. If the node is html, the header should indicate
text/html, which is returned as a text document by default.
The type of document is determined by the mimetypes mappings, and
you can change the mappings in the Admin Interface as needed.
If you happen to know that the response is XML, even if the header
does not specify it as XML, and want to process the response as XML,
you can wrap the response in an xdmp:unquote call to
parse the response as XML. You could also use the
<format>xml</format> option (in the
xdmp:document-get namespace) to tell the API to treat the
document as XML. Also, if you know the response is an HTML document,
you can wrap the response in an xdmp:tidy call, which
will treat the text as HTML, clean it up, and return an XHTML XML
document.
|
Example:
xdmp:http-get("http://www.my.com/document.xhtml",
<options xmlns="xdmp:http">
<authentication method="basic">
<username>myname</username>
<password>mypassword</password>
</authentication>
</options>)
=> the response from the server as well as the specified document
|
Example:
xdmp:http-get("http://www.my.com/iso8859document.html",
<options xmlns="xdmp:document-get">
<encoding>iso-8859-1</encoding>
</options>)[2]
=> The specified document, transcoded from ISO-8859-1
to UTF-8 encoding. This assumes the document is
encoded in ISO-8859-1. Note that the encoding option
is in the "xdmp:document-get" namespace.
|
Example:
xdmp:unquote(
xdmp:http-get("http://www.my.com/somexml.xml")[2])
=> The specified xml document, parsed as XML by
xdmp:unquote. If the header specifies a
mimetype that is configured to be treated as
XML, the xdmp:unquote call is not needed.
Alternately, you can treat the response as XML
by specifying XML in the options node as
follows (note that the format option is in
the "xdmp:document-get" namespace:
xdmp:http-get("http://www.my.com/somexml.xml",
<options xmlns="xdmp:http-get">
<format xmlns="xdmp:document-get">xml</format>
</options>)[2]
|
Example:
xdmp:tidy(
xdmp:http-get("http://www.my.com/somehtml.html")[2])[2]
=> The specified html document, cleaned and transformed
to xhtml by xdmp:tidy. The second node of the tidy
output is the xhtml node (the first node is the status).
You could then perform XPath on the output to return
portions of the document. Note that the document (and
all of its elements) will be in the XHTML namespace, so
you need to specify the namespace in the XPath steps.
For example:
xquery version "1.0-ml";
declare namespace xh="http://www.w3.org/1999/xhtml";
xdmp:tidy(
xdmp:http-get("http://www.my.com/somehtml.html")[2])[2]//xh:title
|
|
|
|
xdmp:http-post(
|
|
$uri as xs:string,
|
|
[$options as node()?],
|
|
[$data as node()?]
|
| ) as item()+ |
|
 |
Summary:
Sends the http POST request to the server.
|
Parameters:
$uri
:
The URI to which the data is to be posted.
|
$options
(optional):
The options node for this request. The default value is ().
The node for the xdmp:http-post options must be in the
xdmp:http namespace.
The xdmp:http-post options include
the following option (in the xdmp:http namespace), in
addition to the options documented with the
xdmp:http-get $options
parameter:
<data>
- This node can contain any string. Anything in the
data
node is sent as a string in the PUT or POST body. When POSTing to a web
service, the data may need to be a SOAP XML structure or binary content.
The optional third argument can be used to specify non-text data.
The other options are the same as the other xdmp:http-*
functions, and the options are documented with the
xdmp:http-get $options
parameter.
|
$data
(optional):
The data for this request. This is an alternative to the
data option for the second parameter that allows binary
content to be specified.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-http-post
|
Usage Notes:
The http functions only operate on URIs that use the http or https
schemes; specifying a URI that does not begin with http://
or https:// throws an exception.
If an http function times out, it throws a socket received
exception (SVC-SOCRECV).
If you expect the request body from this http function to be
processed by another application (via a web service, for example),
you should specify a content-type header. If no content-type header is
specified, the content type defaults to text/plain.
|
Example:
xdmp:http-post("http://www.my.com/document.xhtml",
<options xmlns="xdmp:http">
<authentication method="basic">
<username>myname</username>
<password>mypassword</password>
</authentication>
</options>)
=> the response from the server as well as the specified document
|
Example:
(: Use xdmp:quote to encode the XML as a string
because the <data> options element is a string :)
let $payload := xdmp:quote(
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:my='urn:MyConnection'>
<SOAP-ENV:Body>
<my:LogOn>
<my:User>user</my:User>
<my:Password>pass</my:Password>
<my:Ticket>abc123</my:Ticket>
<my:newData>1234</my:newData>
</my:LogOn>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
)
return
xdmp:http-post("http://www.my.com/document.xhtml",
<options xmlns="xdmp:http">
<authentication method="basic">
<username>myname</username>
<password>mypassword</password>
</authentication>
<data>{$payload}</data>
<headers>
<content-type>text/xml</content-type>
</headers>
</options>)
=> the response from the server as well as the specified document
|
|
|
|
xdmp:http-put(
|
|
$uri as xs:string,
|
|
[$options as node()?],
|
|
[$data as node()?]
|
| ) as item()+ |
|
 |
Summary:
Sends an HTTP PUT request to an HTTP server.
The HTTP server should return a response, which will differ depending on
the action the HTTP server takes for the PUT.
|
Parameters:
$uri
:
The URI to which the data is to be put.
|
$options
(optional):
The options node for this request. The default value is ().
The node for the xdmp:http-put options must be in the
xdmp:http namespace.
The options include
the following option (in the xdmp:http namespace), in
addition to the options documented with the
xdmp:http-get $options
parameter:
<data>
- This node can contain any string. Anything in the
data
node is sent as a string in the PUT or POST body. If binary content is to
be sent, it can be specified as the optional third argument instead.
The other options are the same as the other xdmp:http-*
functions, and the options are documented with the
xdmp:http-get $options
parameter.
|
$data
(optional):
The data for this request. This is an alternative to the
data option for the second parameter that allows binary
content to be specified.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-http-put
|
Usage Notes:
The http functions only operate on URIs that use the http or https
schemes; specifying a URI that does not begin with http://
or https:// throws an exception.
If an http function times out, it throws a socket received
exception (SVC-SOCRECV).
If you expect the request body from this http function to be
processed by another application (via a web service, for example),
you should specify a content-type header. If no content-type header is
specified, the content type defaults to text/plain.
|
Example:
xdmp:http-put("http://www.my.com/document.xhtml",
<options xmlns="xdmp:http">
<authentication method="basic">
<username>myname</username>
<password>mypassword</password>
</authentication>
</options>)
=> the response from the HTTP server as well as the specified document
|
|
|
|
xdmp:invoke(
|
|
$path as xs:string,
|
|
[$vars as item()*],
|
|
[$options as node()?]
|
| ) as item()* |
|
 |
Summary:
Returns the result of evaluating a module at the given path.
|
Parameters:
$path
:
The path of the module to
be executed as a string. The path is resolved against
the root of the App Server evaluating the query, the Modules directory,
or relative to the calling module. For details on resolving paths,
see "Importing XQuery Modules and Resolving Paths" in the
Application Developer's Guide.
|
$vars
(optional):
The external variable values for this evaluation.
This can either be a sequence of map:map objects, or a sequence of even
length, alternating QNames and items.
Each key in the map(s) is a string representing the name of the parameter
in Clark notation: "{namespaceURI}localname". The function
xdmp:key-from-QName
is a convenient way to generate these keys.
Each entry in the map is the value of the corresponding external variable.
Alternatively, the alternating sequence should contain QName and item
pairs that specify a variable name and value for an external variable.
|
$options
(optional):
The options node. The default value is (). The node must be in the
xdmp:eval namespace. See the
xdmp:eval section for a list of options.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-invoke
|
Example:
xdmp:invoke("http://example.com/modules/foo.xqy")
=> 2
|
Example:
This example invokes a module using external variables.
Assume you have a module in the modules database with a URI
"http://example.com/application/module.xqy" containing the
following code:
xquery version "1.0-ml";
declare namespace my="my-namespace-uri";
declare variable $my:var as xs:string external;
xdmp:log($my:var)
Then you can call this module using xdmp:invoke as follows:
xquery version "1.0-ml";
declare namespace my="my-namespace-uri";
xdmp:invoke("module.xqy",
(xs:QName("my:var"), "log this to ErrorLog.txt"),
<options xmlns="xdmp:eval">
<modules>{xdmp:modules-database()}</modules>
<root>http://example.com/application/</root>
</options>)
=> Invokes an XQuery module from the modules database
with the URI http://example.com/application/module.xqy.
The invoked module will then be executed, logging the
message sent in the external variable to the log file.
|
|
|
|
xdmp:invoke-in(
|
|
$uri as xs:string,
|
|
$ID as xs:unsignedLong,
|
|
[$vars as item()*],
|
|
[$modules as xs:unsignedLong?],
|
|
[$root as xs:string?]
|
| ) as item()* |
|
 |
Summary:
[DEPRECATED: use xdmp:invoke with the
database option instead] Returns the result of evaluating a module
at the given path.
|
Parameters:
$uri
:
The path of the module to be executed. The path is resolved against
the root of the App Server evaluating the query. The path must
resolve to a main module (not a library module).
|
$ID
:
The database ID, from xdmp:database("db_name"),
xdmp:security-database(),
or xdmp:schema-database().
|
$vars
(optional):
The external variable values for this evaluation.
This must be a sequence of even length, alternating QNames and items.
Each QName and item pair specify a variable name and value.
|
$modules
(optional):
The modules database containing the module to invoke.
The empty sequence specifies the current modules database.
|
$root
(optional):
The root path for modules.
The empty sequence specifies the current root.
|
|
Example:
xdmp:invoke-in("http://example.com/modules/foo.xqy",2348790529)
=> 2
|
|
|
|
xdmp:ldap-lookup(
|
|
$DN as xs:string,
|
|
[$options as node()?]
|
| ) as element()* |
|
 |
Summary:
Returns an ldap entry.
|
Parameters:
$DN
:
The DN of the entry to be returned.
|
$options
(optional):
The options for ldap lookup.
The default value is ().
Options include:
- "username"
- ldap username.
- "password"
- ldap password.
- "server-uri"
- ldap server uri.
- "use-appserver-config"
- Use appserver config as default. Specify true or false. The default
is false.
|
|
Example:
xdmp:ldap-lookup(
"CN=Jane Doe,CN=Users,DC=MLTEST1,DC=LOCAL",
<options xmlns="xdmp:ldap">
<username>admin</username>
<password>admin</password>
<server-uri>ldap://dc1.mltest1.local:389</server-uri>
</options>)
=>
<ldap-object xmlns="http://marklogic.com/xdmp/ldap/object">
<ldap-attribute id="DN">CN=Jane Doe,CN=Users,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="objectClass">top</ldap-attribute>
<ldap-attribute id="objectClass">person</ldap-attribute>
<ldap-attribute id="objectClass">organizationalPerson</ldap-attribute>
<ldap-attribute id="objectClass">user</ldap-attribute>
<ldap-attribute id="cn">Jane Doe</ldap-attribute>
<ldap-attribute id="sn">Tsoi</ldap-attribute>
<ldap-attribute id="givenName">Jane</ldap-attribute>
<ldap-attribute id="distinguishedName">CN=Jane Doe,CN=Users,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="instanceType">4</ldap-attribute>
<ldap-attribute id="whenCreated">20120418134913.0Z</ldap-attribute>
<ldap-attribute id="whenChanged">20130423001215.0Z</ldap-attribute>
<ldap-attribute id="displayName">Jane Doe</ldap-attribute>
<ldap-attribute id="uSNCreated">21173</ldap-attribute>
<ldap-attribute id="memberOf">CN=TestGroup Admin,CN=Users,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="memberOf">CN=Domain Admins,CN=Users,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="memberOf">CN=Remote Desktop Users,CN=Builtin,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="uSNChanged">82727</ldap-attribute>
<ldap-attribute id="name">Jane Doe</ldap-attribute>
<ldap-attribute id="userAccountControl">66048</ldap-attribute>
<ldap-attribute id="badPwdCount">0</ldap-attribute>
<ldap-attribute id="codePage">0</ldap-attribute>
<ldap-attribute id="countryCode">0</ldap-attribute>
<ldap-attribute id="badPasswordTime">130112986222890625</ldap-attribute>
<ldap-attribute id="lastLogoff">0</ldap-attribute>
<ldap-attribute id="lastLogon">130117512192890625</ldap-attribute>
<ldap-attribute id="pwdLastSet">129792305530986328</ldap-attribute>
<ldap-attribute id="primaryGroupID">513</ldap-attribute>
<ldap-attribute id="adminCount">1</ldap-attribute>
<ldap-attribute id="accountExpires">9223372036854775807</ldap-attribute>
<ldap-attribute id="logonCount">205</ldap-attribute>
<ldap-attribute id="sAMAccountName">jdoe</ldap-attribute>
<ldap-attribute id="sAMAccountType">805306368</ldap-attribute>
<ldap-attribute id="userPrincipalName">jdoe@MLTEST1.LOCAL</ldap-attribute>
<ldap-attribute id="objectCategory">CN=Person,CN=Schema,CN=Configuration,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="dSCorePropagationData">20120530014553.0Z</ldap-attribute>
<ldap-attribute id="dSCorePropagationData">16010101000000.0Z</ldap-attribute>
<ldap-attribute id="lastLogonTimestamp">130111495353203125</ldap-attribute>
</ldap-object>
|
|
|
|
xdmp:ldap-search(
|
|
$query as xs:string,
|
|
[$options as node()?]
|
| ) as element()* |
|
 |
Summary:
Returns ldap search result.
|
Parameters:
$query
:
The query is a string representation of the filter to apply in the search. The string should
conform to the format specified in RFC 4515 as extended by RFC 4526. For instance, "(cn=Jane
Doe)".
|
$options
(optional):
The options for ldap search.
The default value is ().
Options include:
- "username"
- ldap username.
- "password"
- ldap password.
- "server-uri"
- ldap server uri.
- "search-base"
- search-base is the DN of the entry at which to start the search.
- "use-appserver-config"
- Use appserver config as default. Specify true or false. The default
is false.
|
|
Example:
xdmp:ldap-search(
"(cn=Jane Doe)",
<options xmlns="xdmp:ldap">
<username>admin</username>
<password>admin</password>
<server-uri>ldap://dc1.mltest1.local:389</server-uri>
<search-base>CN=Users,DC=MLTEST1,DC=LOCAL</search-base>
</options>)
=>
<ldap-object xmlns="http://marklogic.com/xdmp/ldap/object">
<ldap-attribute id="DN">CN=Jane Doe,CN=Users,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="objectClass">top</ldap-attribute>
<ldap-attribute id="objectClass">person</ldap-attribute>
<ldap-attribute id="objectClass">organizationalPerson</ldap-attribute>
<ldap-attribute id="objectClass">user</ldap-attribute>
<ldap-attribute id="cn">Jane Doe</ldap-attribute>
<ldap-attribute id="sn">Tsoi</ldap-attribute>
<ldap-attribute id="givenName">Jane</ldap-attribute>
<ldap-attribute id="distinguishedName">CN=Jane Doe,CN=Users,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="instanceType">4</ldap-attribute>
<ldap-attribute id="whenCreated">20120418134913.0Z</ldap-attribute>
<ldap-attribute id="whenChanged">20130423001215.0Z</ldap-attribute>
<ldap-attribute id="displayName">Jane Doe</ldap-attribute>
<ldap-attribute id="uSNCreated">21173</ldap-attribute>
<ldap-attribute id="memberOf">CN=TestGroup Admin,CN=Users,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="memberOf">CN=Domain Admins,CN=Users,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="memberOf">CN=Remote Desktop Users,CN=Builtin,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="uSNChanged">82727</ldap-attribute>
<ldap-attribute id="name">Jane Doe</ldap-attribute>
<ldap-attribute id="userAccountControl">66048</ldap-attribute>
<ldap-attribute id="badPwdCount">0</ldap-attribute>
<ldap-attribute id="codePage">0</ldap-attribute>
<ldap-attribute id="countryCode">0</ldap-attribute>
<ldap-attribute id="badPasswordTime">130112986222890625</ldap-attribute>
<ldap-attribute id="lastLogoff">0</ldap-attribute>
<ldap-attribute id="lastLogon">130117512192890625</ldap-attribute>
<ldap-attribute id="pwdLastSet">129792305530986328</ldap-attribute>
<ldap-attribute id="primaryGroupID">513</ldap-attribute>
<ldap-attribute id="adminCount">1</ldap-attribute>
<ldap-attribute id="accountExpires">9223372036854775807</ldap-attribute>
<ldap-attribute id="logonCount">205</ldap-attribute>
<ldap-attribute id="sAMAccountName">jdoe</ldap-attribute>
<ldap-attribute id="sAMAccountType">805306368</ldap-attribute>
<ldap-attribute id="userPrincipalName">jdoe@MLTEST1.LOCAL</ldap-attribute>
<ldap-attribute id="objectCategory">CN=Person,CN=Schema,CN=Configuration,DC=MLTEST1,DC=LOCAL</ldap-attribute>
<ldap-attribute id="dSCorePropagationData">20120530014553.0Z</ldap-attribute>
<ldap-attribute id="dSCorePropagationData">16010101000000.0Z</ldap-attribute>
<ldap-attribute id="lastLogonTimestamp">130111495353203125</ldap-attribute>
</ldap-object>
|
|
|
|
xdmp:log(
|
|
$msg as item()*,
|
|
[$level as xs:string?]
|
| ) as empty-sequence() |
|
 |
Summary:
Logs a debug message to the log file
<install_dir>/Logs/ErrorLog.txt.
|
Parameters:
$msg
:
Message for logging.
|
$level
(optional):
One of: emergency, alert, critical, error, warning, notice, info,
config, debug, fine, finer, or finest. The default level is "info".
|
|
Example:
|
|
|
|
xdmp:multipart-decode(
|
|
$separator as xs:string,
|
|
$data as binary(),
|
|
$options as element()?
|
| ) as node()* |
|
 |
Summary:
Extract the parts from a multipart encoding. The first item in the
sequence is a manifest, and the remaining items are the decoded parts.
An attempt will be made to determine the type of content based on
headers such as the part's content-type. If possible, an element will be
returned, falling back to an xs:string, and finally binary().
The options control how the parts are unpacked, and are similar to
xdmp:zip-get - default-namespace, repair,
format, default-language,
and encoding. The options apply to all parts, so specifying a format of
binary will cause all parts to be returned as binary, and specifying text
will cause all parts to be returned as xs:string if possible, falling back
to binary() if necessary. This is useful if different parts need different
options, in which case the resulting strings can each be passed to
xdmp:unquote() with appropriate options.
|
Parameters:
$separator
:
The string that is to be used as a separator.
|
$data
:
The data to be decoded.
|
$options
:
Decode options.
|
|
Example:
xquery version "1.0-ml";
let $html:= document{ <html><p>Some stuff in an .html document</p></html> }
let $xml:= document{ <root><a>Some other stuff in a .xml document</a></root> }
let $text :=text{xdmp:to-json(("a",fn:false()))}
let $boundary-string:="gc0p4Jq0M2Yt08jU534c0p"
let $mpe := xdmp:multipart-encode(
$boundary-string,
<manifest>
<part>
<headers>
<Content-Type>xml</Content-Type>
<boundary>gc0p4Jq0M2Yt08jU534c0p</boundary>
</headers>
</part>
<part>
<headers>
<Content-Type>html</Content-Type>
</headers>
</part>
<part/>
</manifest>,
($xml,$html,$text) )
return xdmp:multipart-decode($boundary-string, $mpe)
=>
<manifest>
<part>
<headers>
<Content-Type>xml</Content-Type>
<boundary>gc0p4Jq0M2Yt08jU534c0p</boundary>
<Content-Length>94</Content-Length>
</headers>
</part>
<part>
<headers>
<Content-Type>html</Content-Type>
<Content-Length>90</Content-Length>
</headers>
</part>
<part>
<headers>
<Content-Type>text/plain</Content-Type>
<Content-Length>12</Content-Length>
</headers>
</part>
<part/>
</manifest>
<?xml version="1.0" encoding="UTF-8"?>
<root><a>Some other stuff in a .xml document</a></root>
<?xml version="1.0" encoding="UTF-8"?>
<html><p>Some stuff in an .html document</p></html>
["a", false]
|
|
|
|
xdmp:multipart-encode(
|
|
$separator as xs:string,
|
|
$manifest as element(),
|
|
$content as node*
|
| ) as binary() |
|
 |
Summary:
Create a multipart encoding of the specified node. The returned binary
node can be passed to xdmp:http-post.
The manifest is modeled after the
manifest that is passed to xdmp:zip-create,
with the headers element being
the same as is described for xdmp:http-get
allowing users to add arbitrary
headers to each part. If a content-type header is not specified for a part,
it will be determined if possible from the content.
There should be one part element for each node in the content sequence.
Each part also has an optional options node to control how xml or text
will be serialized. The two options are the same as for
xdmp:save.
<parts>
<part>
<headers>
<Content-Type>image/jpeg</Content-Type>
<headers>
<options>
<output-encoding>...</output-encoding>
<output-sgml-character-entities>...</output-sgml-character-entities>
</options>
</part>
</parts>
|
Parameters:
$separator
:
The string that is to be used as a separator.
|
$manifest
:
The manifest.
|
$content
:
The nodes that are to be encoded.
|
|
Example:
xquery version "1.0-ml";
let $html:= document{ <html><p>Some stuff in an .html document</p></html> }
let $xml:= document{ <root><a>Some other stuff in a .xml document</a></root> }
let $text :=text{xdmp:to-json(("a",fn:false()))}
let $boundary-string:="gc0p4Jq0M2Yt08jU534c0p"
return
xdmp:multipart-encode(
$boundary-string,
<manifest>
<part>
<headers>
<Content-Type>xml</Content-Type>
<boundary>gc0p4Jq0M2Yt08jU534c0p</boundary>
</headers>
</part>
<part>
<headers>
<Content-Type>html</Content-Type>
</headers>
</part>
<part/>
</manifest>,
($xml,$html,$text) )
=>
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: xml
boundary: gc0p4Jq0M2Yt08jU534c0p
Content-Length: 94
<?xml version="1.0" encoding="UTF-8"?>
<root><a>Some other stuff in a .xml document</a></root>
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: html
Content-Length: 90
<?xml version="1.0" encoding="UTF-8"?>
<html><p>Some stuff in an .html document</p></html>
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: text/plain
Content-Length: 12
["a", false]
--gc0p4Jq0M2Yt08jU534c0p--
|
|
|
|
xdmp:parse-dateTime(
|
|
$picture as xs:string,
|
|
$value as xs:string,
|
|
[$language as xs:string?],
|
|
[$calendar as xs:string?],
|
|
[$country as xs:string]
|
| ) as xs:dateTime |
|
 |
Summary:
Parses a string containing date, time or dateTime using the supplied
picture argument and returns a dateTime value. While this function
is closely related to other XSLT functions, it is available in XSLT
as well as in all XQuery dialects.
|
Parameters:
$picture
:
The desired string representation of the given $value.
The picture string is a sequence of characters, in which the
characters represent variables such as, decimal-separator-sign,
grouping-sign, zero-digit-sign, digit-sign, pattern-separator,
percent sign and per-mille-sign. For details on the picture string, see
http://www.w3.org/TR/xslt20/#date-picture-string.
This follows the specification of
picture string in the W3C XSLT 2.0
specification for the fn:format-dateTime function.
Symbol Description
-----------------------------------
'Y' year(absolute value)
'M' month in year
'D' day in month
'd' day in year
'F' day of week
'W' week in year
'w' week in month
'H' hour in day
'h' hour in half-day
'P' am/pm marker
'm' minute in hour
's' second in minute
'f' fractional seconds
'Z' timezone as a time offset from UTC
for example PST
'z' timezone as an offset using GMT,
for example GMT+1
|
$value
:
The given string $value representing the dateTime value
that needs to be formatted.
|
$language
(optional):
The language used in string representation of the date, time or
dateTime value.
|
$calendar
(optional):
This argument is reserved for future use. The only calendar supported
at this point is "Gregorian" or "AD".
|
$country
(optional):
$country is used to take into account if there any country specific
interpretation of the string while converting it into dateTime value.
|
|
Usage Notes:
Dates before October 15, 1582 (the start of the Gregorian calendar) will
not return the correct dateTime value.
The xdmp:parse-dateTime function will not parse all dates;
if it does not parse a date, it can throw the
XDMP-PATTERNVALUEMISMATCH exception. To help normalize
the dates so they can be parsed, you can try using the XSLT functions
defined in the following stylesheet:
<marklogic-dir>/Modules/MarkLogic/appservices/utils/normalize-dates.xsl
In particular xdmp:parse-dateTime does not support parsing names of days or months.
|
Example:
xdmp:parse-dateTime("[Y0001]-[M01]-[D01]T[h01]:[m01]:[s01].[f1][Z]","2010-01-06T17:13:50.873594-08:00")
|
|
|
|
xdmp:parse-yymmdd(
|
|
$picture as xs:string,
|
|
$value as xs:string,
|
|
[$language as xs:string?],
|
|
[$calendar as xs:string?],
|
|
[$country as xs:string?]
|
| ) as xs:dateTime |
|
 |
Summary:
Parses a string containing date, time or dateTime using the supplied
picture argument and returns a dateTime value. While this function
is closely related to other XSLT functions, it is available in XSLT
as well as in all XQuery dialects.
|
Parameters:
$picture
:
The desired string representation of the given $value.
This follows the specification of picture string which is
compatible to the format specification in icu. See
http://icu-project.org/apiref/icu4j/com/ibm/icu/text/SimpleDateFormat.html
for more details.
The following is the summary of the formatting symbols:
Symbol Description
----------------------------
"y" year(absolute value)
"M" month in year
"d" day in month
"D" day in year
"E" day of week
"w" week in year
"W" week in month
"H" hour in day
"K" hour in half-day
"a" am/pm marker
"s" second in minute
"S" fractional seconds
"Z" timezone as a time offset from UTC
for example PST
"ZZZZ" timezone as an offset using GMT,
for example GMT+1
|
$value
:
The given string $value that needs to be formatted.
|
$language
(optional):
The language used in string representation of the date, time or
dateTime value.
|
$calendar
(optional):
This argument is reserved for future use. The only calendar supported
at this point is "Gregorian" or "AD".
|
$country
(optional):
$country is used to take into account if there any country specific
interpretation of the string while converting it into dateTime value.
|
|
Usage Notes:
Dates before October 15, 1582 (the start of the Gregorian calendar) will
not return the correct dateTime value.
|
Example:
xdmp:parse-yymmdd("yyyy-MM-ddThh:mm:ss.Sz","2010-01-06T17:13:50.873594-8.00")
|
|
|
|
xdmp:plan(
|
|
$expression as item()*,
|
|
[$maximum as xs:double?]
|
| ) as element() |
|
 |
Summary:
Returns an XML element recording information about how the given
expression will be processed by the index. The information is a
structured representation of the information provided in the error log
when query trace is enabled. The query will be processed up to the
point of getting an estimate of the number of fragments returned by the
index.
|
Parameters:
$expression
:
The expression to estimate.
This must be a partially searchable XPath expression
or a cts:search() expression.
|
$maximum
(optional):
The maximum value to return.
Stop selecting fragments if this number is reached.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-plan
|
Usage Notes:
The output from xdmp:plan will vary depending on various index
settings.
Running an xdmp:plan on a search is similar to running an
xdmp:estimate on a search, but it returns a report on the
search instead of just an estimate. As part of the report, the
qry:result element includes the estimate.
If the search expression argument cannot be run in the
plan because it is not partially searchable, then an
XDMP-UNSEARCHABLE exception is returned as part of the
xdmp:plan output.
If you are running a search using the search API
(for example, search:search), use the
option <return-plan>true</return-plan> in your
search API options node.
|
Example:
xquery version "1.0-ml";
xdmp:plan(cts:search(fn:doc(),cts:word-query("cat")))
=>
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:info-trace>xdmp:eval("xquery version &quot;1.0-ml&quot;;&
#10;&#10;xdmp:plan(cts:search...", (), <options
xmlns="xdmp:eval"><database>8855151527276563827</database>
<isolation>different-tra...</options>)
</qry:info-trace>
<qry:info-trace>Analyzing path for search: fn:doc()</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:doc()</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:word-trace text="cat">
<qry:key>12545744176132597186</qry:key>
</qry:word-trace>
<qry:info-trace>Search query contributed 1 constraint:
cts:word-query("cat", ("lang=en"), 1)
</qry:info-trace>
<qry:partial-plan>
<qry:term-query weight="1">
<qry:key>12545744176132597186</qry:key>
<qry:annotation>word("cat")</qry:annotation>
</qry:term-query>
</qry:partial-plan>
<qry:info-trace>Executing search.</qry:info-trace>
<qry:final-plan>
<qry:and-query>
<qry:term-query weight="1">
<qry:key>12545744176132597186</qry:key>
<qry:annotation>word("cat")</qry:annotation>
</qry:term-query>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 1 fragment to filter</qry:info-trace>
<qry:result estimate="1"/>
</qry:query-plan>
|
Example:
xquery version "1.0-ml" ;
xdmp:plan(
cts:search(/document,
cts:word-query("cut?",
("unstemmed", "wildcarded") ) ) )
(:
The <qry:expansion-trace> element indicates that a
lexicon expansion occurred on the wildcarded query
(word searches, three character searches and
a codepoint lexicon are enabled in the database
configuration for wildcard queries). The
<qry:expansion> element shows what term(s) the
lexicon expansion found. In this case, "cut?"
expands to "cute".
:)
=>
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:info-trace>Analyzing path for search: fn:collection()/document
</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace>
<qry:info-trace>Step 2 is searchable: document</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:expansion-trace type="full" elapsed-time="PT0.000381S" text="cut?"
counts="1">
<qry:interval lowerbound="CUT" upperbound="C??"/>
<qry:interval lowerbound="cUT" upperbound="c??"/>
<qry:interval lowerbound="}UT" upperbound="???"/>
<qry:expansion text="cute"/>
</qry:expansion-trace>
<qry:word-trace text="cute">
<qry:key>16588943567160478160</qry:key>
</qry:word-trace>
<qry:info-trace>Search query contributed 1 constraint:
cts:word-query("cut?", ("unstemmed","wildcarded","lang=en"), 1)
</qry:info-trace>
<qry:partial-plan>
<qry:term-query weight="1">
<qry:key>16588943567160478160</qry:key>
<qry:annotation>word("cute")</qry:annotation>
</qry:term-query>
</qry:partial-plan>
<qry:info-trace>Executing search.</qry:info-trace>
<qry:final-plan>
<qry:and-query>
<qry:or-two-queries>
<qry:term-query weight="0">
<qry:key>3998944933214536873</qry:key>
<qry:annotation>doc-root(element(document),doc-kind(document))
</qry:annotation>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>13616698357625443361</qry:key>
<qry:annotation>link-child(descendant(doc-root(element(document),
doc-kind(document)) ))
</qry:annotation>
</qry:term-query>
</qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>16588943567160478160</qry:key>
<qry:annotation>word("cute")</qry:annotation>
</qry:term-query>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 1 fragment to filter</qry:info-trace>
<qry:result estimate="1"/>
</qry:query-plan>
|
|
|
|
xdmp:QName-from-key(
|
|
$key as xs:string
|
| ) as xs:QName |
|
 |
Summary:
Construct a QName from a string of the form "{namespaceURI}localname".
This function is useful for constructing Clark notation
parameters for the xdmp:xslt-eval
and xdmp:xslt-invoke
functions.
|
Parameters:
$key
:
The string from which to construct a QName.
|
|
Example:
xquery version "1.0-ml";
(: returns the Clark notation form of the QName :)
xdmp:key-from-QName(xs:QName("fn:foo"))
=>
{http://www.w3.org/2005/xpath-functions}foo
|
|
|
|
xdmp:query-meters( ) as element()
|
|
 |
Summary:
Returns the current value of the resource meters for this
query sequence.
|
Usage Notes:
The resource meters returned include:
- elapsed-time
- The time elapsed since the start of the processing of this query,
in the form of a duration.
- requests
- The number of requests.
- list-cache-hits
- The number of successful list cache lookups. The list
cache holds search termlists used to accelerate path expressions and
text searches.
- list-cache-misses
- The number of unsuccessful list cache lookups. Each
unsuccessful list cache lookup was followed by a disk access to load the
search termlist into the cache.
- in-memory-list-hits
- The number of successful list lookups in in-memory
stands.
- expanded-tree-cache-hits
- The number of successful expanded tree cache lookups.
The expanded tree cache cache holds XML document data in the expanded
representation used by the XQuery evaluator.
- expanded-tree-cache-misses
- The number of unsuccessful expanded tree cache lookups.
Each unsuccessful expanded tree lookup was followed by a compressed tree
cache lookup to load the expanded tree into the cache.
- compressed-tree-cache-hits
- The number of successful compressed tree cache lookups.
The compressed tree cache holds XML document data in the compressed
representation stored on disk.
- compressed-tree-cache-misses
- The number of unsuccessful compressed tree cache lookups.
Each unsuccessful compressed tree cache lookup was followed by a disk
access to load the compressed tree into the cache.
- in-memory-compressed-tree-hits
- The number of successful compressed tree lookups in
in-memory stands.
- value-cache-hits
- The number of successful value cache lookups. The value
cache is a transient cache that exists only for the duration of one
query. It holds typed values, and is used to accelerate the frequent
conversion of nodes to typed values.
- value-cache-misses
- The number of unsuccessful value cache lookups. Each
unsuccessful value cache lookup was followed by a conversion of an XML
node to a typed value.
- regexp-cache-hits
- The number of successful regular expression cache
lookups. The regular expression cache is a transient cache that exists
only for the duration of one query. It holds compiled regular
expressions, and is used to accelerate the frequent use of regular
expressions during the evaluation of a query.
- regexp-cache-misses
- The number of unsuccessful regular expression cache
lookups. Each unsuccessful regular expression cache lookup was followed
by a compilation of a regular expression from source text.
- link-cache-hits
- The number of successful link cache lookups. The link
cache is a transient cache that exists only for the duration of one
query. It holds pointers to expanded trees, and is used to accelerate
the frequent dereferencing of link nodes.
- link-cache-misses
- The number of unsuccessful link cache lookups. Each
unsuccessful link cache lookup was followed by a search for the
link target tree.
- filter-hits
- The number of successful search filter matches.
- filter-misses
- The number of unsuccessful search filter matches.
- fragments-added
- The number of XML fragments added to the database by an
update.
- fragments-deleted
- The number of XML fragments deleted from the database by
an update.
- fs-program-cache-hits
- The number of module cache hits from the entire program made from
modules on the file system.
- fs-program-cache-misses
- The number of module cache misses from the entire program made from
modules on the file system.
- db-program-cache-hits
- The number of module cache hits from the entire program made from
modules in a database (may contain library modules from the special
Modules directory).
- db-program-cache-misses
- The number of module cache misses from the entire program made from
modules in a database (may contain library modules from the special
Modules directory).
- env-program-cache-hits
- The number of module cache hits from the entire program made from
ad hoc XSLT stylesheet nodes.
- env-program-cache-misses
- The number of module cache misses from the entire program made from
ad hoc XSLT stylesheet nodes.
- fs-main-module-sequence-cache-hits
- The number of main module cache hits from main modules on the
file system.
- fs-main-module-sequence-cache-misses
- The number of main module cache misses from main modules on the
file system.
- db-main-module-sequence-cache-hits
- The number of main module cache hits from main modules in a
database.
- db-main-module-sequence-cache-misses
- The number of main module cache misses from main modules in a
database.
- fs-library-module-cache-hits
- The number of library module cache hits from library modules on the
file system.
- fs-library-module-cache-misses
- The number of library module cache misses from library modules on the
file system.
- db-library-module-cache-hits
- The number of library module cache hits from library modules from the
modules database.
- db-library-module-cache-misses
- The number of library module cache misses from library modules from the
modules database.
Some meters are broken down by fragment root and document URI:
- fragments
- A sequence of fragment elements, each containing:
- root
- The fragment root name.
- expanded-tree-cache-hits
- A count of successful expanded tree cache lookups for this fragment
root.
- expanded-tree-cache-misses
- A count of unsuccessful expanded tree cache lookups for this
fragment root.
- documents
- A sequence of document elements, each containing:
- uri
- The document URI.
- expanded-tree-cache-hits
- A count of successful expanded tree cache lookups
for this document URI.
- expanded-tree-cache-misses
- A count of unsuccessful expanded tree cache lookups
for this document URI.
There are also meters that measure the query activity per host. There is
a qm:hosts element with one qm:host child per
host that participates in the query. Each qm:host element
contains meters showing the round-trip-time and round-trip-count for
communications between the evaluator host and the host referenced in the
xdmp:query-meters output. The qm:hosts element is
empty for a single-node cluster.
Certain operations are run concurrently with the timing operations,
and if those operations are not actually used in the query, they might not
be included in the timings. This occurs for operations like
xdmp:estimate, xdmp:exists, and lexicon calls
(for example, cts:element-values). If you want to see the
total timings that include calls that are not used, you can form some other
expression with the results of the calls. For example, if you have an
expression that calls xdmp:estimate in a let
expression, you can add 0 to the output, which causes it to be included in
the timings (something like xdmp:estimate($query) + 0).
|
Example:
xdmp:query-meters();
=>
<qm:query-meters
xsi:schemaLocation="http://marklogic.com/xdmp/query-meters
query-meters.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:qm="http://marklogic.com/xdmp/query-meters">
<qm:elapsed-time>PT0.22S</qm:elapsed-time>
<qm:requests>1</qm:requests>
<qm:list-cache-hits>0</qm:list-cache-hits>
<qm:list-cache-misses>0</qm:list-cache-misses>
<qm:in-memory-list-hits>0</qm:in-memory-list-hits>
<qm:expanded-tree-cache-hits>0
</qm:expanded-tree-cache-hits>
<qm:expanded-tree-cache-misses>0
</qm:expanded-tree-cache-misses>
<qm:compressed-tree-cache-hits>0
</qm:compressed-tree-cache-hits>
<qm:compressed-tree-cache-misses>0
</qm:compressed-tree-cache-misses>
<qm:in-memory-compressed-tree-hits>0
</qm:in-memory-compressed-tree-hits>
<qm:value-cache-hits>0</qm:value-cache-hits>
<qm:value-cache-misses>0</qm:value-cache-misses>
<qm:regexp-cache-hits>0</qm:regexp-cache-hits>
<qm:regexp-cache-misses>0</qm:regexp-cache-misses>
<qm:link-cache-hits>0</qm:link-cache-hits>
<qm:link-cache-misses>0</qm:link-cache-misses>
<qm:fragments-added>0</qm:fragments-added>
<qm:fragments-deleted>0</qm:fragments-deleted>
<qm:fs-program-cache-hits>1</qm:fs-program-cache-hits>
<qm:fs-program-cache-misses>0</qm:fs-program-cache-misses>
<qm:db-program-cache-hits>0</qm:db-program-cache-hits>
<qm:db-program-cache-misses>0</qm:db-program-cache-misses>
<qm:env-program-cache-hits>0</qm:env-program-cache-hits>
<qm:env-program-cache-misses>0</qm:env-program-cache-misses>
<qm:fs-main-module-sequence-cache-hits>0
</qm:fs-main-module-sequence-cache-hits>
<qm:fs-main-module-sequence-cache-misses>0
</qm:fs-main-module-sequence-cache-misses>
<qm:db-main-module-sequence-cache-hits>0
</qm:db-main-module-sequence-cache-hits>
<qm:db-main-module-sequence-cache-misses>0
</qm:db-main-module-sequence-cache-misses>
<qm:fs-library-module-cache-hits>0
</qm:fs-library-module-cache-hits>
<qm:fs-library-module-cache-misses>0
</qm:fs-library-module-cache-misses>
<qm:db-library-module-cache-hits>0
</qm:db-library-module-cache-hits>
<qm:db-library-module-cache-misses>0
</qm:db-library-module-cache-misses>
<qm:fragments/>
<qm:documents/>
<qm:hosts/>
</qm:query-meters>
|
Example:
xquery version "1.0-ml";
declare namespace qm="http://marklogic.com/xdmp/query-meters";
fn:count(collection()),
xdmp:query-meters()/qm:elapsed-time
=> The count of the number of documents in the database followed by
the elapsed-time element of the xdmp:query-trace XML output:
153
<qm:elapsed-time xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:qm="http://marklogic.com/xdmp/query-meters">
PT0.04S</qm:elapsed-time>
|
|
|
|
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.
<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.
<cdata-section-elements>
- A list 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.
<use-character-maps>
- 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.
<media-type>
- A mimetype representing a media type. For example,
text/plain or text/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.
<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))
=> (<a>aaa</a>, "<a>aaa</a>")
|
|
|
|
xdmp:resolve-uri(
|
|
$relative as xs:string?,
|
|
[$base as xs:string]
|
| ) as xs:anyURI? |
|
 |
Summary:
Resolves a relative URI against an absolute URI. If $base is specified,
the URI is resolved relative to that base. If $base is not specified, the
base is set to the base-uri property from the static context, if the
property exists; if it does not exist, an error is thrown.
|
Parameters:
$relative
:
A URI reference to resolve against the base.
|
$base
(optional):
An absolute URI to use as the base of the resolution.
|
|
Usage Notes:
This function is the same as fn:resolve-uri(), but always accepts a relative
base URI. The fn:resolve-uri() function raises an error in this case in
standards compatible dialects.
If $base is specified, it is assumed to be an absolute URI and
$relative is assumed to be an absolute or a relative URI reference.
If $relative is a relative URI reference, it is resolved against $base,
using an algorithm such as the ones described in
[RFC 2396] or
[RFC 3986], and
the resulting absolute URI reference is returned.
If $relative is the zero-length string, fn:resolve-uri returns
the value of $base, or the base-uri property from the static context
if there is no $base value specified (if the base-uri property is
not initialized in the static context, an error is raised).
Resolving a URI does not dereference it. This is merely a syntactic operation
on two character strings.
|
Example:
xdmp:resolve-uri("hello/goodbye.xml",
"/mycompany/default.xqy")
=> /mycompany/hello/goodbye.xml
|
|
|
|
xdmp:set(
|
|
$variable as item()*,
|
|
$expr as item()*
|
| ) as empty-sequence() |
|
 |
Summary:
Set the value of a variable to the specified expression. The
xdmp:set command allows you to introduce changes to the
state (side effects) of a query by changing the value of a variable to
something other than what it is bound to.
|
Parameters:
$variable
:
A variable to set.
|
$expr
:
A value to set the variable.
|
|
Usage Notes:
When a variable is bound to a sequence in a for loop, and when
that variable is changed by xdmp:set in the return
clause, the change only affects the value for one iteration of the
for loop at a time; when the next value is sent to the return
clause, it is set to the next value in the sequence specified in the
for clause. The value changes only after the
xdmp:set call is made.
|
Example:
(: set the value of the variable $x
to 1234 and then print out $x :)
let $x := 12
return
(xdmp:set($x, 1234), $x)
=> 1234
|
Example:
(: set the value of the variable $x
to 5 and then print out $x for
each value of $y :)
for $x in (1, 2)
for $y in ($x, $x)
return
($y, xdmp:set($x, 5), $x)
=> (1, 5, 1, 5, 2, 5, 2, 5)
|
Example:
(: note the effect on $z of changing the
value of $x :)
for $x in (1, 2)
for $y in (3,4)
for $z in ($x, $x)
return
($z, xdmp:set($x, 5))
=> (1, 1, 5, 5, 2, 2, 5, 5)
|
Example:
(: every time the name of the input node changes,
output the new name :)
let $n := ()
for $i in (<x>1</x>, <x>2</x>, <y>3</y>)
return (
if (name($i) eq $n)
then ()
else (xdmp:set($n, name($i)), $n)
, data($i)
)
=> (x, 1, 2, y, 3)
|
|
|
|
xdmp:spawn(
|
|
$path as xs:string,
|
|
[$vars as item()*],
|
|
[$options as node()?]
|
| ) as item()* |
|
 |
Summary:
Place the specified module on the task queue for evaluation.
|
Parameters:
$path
:
The path, relative to the specified root, of the module to be executed.
For more details on resolving paths, see "Importing XQuery Modules
and Resolving Paths" in the Application Developer's Guide.
|
$vars
(optional):
The external variable values for this evaluation.
This can either be a sequence of map:map objects, or a sequence of even
length, alternating QNames and items.
Each key in the map(s) is a string representing the name of the parameter
in Clark notation: "{namespaceURI}localname". The function
xdmp:key-from-QName
is a convenient way to generate these keys.
Each entry in the map is the value of the corresponding external variable.
Alternatively, the alternating sequence should contain QName and item
pairs that specify a variable name and value for an external variable.
|
$options
(optional):
The options node. The default value is (). The node must be in the
xdmp:eval namespace. See the
xdmp:eval section for a list of options.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-spawn
|
Usage Notes:
The xdmp:spawn function places the specified XQuery module
in the task queue to be processed. The module will be evaluated when the
task server has the available resources to process it. The tasks are
processed in the order in which they are added to the queue.
Once xdmp:spawn is called, it cannot be rolled back,
even if the transaction from which it is called does not complete.
Therefore, use care or preferably avoid calling xdmp:spawn
from a module that is performing an update transaction. Once a module is
spawned, its evaluation is completely asynchronous of the statement in
which xdmp:spawn was called. Consequently,
if you call xdmp:spawn from a module that is updating a
document, and if the update ends up retrying (for example, if a deadlock
is detected), then the entire module is re-evaluated and the
xdmp:spawn call is therefore called again. This will
only happen in update statements, not in query statements. For details
on how transactions work in MarkLogic Server, see "Understanding
Transactions in MarkLogic Server" in the Developer's Guide.
|
Example:
xdmp:spawn("module.xqy", (),
<options xmlns="xdmp:eval">
<modules>{xdmp:modules-database()}</modules>
<root>http://example.com/application/</root>
</options>)
=> Puts the module from the modules database with the
URI http://example.com/application/module.xqy
in the task server queue.
|
Example:
(:
This example uses the <result> option to use the results of a
spawned task in the query
:)
let $x := xdmp:spawn("/oneplusone.xqy", (),
<options xmlns="xdmp:eval">
<result>{fn:true()}</result>
</options>
)
return
($x + 2)
(:
if /oneplusone.xqy has the following body:
1 + 1
then this query returns 4
:)
|
|
|
|
xdmp:spawn-function(
|
|
$function as function() as item()*,
|
|
[$options as node()?]
|
| ) as item()* |
|
 |
Summary:
Place the specified function value on the task queue for evaluation.
|
Parameters:
$function
:
A zero arity function value to execute.
|
$options
(optional):
The options node. The default value is (). The node must be in the
xdmp:eval namespace. See the
xdmp:eval section for a list of options.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-spawn
|
Usage Notes:
The xdmp:spawn function places the specified function value
in the task queue to be processed. The function will be executed when the
task server has the available resources to process it. The tasks are
processed in the order in which they are added to the queue.
Once xdmp:spawn is called, it cannot be rolled back,
even if the transaction from which it is called does not complete.
Therefore, use care or preferably avoid calling xdmp:spawn
from a module that is performing an update transaction. Once a module is
spawned, its evaluation is completely asynchronous of the statement in
which xdmp:spawn was called. Consequently,
if you call xdmp:spawn from a module that is updating a
document, and if the update ends up retrying (for example, if a deadlock
is detected), then the entire module is re-evaluated and the
xdmp:spawn call is therefore called again. This will
only happen in update statements, not in query statements. For details
on how transactions work in MarkLogic Server, see "Understanding
Transactions in MarkLogic Server" in the Developer's Guide.
If your function performs an update, then by default it will run
in update transaction-mode, which runs as a multi-statement transaction.
You must put an explicit xdmp:commit() with a
transaction mode of update (otherwise it will automatically roll back).
For implicit commits, specify a transaction mode of update-auto-commit.
|
Example:
let $message := "Hi!"
return
xdmp:spawn-function(function() { xdmp:sleep(1000), xdmp:log($message) })
=> Puts the inline function in the task server queue.
|
Example:
for $x in (1 to 10)
return
xdmp:spawn-function(function() {xdmp:document-insert(
fn:concat("/doc", $x, ".xml"), <foo>{$x * 2}</foo>),
xdmp:commit()},
<options xmlns="xdmp:eval">
<transaction-mode>update-auto-commit</transaction-mode>
</options>)
(:
This example uses update-auto-commit for implicit commit.
If you use <transaction-mode>update</transaction-mode>
(or if you do not specify an option, and then update
is the default) then you must put an expicit xdmp:commit()
in your function as it is run as a multi-statement transaction,
and will rollback without an expliit xdmp:commit().
:)
(: spawns functions to create the specified documents on the task server :)
|
|
|
|
xdmp:spawn-in(
|
|
$path as xs:string,
|
|
$ID as xs:unsignedLong,
|
|
[$vars as item()*],
|
|
[$modules as xs:unsignedLong?],
|
|
[$root as xs:string?]
|
| ) as empty-sequence() |
|
 |
Summary:
[DEPRECATED: use xdmp:spawn with the
database option instead] Place the specified module on the task
queue for evaluation. It will be evaluated in the given database.
|
Parameters:
$path
:
The path, relative to the specified root, of the module to be executed.
|
$ID
:
The database ID, from xdmp:database("db_name"),
xdmp:security-database(),
or xdmp:schema-database().
|
$vars
(optional):
The external variable values for this evaluation.
This must be a sequence of even length, alternating QNames and items.
Each QName and item pair specify a variable name and value.
|
$modules
(optional):
The modules database that contains the module to invoke.
The empty sequence specifies the current modules database.
|
$root
(optional):
The root path for modules.
The empty sequence specifies the current root.
|
|
Usage Notes:
The xdmp:spawn-in function places the specified XQuery
module in the task queue to be processed. The module will be evaluated
when the task server has the available resources to process it. The tasks
are processed in the order in which they are added to the queue.
|
Example:
xdmp:spawn-in("example.xqy",
324398742983742,
(),
xdmp:modules-database(),
"http://example.com/application/")
=> ()
Puts the module from the modules database with the
URI http://example.com/application/module.xqy
in the task server queue. The module will be
executed in the context of the database with
an ID of 324398742983742.
|
|
|
|
xdmp:sql(
|
|
$sql as xs:string,
|
|
[$options as xs:string*]
|
| ) as item()* |
|
 |
Summary:
Executes an ad hoc SQL query. This function is for testing
your SQL views when data modeling; it is not intended to be used directly
in applications.
|
Parameters:
$sql
:
The SQL statement to be executed.
|
$options
(optional):
Options. Available options are:
array - Return the result as a sequence of array
values (
json:array).
format - Return the results as formatted strings.
map - Return the result as a sequence of map values,
where the key is the column name.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-sql
|
Usage Notes:
Only one of the "map" and "array" options may be specified. If neither
is specified, the default is "array". If the "format" option is specified, the
output will be formatted, regardless of whether "array" or "map" was selected.
The first tuple returned will always be one consisting of the column names.
|
Example:
xdmp:sql("select title,author from books limit 4", "format")
==>
| title| author|
| The C++ Programming Language| Bjarne Stroustrup|
| Modern Information Retrieval| Ricardo Baeza-Yates|
| Modern Information Retrieval| Berthier Ribeiro-Neto|
| Unicode Demystified| Richard Gillam|
|
Example:
xdmp:to-json(xdmp:sql("select title,author from books limit 4", "array"))
==>
[{"title":"title", "author":"author"},
{"title":"The C++ Programming Language", "author":"Bjarne Stroustrup"},
{"title":"Modern Information Retrieval", "author":"Ricardo Baeza-Yates"},
{"title":"Modern Information Retrieval", "author":"Berthier Ribeiro-Neto"},
{"title":"Unicode Demystified", "author":"Richard Gillam"}
]
|
Example:
for $row in xdmp:sql("select title,author from books limit 4")
return fn:concat("Title=",$row[1],"; Author=",$row[2])
==>
Title=title, Author=author
Title=The C++ Programming Language; Author=Bjarne Stroustrup
Title=Modern Information Retrieval; Author=Ricardo Baeza-Yates
Title=Modern Information Retrieval; Author=Berthier Ribeiro-Neto
Title=Unicode Demystified; Author=Richard Gillam
|
|
|
|
xdmp:to-json(
|
|
$item as item()*
|
| ) as xs:string |
|
 |
Summary:
Returns a string representing a JSON
serialization of a given item sequence.
|
Parameters:
$item
:
The item sequence whose JSON serialization is returned.
|
|
Usage Notes:
XML nodes are serialized to JSON strings.
JSON has no serialization for infinity, not a number, and negative 0,
therefore if you try and serialize INF, -INF, NaN, or -0 as JSON, an
exception is thrown. If you want to represent these values in some way in
your serialized JSON, then you can catch the exception (with a try/catch, for
example) and provide your own value for it.
XQuery maps (map:map types) serialize to JSON name-value
pairs.
|
Example:
xdmp:to-json(("a",fn:false()))
=> ["a", false]
|
Example:
xquery version "1.0-ml";
xdmp:to-json(
xdmp:from-json('
{ "a":111 }
')
)
=>
{"a":111}
|
|
|
|
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.
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.
- "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.
|
|
|
|
xdmp:validate(
|
|
$node as node(),
|
|
[$mode as xs:string],
|
|
[$typeName as xs:QName]
|
| ) as element(xdmp:validation-errors) |
|
 |
Summary:
Returns an element containing a summary of validation errors in a node.
|
Parameters:
$node
:
The node to validate.
|
$mode
(optional):
The validation mode, either "strict", "lax", or "type".
|
$typeName
(optional):
The name of the type to validate against, if the mode is "type". An error
is raised if a typeName is given with a different validation mode, or if
no type is given if the mode is "type".
|
|
Example:
declare namespace t="http://marklogic.com/xdmp/thesaurus";
xdmp:validate(
document {
<t:thesaurus>
<t:entry>
<t:term>one</t:term>
<t:notes>unexpected stuff</t:notes>
<t:part-of-speech>expl</t:part-of-speech>
<t:synonym>
<t:term>unique</t:term>
</t:synonym>
</t:entry>
</t:thesaurus>
} )
=>
<xdmp:validation-errors>
<error:error xmlns:error="http://marklogic.com/xdmp/error"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<error:code>XDMP-VALIDATEUNEXPECTED</error:code>
<error:name>err:XQDY0027</error:name>
<error:xquery-version>1.0-ml</error:xquery-version>
<error:message>Invalid node</error:message>
<error:format-string>XDMP-VALIDATEUNEXPECTED:
(err:XQDY0027) validate full { () } -- Invalid node: Found t:notes but
expected (t:part-of-speech?,t:qualifiers?,t:scope-notes?,t:synonym*) at
fn:doc("")/t:thesaurus/t:entry/t:notes using schema
"thesaurus.xsd"</error:format-string>
<error:retryable>false</error:retryable>
<error:expr>validate full { () }</error:expr>
<error:data>
<error:datum>t:notes</error:datum>
<error:datum>(t:part-of-speech?,t:qualifiers?,t:scope-notes?,t:synonym*)
</error:datum>
<error:datum>fn:doc("")/t:thesaurus/t:entry/t:notes</error:datum>
<error:datum>"thesaurus.xsd"</error:datum>
</error:data>
<error:stack>
<error:frame>
<error:line>2</error:line>
<error:column>0</error:column>
<error:xquery-version>1.0-ml</error:xquery-version>
</error:frame>
</error:stack>
</error:error><error:error xmlns:error="http://marklogic.com/xdmp/error"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<error:code>XDMP-VALIDATEBADTYPE</error:code>
<error:name>err:XQDY0027</error:name>
<error:xquery-version>1.0-ml</error:xquery-version>
<error:message>Invalid node type</error:message>
<error:format-string>XDMP-VALIDATEBADTYPE: (err:XQDY0027) validate
full { () } -- Invalid node type: t:part-of-speech lexical value "expl"
invalid for expected type #t:part-of-speech at
fn:doc("")/t:thesaurus/t:entry/t:part-of-speech using schema
"thesaurus.xsd"</error:format-string>
<error:retryable>false</error:retryable>
<error:expr>validate full { () }</error:expr>
<error:data>
<error:datum>t:part-of-speech</error:datum>
<error:datum>"expl"</error:datum>
<error:datum>#t:part-of-speech</error:datum>
<error:datum>fn:doc("")/t:thesaurus/t:entry/t:part-of-speech</error:datum>
<error:datum>"thesaurus.xsd"</error:datum>
</error:data>
<error:stack>
<error:frame>
<error:line>2</error:line>
<error:column>0</error:column>
<error:xquery-version>1.0-ml</error:xquery-version>
</error:frame>
</error:stack>
</error:error>
</xdmp:validation-errors>
|
|
|
|
xdmp:value(
|
|
$expr as xs:string
|
| ) as item()* |
|
 |
Summary:
Evaluate an expression in the context of the current evaluating statement.
This differs from xdmp:eval in that xdmp:value
preserves all of the context from the calling query, so you do not
need to re-define namespaces, variables, and so on. Although the expression
retains the context from the calling query, it is evaluated in its own
transaction with same-statement isolation.
|
Parameters:
$expr
:
The string representing an expression to evaluate.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-value
|
Usage Notes:
You can only evaluate expressions with xdmp:value; no
prolog definitions (namespace declarations, function definitions,
module imports, and so on) are allowed.
If the expression references something not in the context of either
the calling query or the value expression, then an error is thrown. For
example, the following throws an undefined variable exception:
xdmp:value("$y")
|
Example:
let $var := 5
return
xdmp:value("$var")
=> 5
|
Example:
xquery version "1.0-ml";
xdmp:document-insert("/test.xml",
<root>
<step1>this is step1</step1>
<step2>this is step2</step2>
</root>)
;
(:
use xdmp:value to dynamically specify a step
in an XPath expression
:)
for $x in ("step1", "step2")
return
/root/xdmp:value($x)
=>
<step1>this is step1</step1>
<step2>this is step2</step2>
|
|
|
|
xdmp:xslt-eval(
|
|
$stylesheet as element(),
|
|
$input as node()?,
|
|
[$params as map:map?],
|
|
[$options as node()?]
|
| ) as document-node()* |
|
 |
Summary:
Executes an XSLT stylesheet against a node.
|
Parameters:
$stylesheet
:
The stylesheet to be executed.
|
$input
:
The context node to which the stylesheet is applied.
|
$params
(optional):
The stylesheet parameter values for this evaluation.
Each key in the map is a string representing the name of the parameter
in Clark notation: "{namespaceURI}localname". The function
xdmp:key-from-QName
is a convenient way to generate these keys.
Each entry in the map is the value of the corresponding parameter.
|
$options
(optional):
The options node. The default value is (). The node must be in the
xdmp:eval namespace. See the
xdmp:eval section for a list of options.
Additional options include:
<mode> - A QName specifying the initial
stylesheet mode to use (the
<xsl:template> with
the specified mode attribute).
<template> - A QName specifying the name of
the initial template to apply.
|
|
Usage Notes:
When creating the xsl:stylesheet element that is the
stylesheet parameter to xdmp:xslt-eval, keep in mind that
it has to first be parsed by XQuery before
it is evaluated as a stylesheet. Therefore, any characters in the stylesheet
that require escaping in XQuery must be escaped, otherwise you get an error
in the XQuery. For example, if the stylesheet has any curly braces
( { or } ), you must escape the curly braces (with curly braces). For
an example, see the example below.
When running an XSLT stylesheet in MarkLogic, you pass in a node on
which the stylesheet operates. Many stylesheets are written
to expect the initial node to be a document
node. In other XSLT processors, the node you pass to the stylesheet is
typically read in from the filesystem and is always treated as a document
node. In MarkLogic, you often get the node to pass to the stylesheet as
the result of a query or a search, and the node is not necessarily a
document node. Therefore, if your stylesheet expects
the context node to be a document node, make sure to pass in a document
node and not an element node. If you pass in an element node to a
stylesheet that has default template rules to expect a document node,
then you might miss the processing on the element you passed
in (because the stylesheet might expect the child node to be the root
element of the XML document, but if you passed in the root element instead of
its parent document node, then the child nodes would be the children of the
root element, causing the root element to miss its default processing).
|
Example:
let $foo-to-bar :=
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="foo">
<bar>
<xsl:apply-templates select="node()"/>
</bar>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
return xdmp:xslt-eval($foo-to-bar,
<stuff>
<one/>
<foo/>
<two/>
<foo><blah>42</blah></foo>
<bar>22</bar>
</stuff>)/element()
|
Example:
xquery version "1.0-ml" ;
(: Hello World example for xslt:eval, with a parameter :)
let $params := map:map()
let $_put := map:put(
$params,
xdmp:key-from-QName(fn:QName("foo", "pName")),
"Stephen")
let $_put := map:put(
$params,
xdmp:key-from-QName(fn:QName("bar", "bName")),
"Ron")
let $_put := map:put(
$params,
"cName",
"Dave")
return
xdmp:xslt-eval(
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="foo" xmlns:b="bar"
version="2.0">
<xsl:param name="f:pName"/>
<xsl:param name="b:bName"/>
<xsl:param name="cName"/>
<xsl:param name="greeting" select="'Hi there '"/>
<xsl:template match="/">
<output>
<xsl:copy-of select="node"/>
<greeting><xsl:value-of select="$greeting"/></greeting>
<param><xsl:value-of select="$f:pName"/></param>
<param><xsl:value-of select="$b:bName"/></param>
<param><xsl:value-of select="$cName"/></param>
</output>
</xsl:template>
</xsl:stylesheet>,
document { <node>Hello World</node> },
$params)
=>
<?xml version="1.0" encoding="ASCII"?>
<output xmlns:f="foo" xmlns:b="bar">
<node>Hello World</node>
<greeting>Hi there </greeting>
<param>Stephen</param>
<param>Ron</param>
<param>Dave</param>
</output>
|
Example:
xquery version "1.0-ml" ;
(: example that passes in a QName for a mode :)
xdmp:xslt-eval(
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="/">
<output>this has no mode</output>
</xsl:template>
<xsl:template match="/" mode="my-mode">
<debug>this has a mode</debug>
</xsl:template>
</xsl:stylesheet>,
document { <node>Hello World</node> },
(),
<options xmlns="xdmp:eval">
<mode>{fn:QName("", "my-mode")}</mode>
</options>)
=>
<?xml version="1.0" encoding="ASCII"?>
<debug>this has a mode</debug>
|
Example:
xquery version "1.0-ml";
(:
Note the esacped curly braces ( {{ and }} on the name attribute
of xsl:element), as the stylesheet must first be parsed by XQuery
before it is evaluated as a stylesheet. If you do not escape
the curly braces, the query throws the XQuery exception:
[1.0-ml] XDMP-CONTEXT: (err:XPDY0002) Expression depends on the context
where none is defined
That is because, without the escaped braces, XQuery tries to evaluate
the expression in the name attribute, but there is no context for it.
:)
xdmp:xslt-eval(
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="foo">
<xsl:element name="{{name(.)}}"/>
</xsl:template>
</xsl:stylesheet>
,
document{ <foo>something goes here</foo>} )
=>
<?xml version="1.0" encoding="ASCII"?>
<foo/>
|
|
|
|
xdmp:xslt-invoke(
|
|
$path as xs:string,
|
|
$input as node()?,
|
|
[$params as map:map?],
|
|
[$options as node()?]
|
| ) as document-node()* |
|
 |
Summary:
Executes an XSLT stylesheet against a node.
|
Parameters:
$path
:
The path of the stylesheet to be executed. The path is resolved against
the root of the App Server evaluating the query, the Modules directory,
or relative to the calling module. For details on resolving paths,
see "Importing XQuery Modules and Resolving Paths" in the
Application Developer's Guide.
|
$input
:
The context node to which the stylesheet is applied.
|
$params
(optional):
The stylesheet parameter values for this evaluation.
Each key in the map is a string representing the name of the parameter
in Clark notation: "{namespaceURI}localname". The function
xdmp:key-from-QName
is a convenient way to generate these keys.
Each entry in the map is the value of the corresponding parameter.
|
$options
(optional):
The options node. The default value is (). The node must be in the
xdmp:eval namespace. See the
xdmp:eval section for a list of options.
Additional options include:
<mode> - A QName specifying the initial
stylesheet mode to use (the
<xsl:template> with
the specified mode attribute).
<template> - A QName specifying the name of
the initial template to apply.
<encoding>
- Specifies the encoding to use when reading the stylesheet into MarkLogic
Server. Supported values include
UTF-8,
ISO-8859-1, as well as many other popular encodings.
See the Search Developer's Guide for a list of character
set encodings by
language. All encodings will be translated into UTF-8
from the specified encoding. The string specifed for the
encoding option will be matched to an encoding name according
to the Unicode Charset Alias Matching rules
(http://www.unicode.org/reports/tr22/#Charset_Alias_Matching).
An automatic encoding detector will be used if the value auto
is specified.
If no encoding can be detected, the encoding defaults to UTF-8.
|
|
Usage Notes:
When running an XSLT stylesheet in MarkLogic, you pass in a node on
which the stylesheet operates. Many stylesheets are written
to expect the initial node to be a document
node. In other XSLT processors, the node you pass to the stylesheet is
typically read in from the filesystem and is always treated as a document
node. In MarkLogic, you often get the node to pass to the stylesheet as
the result of a query or a search, and the node is not necessarily a
document node. Therefore, if your stylesheet expects
the context node to be a document node, make sure to pass in a document
node and not an element node. If you pass in an element node to a
stylesheet that has default template rules to expect a document node,
then you might miss the processing on the element you passed
in (because the stylesheet might expect the child node to be the root
element of the XML document, but if you passed in the root element instead of
its parent document node, then the child nodes would be the children of the
root element, causing the root element to miss its default processing).
|
Example:
xquery version "1.0-ml";
(:
this example requires a document named hello.xsl directly
at the App Server root with the following content:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="/">
<xsl:text>hello</xsl:text>
</xsl:template>
</xsl:stylesheet>
:)
xdmp:xslt-invoke("/hello.xsl", document{ <foo/> })
=>
hello
|
Example:
xquery version "1.0-ml" ;
(: Hello World example for xslt:invoke, with a parameter.
Assumes a stylesheet names params.xsl directly at
the App Server root with the following content:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="foo" xmlns:b="bar"
version="2.0">
<xsl:param name="f:pName"/>
<xsl:param name="b:bName"/>
<xsl:param name="cName"/>
<xsl:param name="greeting" select="'Hi there '"/>
<xsl:template match="/">
<output>
<xsl:copy-of select="node"/>
<greeting><xsl:value-of select="$greeting"/></greeting>
<param><xsl:value-of select="$f:pName"/></param>
<param><xsl:value-of select="$b:bName"/></param>
<param><xsl:value-of select="$cName"/></param>
</output>
</xsl:template>
</xsl:stylesheet>
:)
let $params := map:map()
let $_put := map:put(
$params,
xdmp:key-from-QName(fn:QName("foo", "pName")),
"Stephen")
let $_put := map:put(
$params,
xdmp:key-from-QName(fn:QName("bar", "bName")),
"Ron")
let $_put := map:put(
$params,
"cName",
"Dave")
return
xdmp:xslt-invoke("/params.xsl",
document { <node>Hello World</node> },
$params)
=>
<?xml version="1.0" encoding="ASCII"?>
<output xmlns:f="foo" xmlns:b="bar">
<node>Hello World</node>
<greeting>Hi there </greeting>
<param>Stephen</param>
<param>Ron</param>
<param>Dave</param>
</output>
|
|
|
|
|