This page was generated
July 7, 2010
4:04 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:nilled Summary: Returns an xs:boolean indicating whether the argument node is "nilled".
fn:node-kind [0.9-ml only, use xdmp:node-kind in 1.0 and 1.0-ml] 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  xs: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:nilled(
$arg as node()?
)  as  xs:boolean?
Summary:

Summary: Returns an xs:boolean indicating whether the argument node is "nilled". If the argument is not an element node, returns the empty sequence. If the argument is the empty sequence, returns the empty sequence. For element nodes, true() is returned if the element is nilled, otherwise false().

Elements may be defined in a schema as nillable, which allows an empty instance of an element to a appear in a document even though its type requires that it always have some content. Nilled elements should always be empty but an element is not considered nilled just because it's empty. It must also have the type annotation attribute xsi:nil="true".


Parameters:
$arg : The node to test for nilled status.

Example:
fn:nilled(<foo/>)
=> false

fn:nilled(<foo xsi:nil="true"/>)
=> true

fn:nilled(<foo xsi:nil="false"/>)
=> false

fn:nilled(())
=> ()

fn:nilled(text { "foo" })
=> ()

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

[0.9-ml only, use xdmp:node-kind in 1.0 and 1.0-ml] 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