MarkLogic Server
XQUERY API DOCUMENTATION
3.2
This page was generated
January 5, 2009
5:42 PM
XQuery Built-In and Modules Function Reference

Built-In: Accessor

The accessor built-in functions are XQuery functions to access node properties. They are defined in XQuery 1.0 and XPath 2.0 Functions and Operators.
Function Summary
fn:base-uri Returns the value of the base-uri property for the specified node.
fn:data Takes a sequence of items and returns a sequence of atomic values.
fn:document-uri Returns the value of the document-uri property for the specified node.
fn:node-kind Returns an xs:string representing the node's kind: either "document", "element", "attribute", "text", "namespace", "processing-instruction", "binary", or "comment".
fn:node-name Returns an expanded-QName for node kinds that can have names.
fn:string Returns the value of $arg represented as an xs:string.
Function Detail
fn:base-uri(
[$arg as node()?]
)  as  xs:anyURI?
Summary:

Returns the value of the base-uri property for the specified node. If the node is part of a document and does not have a base-uri attribute explicitly set, fn:base-uri typically returns the URI of the document in which the node resides.

Parameters:
$arg (optional): The node whose base-uri is to be returned.

Example:
for $x in xdmp:directory("/myDirectory/", "1")
return
base-uri($x)

=> a list of URIs for all of the documents in the
   directory "/myDirectory/"

fn:data(
$arg as item()*
)  as  xdt:anyAtomicType*
Summary:

Takes a sequence of items and returns a sequence of atomic values.

The fn:data function returns the sequence of atomic values produced by applying the following rules to each item in $arg:

  • If the item is an atomic value, it is returned.
  • If the item is a node:
    • If the node does not have a typed value an error is raised [err:FOTY0012].
    • Otherwise, fn:data returns the typed value of the node as defined by the accessor function dm:typed-value in Section 5.15 typed-value Accessor[DM].

Parameters:
$arg : The items whose typed values are to be returned.

Example:
let $x := <hello>hello
            <goodbye>goodbye</goodbye>
          </hello>
return
fn:data($x)

=> hello goodbye

fn:document-uri(
$arg as node()?
)  as  xs:anyURI?
Summary:

Returns the value of the document-uri property for the specified node. If the node is a document node, then the value returned is the URI of the document. If the node is not a document node, then fn:document-uri returns the the empty sequence.

Parameters:
$arg : The node whose document-uri is to be returned.

Usage Notes:

fn:document-uri will only return the URI of a document when a document node is passed into it. If you want to return the URI of a node that is not a document node, but has a document node ancestor, use fn:base-uri.

Example:
for $x in xdmp:directory("/myDirectory/", "1")
return
fn:document-uri($x)

=> a list of URIs for all of the documents in the
   directory "/myDirectory/"

fn:node-kind(
$node as node()?
)  as  xs:string
Summary:

Returns an xs:string representing the node's kind: either "document", "element", "attribute", "text", "namespace", "processing-instruction", "binary", or "comment".

Parameters:
$node : The node whose kind is to be returned.

Example:
let $x := <hello><goodbye>1</goodbye></hello>
return
fn:node-kind($x/node())

=> element

fn:node-name(
$arg as node()?
)  as  xs:QName?
Summary:

Returns an expanded-QName for node kinds that can have names. For other kinds of nodes it returns the empty sequence. If $arg is the empty sequence, the empty sequence is returned.

Parameters:
$arg : The node whose name is to be returned.

Example:
let $x := <hello><goodbye>1</goodbye></hello>
return
fn:node-name($x/child::element())

=> goodbye

fn:string(
[$arg as item()?]
)  as  xs:string?
Summary:

Returns the value of $arg represented as an xs:string. If no argument is supplied, this function returns the string value of the context item (.).

Parameters:
$arg (optional): The item to be rendered as a string.

Usage Notes:

If no argument is supplied and the context item is undefined, an error is raised.

If $arg is the empty sequence, the zero-length string is returned.

If $arg is a node, the function returns the string-value of the node, as obtained using the dm:string-value accessor.

If $arg is an atomic value, then the function returns the same string as is returned by the expression:

$arg cast as xs:string

Example:
let $x := <hello>hello<goodbye>goodbye</goodbye></hello>
return
fn:string($x)

=> hellogoodbye