| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 6:01 AM | XQuery & XSLT Built-In & Modules Function Reference
Built-In: Node
The node built-in functions are XQuery functions defined to operate on nodes. They are defined in XQuery 1.0 and XPath 2.0 Functions and Operators.
Function Summary
fn:generate-id | Returns a string that uniquely identifies a given node.
fn:lang | This function tests whether the language of $node, or the context node if the second argument is omitted, as specified by xml:lang attributes is the same as, or is a sublanguage of, the language specified by $testlang.
fn:local-name | Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName.
fn:name | Returns the name of a node, as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName.
fn:namespace-uri | Returns the namespace URI of the xs:QName of the node specified by $arg.
fn:number | Returns the value indicated by $arg or, if $arg is not specified, the context item after atomization, converted to an xs:double.
fn:root | Returns the root of the tree to which $arg belongs.
Function Detail
fn:generate-id(
| [$node as node()?]
) as xs:string
Summary: Returns a string that uniquely identifies a given node. If $arg is the empty sequence, the zero-length string is returned. If the function is called without an argument, the context item is used as the default argument. If the context item is undefined an error is raised: [err:XPDY0002]. If the context item is not a node an error is raised: [err:XPTY0004].
Parameters:
$node (optional): The node whose id will be generated.
Example:
    let $x := doc("auction.xml")
    return
    fn:generate-id($x)

    => n965c71980e85a011
