How to use XQuery Node function in XML

In this article, we will discuss about XQuery Node Function.
  • 2403

The XQuery node function returns the expanded QName of a node. Function on  node is given below.

  • number Function

    The fn:number function returns the numeric value of the node that is indicated by $arg, if $arg is not specified, the context item after atomization, converted to an xs:double.

Syntax of number Function

fn:number() as xs:double?

fn:number($arg as node()?) as xs:double?

Example of number Function

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.

  • local-name Function

    The fn:local-name function returned local node value.

Syntax of local-name Function

fn:local-name() as xs:string
fn:local-name($arg as node()?) as xs:string

Example of local-name Function

declare namespace a="";
Here returned value is b.
  • namespace-uri Function

    The fn:namespace-uri function returns the namespace URI of the QName for a node.

Syntax of  namespace-uri Function

fn:namespace-uri() as xs:string
fn:namespace-uri($arg as node()?) as xs:string

Example of  namespace-uri Function

xquery version "1.0-ml";

declare namespace a="aaa";

let $x := <a:hello/>



= aaa

  • data Function

    The fn:data function returns the input sequence after replacing any nodes in the input sequence by their typed values.

Syntax of data Function

fn:data ($arg as item()*) as xdt:untypedAtomic*
  • min node Function

    The XML min node function returns the node that contains the minimum value, based on typed value.

Syntax of min node Function

declare namespace functx = ""

define function min-node

( $nodes as node()* )  as node()* {

$nodes[. = fn:min($nodes)]


  • max node Function

    The XML min node function returns the node that contains the maxmum value, based on typed value.

Syntax of  max node Function

declare namespace functx = ""

define function max-node

( $nodes as node()* )  as node()* {

$nodes[. = fn:max($nodes)]


  • root Function

    The fn:root function returns the root of the tree to which the current node or the specified belongs.

Syntax of  root Function

[$arg as node()?] )  as  node()?

Example of root Function is returns the root node of the element named last fn:root($e/last).

let $f := <first>Laura</first>
let $e := <emp> {$f} <last>Brown</last> </emp>
let $doc := document {<emps>{$e}</emps>}

Further Readings

You may also want to read these related articles: here
Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.