fn:lang(
| $testlang as xs:string?,
| [$node as node()]
) as xs:boolean
Summary: This function tests whether the language of $node, or the context node if the second argument is omitted, as specified by xml:lang attributes is the same as, or is a sublanguage of, the language specified by $testlang. The language of the argument node, or the context node if the second argument is omitted, is determined by the value of the xml:lang attribute on the node, or, if the node has no such attribute, by the value of the xml:lang attribute on the nearest ancestor of the node that has an xml:lang attribute. If there is no such ancestor, then the function returns false If the second argument is omitted and the context item is undefined an error is raised: [err:XPDY0002]. If the context item is not a node an error is raised [err:XPTY0004]. If $testlang is the empty sequence it is interpreted as the zero-length string. The relevant xml:lang attribute is determined by the value of the XPath expression: (ancestor-or-self::* /@xml:lang)[last()] If this expression returns an empty sequence, the function returns false. Otherwise, the function returns true if and only if the string-value of the relevant xml:lang attribute is equal to $testlang based on a caseless default match as specified in section 3.13 of [The Unicode Standard], or if the string-value of the relevant testlang attribute contains a hyphen, "-" (The character "-" is HYPHEN-MINUS, #x002D) such that the part of the string-value preceding that hyphen is equal to $testlang, using caseless matching.
Parameters:
$testlang : The language against which to test the node.
$node (optional): The node to test.
Example: The expression fn:lang("en") would return true if the context node were any of the following four elements: <para xml:lang="en"/> <div xml:lang="en"><para>And now, and forever!</para></div> <para xml:lang="EN"/> <para xml:lang="en-us"/> The expression fn:lang("fr") would return false if the context node were <para xml:lang="EN"/>
fn:local-name(
| [$arg as node()?]
) as xs:string
Summary: Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName. If the argument is omitted, it defaults to the context node. If the context item is undefined an error is raised: [err:XPDY0002]. If the context item is not a node an error is raised: [err:XPTY0004]. If the argument is supplied and is the empty sequence, the function returns the zero-length string. If the target node has no name (that is, if it is a document node, a comment, a text node, or a namespace node having no name), the function returns the zero-length string. Otherwise, the value returned will be the local part of the expanded-QName of the target node (as determined by the dm:node-name accessor in Section 5.11 node-name Accessor[DM]. This will be an xs:string whose lexical form is an xs:NCName.
Parameters:
$arg (optional): The node whose local name is to be returned.
Example:
    xquery version "1.0-ml";
    declare namespace a="a";

    let $x := <a:hello/>
    return
    fn:local-name($x)

    => hello
fn:name(
| [$arg as node()?]
) as xs:string
Summary: Returns the name of a node, as an `xs:string` that is either the zero-length string, or has the lexical form of an `xs:QName`. If the argument is omitted, it defaults to the context node. If the context item is undefined an error is raised: [err:XPDY002]. If the context item is not a node an error is raised: [err:XPTY0004]. If the argument is supplied and is the empty sequence, the function returns the zero-length string. If the target node has no name (that is, if it is a document node, a comment, a text node, or a namespace node having no name), the function returns the zero-length string. If the specified node was created with a namespace prefix, that namespace prefix is returned with the element localname (for example, `a:hello`). Note that the namespace prefix is not always the same prefix that would be returned if you serialized the QName of the node, as the serialized QName will use the namespace from the XQuery context in which it was serialized.
Parameters:
$arg (optional): The node whose name is to be returned.
Example:
    xquery version "1.0-ml";
    declare namespace a="a";

    let $x := <a:hello/>
    return
    fn:name($x)

    => a:hello
fn:namespace-uri(
| [$arg as node()?]
) as xs:anyURI
Summary: Returns the namespace URI of the xs:QName of the node specified by $arg. If the argument is omitted, it defaults to the context node. If the context item is undefined an error is raised: [err:XPDY0002]. If the context item is not a node an error is raised: [err:XPTY0004]. If $arg is the empty sequence, the xs:anyURI corresponding to the zero-length string is returned. If $arg is neither an element nor an attribute node, or if it is an element or attribute node whose expanded-QName (as determined by the dm:node-name accessor in the Section 5.11 node-name Accessor[DM]) is in no namespace, then the function returns the xs:anyURI corresponding to the zero-length string.
Parameters:
$arg (optional): The node whose namespace URI is to be returned.
Example:
    xquery version "1.0-ml";
    declare namespace a="aaa";

    let $x := <a:hello/>
    return
    fn:namespace-uri($x)

    => aaa
fn:number(
| [$arg as xs:anyAtomicType?]
) as xs:double
Summary: Returns the value indicated by $arg or, if $arg is not specified, the context item after atomization, converted to an xs:double. If $arg is the empty sequence or if $arg or the context item cannot be converted to an xs:double, the xs:double value NaN is returned. If the context item is undefined an error is raised: [err:XPDY0002]. Calling the zero-argument version of the function is defined to give the same result as calling the single-argument version with an argument of ".". That is, fn:number() is equivalent to fn:number(.). If $arg is the empty sequence, NaN is returned. Otherwise, $arg, or the context item after atomization, is converted to an xs:double following the rules of 17.1.3.2 Casting to xs:double. If the conversion to xs:double fails, the xs:double value NaN is returned.
Parameters:
$arg (optional): The value to be returned as an xs:double value.
Example:
    fn:number($item1/quantity) returns 5.0.
    fn:number($item2) returns NaN.

    Assume that the context item is the xs:string "15".
    fn:number() returns 1.5E1.
fn:root(
| [$arg as node()?]
) as node()?
Summary: Returns the root of the tree to which $arg belongs. This will usually, but not necessarily, be a document node. If $arg is the empty sequence, the empty sequence is returned. If $arg is a document node, $arg is returned. If the function is called without an argument, the context item is used as the default argument. If the context item is undefined an error is raised: [err:XPDY0002]. If the context item is not a node an error is raised: [err:XPTY0004].
Parameters:
$arg (optional): The node whose root node will be returned.
Example:
    Assume the following variable definitions:
    let $i := <tool>wrench</tool>
    let $o := <order> {$i} <quantity>5</quantity> </order>
    let $odoc := document {$o}
    let $newi := $o/tool

    fn:root($i) returns $i
    fn:root($o/quantity) returns $o
    fn:root($odoc//quantity) returns $odoc
    fn:root($newi) returns $o

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.