You are on page 1of 36

c

XPath Tutorial
cc 
c c c c

c
cc cc cc 
cc cccc

c

ccc
 c 
cc!c"cc#cc$ %cc
 c ccccc  c

c
Start learning XPath now!c

XPath Reference
&cc%c'c(cc
  c (   c(cc c#c(ccc
)*+c$ %c,*cc"c)*c

c-c

Table of Contents
c.c
"c c c'ccc

c  c
"c c ( c c((  c% c(c cccc c c(c c

c% c
"c c c cc% c

c& c
"c c c cc c

c/ c
"c cc c ccc c ccc  c

c0 
 c
"c c c c12
1c
cc
 c
cc 
 c

c

%c
"c ccc

%cc'c%c c  cccccc


 

cc'c c%cc%c c

c
cc 
c c c c

XPath Introduction
c  c c c c

ccc c(c(c(
cccc
c

What You Should Already Know


3 ( c%c c%cc ccc c(c c('4c

ïc "c5c "c
ïc c5cc 
 c

.(c%c'cc%c  c c(+c(c cccc 


c c

What is XPath?

ïc ccc% c(c (cc(ccc


c
ïc c cc  cc ccc
c
ïc ccc%c(cc(c
ïc ccc
 c 
cc"c
ïc cccc 

c

c
c

XPath Path Expressions


c cc  cc  c cc # cccc
c"  cc
 c2c %c
c2 c c  c%c c' c%c'2c'ccc

 c( c%
c

XPath Standard Functions


c c c,**c#c(c"  c c(c(cc +c
c +c
 cc
c
+c cc$ 
c
+c 6  c
+c3 c
 +cc
 c

XPath is Used in XSLT


ccc
 c 
cc c"cccc2'  c%c'cc c c
c  c"c
c

7cc c
 cc"ccc"cc

$ %cc c ccccc  c$ %c,*ccc)*c c c



cc
 ccc c
c(cc c

7cc c
 cc$ %ccc$ %cc

XPATH is a W3C Recommendation


c 
ccc8 

c,9c 
 c,:::c

c'c  cc c c%c"+c cc ccc(' c

"c c
 cc c&" c cc+c  c cccc

XPath HOME
XPath Intro
XPath Nodes
XPath Syntax
XPath Axes
XPath Operators
XPath Examples
XPath Summary
XPath Reference
XPath Functions

XPath Nodes
« Previous Next Chapter »

XPath Terminology
` 

.c+c  c c  c2c(c 4c 


+c +c +c
 +c
 #+c

+cc
c c

c
c c  cc c(c c" c
c 
c(c c cc c
 cc 
c

2cc c('cc
4c

´ xml version="1.0" encoding="ISO-8859-1" 

´ookstore
´ook
´title lang="en"Harry Potter´title
´author K. Rowling´author
´year005´year
´price9.99´price
´ook
´ookstore

0 
 c(c cc cc
c 4c

´ookstore (root element node)

´author K. Rowling´author (element node)

lang="en" (attriute node)


h 


&
c c c c'cc cc c

0 
 c(c
c 4c

 K. Rowling

"en"

ã 

.
c c
c cc c

Relationship of Nodes
Ê  

0c 
cc cc c c

.c c('c 
 ;c c2c 
cc c c(c c +c+c% +cc
 4c

´ook
´titleHarry Potter´title
´author K. Rowling´author
´year005´year
´price9.99´price
´ook

á 
  

0
c c
%c c< +c cc
 c c

.c c('c 
 ;c c +c+c% +cc c 
c cc c(c
 c2c 
4c

´ook
´titleHarry Potter´title
´author K. Rowling´author
´year005´year
´price9.99´price
´ook


 

 cc c c


c c

.c c('c 
 ;c c +c+c% +cc c 
c cc4c

´ook
´titleHarry Potter´title
´author K. Rowling´author
´year005´year
´price9.99´price
´ook

h  

&c !c +c !c +c c

.c c('c 
 ;c c c(c c c 
c c c2c 
cc c
2 c 
4c

´ookstore

´ook
´titleHarry Potter´title
´author K. Rowling´author
´year005´year
´price9.99´price
´ook

´ookstore

š  

&c !c +c !c +c c

.c c('c 
 ;c  c(c c2 c 
c c c2+c +c
+c% +cc c 
4c
´ookstore

´ook
´titleHarry Potter´title
´author K. Rowling´author
´year005´year
´price9.99´price
´ook

´ookstore

c /0c
c.c
c  c
XPath Syntaxc
c& c
c/ c
c0 
 c
c

%c

XPath Reference
c-c

XPath Syntax
c  c c c c

c cc  cc  c cc # cccc


c" c
 cc   c%c('cccc c

The XML Example Document


 c'c c c('cc
cc c 
 c 'c

=>
c ?1,*1c ?1./#@@A:#,1>Bc
c
=2 Bc
c
=2Bc
cc= c?1 1B %c =5 Bc
cc= B):::=5 Bc
=52Bc
c
=2Bc
cc= c?1 1B c=5 Bc
cc= B::A=5 Bc
=52Bc
c
=52 Bc
c
c

Selecting Nodes
c cc  cc  c cccc
c" c cc   c
%c('cccc c" c
c (cc  c c c '4c

Expression Description


c   ccc c(c c
c c
5c   c(
c cc c
55c   c cc c
c(
c c c cc
c
 c  cc
 c'  c %c cc
c   c c c c
c   c c c(c c c c
Cc   c c

.c c c 'c' c c c


cc  cc c c(c c
 4c

Path Expression Result


2 c   cc cc c(c c2 c 
c
52 c   c cc 
c2 c

Note:c.(c ccc'cccDc5cEcc'%c   cc


 cccc 
Fc
2 52c   cc2c 
cc c c(c2 c
552c   cc2c 
cc
 c'  c %c cc c

c
2 552c   cc2c 
cc c  c(c c2 c

+cc
 c'  c %c c c c2 c 
c
55Cc   cc cc c
cc
c
c

Predicates
  c c cc(cc (c ccc cccc (c c

  c c'%c


  cc6 c2 c

.c c c 'c' c c c


cc  c'c  cc c c(c
 c  4c

Path Expression Result


52 52G,Hcc   c c(c2c 
ccc cc(c c
2 c 
c

Note:c.0Acc cc

 ccG*Hcc
 c c(c +cccc ccc
cc c cG,HFFc
52 52GDEHc   c cc2c 
ccc cc(c c
2 c 
c
52 52GDE#,Hc   c ccc c2c 
ccc c
c(c c2 c 
c
52 52GDE=Hc   c c(c'c2c 
cc c c
(c c2 c 
c
55 GCHc   cc c c 
cc cc c

cc
55 GC?! !Hc   cc c c 
cc cc c

cc'cc c(c! !c
52 52G BA**Hc   cc c2c 
c(c c2 c

cc cc c 
c'cc c
  ccA**c
52 52G BA**H5 c   cc c c 
c(c c2c 
c(c
 c2 c 
cc cc c 
c'c
c c  ccA**c
c
c

Selecting Unknown Nodes


c'cc c cc  c2'cc 
c

Wildcard Description
Ic  c%c 
c c
CIc  c%c c c
 DEc  c%c c(c%c2c

.c c c 'c' c c c


cc  cc c c(c c
 4c

Path Expression Result


52 5Ic   cc cc c(c c2 c 
c
55Ic   cc 
cc c
c
55 GCIHc   cc c 
c'c c%c c
c
c

Selecting Several Paths


3%cc cJc cccc  c%cc  c  cc

.c c c 'c' c c c


cc  cc c c(c c
 4c

Path Expression Result


5525 cJc5525 c   cc c c& Kc c 
c(cc2c

c
55 cJc55 c   cc c c& Kc c 
cc c

c
52 525 cJc55 c   cc c c 
c(c c2c 
c(c
 c2 c 
c& Kcc c c 
cc
c
 c
c
XPath HOME
XPath Intro
XPath Nodes
XPath Syntax
XPath Axes
XPath Operators
XPath Examples
XPath Summary

XPath Reference
XPath Functions
XPath Axes
« Previous Next Chapter »

The XML Example Document


 c'c c c('cc
cc c 
 c 'c

´ xml version="1.0" encoding="ISO-8859-1" 

´ookstore

´ook
´title lang="eng"Harry Potter´title
´price9.99´price
´ook

´ook
´title lang="eng"earning XM´title
´price9.95´price
´ook

´ookstore

XPath Axes
&c c ( cc # c  cc c c c

AxisName Result

ancestor Selects all ancestors (parent, grandparent, etc.) of the


current node

ancestor-or-self Selects all ancestors (parent, grandparent, etc.) of the


current node and the current node itself
attriute Selects all attriutes of the current node

child Selects all children of the current node

descendant Selects all descendants (children, grandchildren, etc.) of


the current node

descendant-or-self Selects all descendants (children, grandchildren, etc.) of


the current node and the current node itself

following Selects everything in the document after the closing tag of


the current node

following-siling Selects all silings after the current node

namespace Selects all namespace nodes of the current node

parent Selects the parent of the current node

preceding Selects everything in the document that is efore the start


tag of the current node

preceding-siling Selects all silings efore the current node

self Selects the current node

Location Path Expression


&cccc c cc  c

&c cccc'cccDc5cEccc  ccc cc.c


c c cccc(c cc
 c +c c  c%cc4c

An asolute location path:

stepstep...

A relative location path:

stepstep...
0c cc  cc c cc c c # c

&c cc(4c

ïc an axis (defines the tree-relationship etween the selected nodes and the current
node)
ïc a node-test (identifies a node within an axis)
ïc ƒero or more predicates (to further refine the selected node-set)

" c% c(ccc c4c

axisname::nodetest[predicate]

V 

Vxample Result

child::ook Selects all ook nodes that are children of the current
node

attriute::lang Selects the lang attriute of the current node

child::* Selects all children of the current node

attriute::* Selects all attriutes of the current node

child::text() Selects all text child nodes of the current node

child::node() Selects all child nodes of the current node

descendant::ook Selects all ook descendants of the current node

ancestor::ook Selects all ook ancestors of the current node

ancestor-or-self::ook Selects all ook ancestors of the current node - and the
current as well if it is a ook node

child::*child::price Selects all price grandchildren of the current node

c /0c
c.c
c  c
c% c
c& c
XPath Operatorsc
c0 
 c
c

%c

XPath Reference
c-c

XPath Operators
c  c c c c

&cc  c c  cc # +cc+cc3 +ccc


 c

XPath Operators
3 'cccc(c c ccc c ccc  4c

Operator Description Example Return value


Jc 
 c'c # c 552cJc55c 8 cc # c
'cc2ccc

c
Lc &c 9cLcMc ,*c
#c c 9c#cMc )c
Ic c 9cIcMc )Mc
c Kc @ccMc )c
?c 06c  ?:@*c  c(c cc:@*c
( c(c cc::*c
F?c c 6c  F?:@*c  c(c cc::*c
( c(c cc:@*c
=c  cc  =:@*c  c(c cc:**c
( c(c cc:@*c
=?c  ccc 6cc  =?:@*c  c(c cc:**c
( c(c cc::*c
Bc N  cc  B:@*c  c(c cc::*c
( c(c cc:@*c
B?c N  ccc 6cc  B?:@*c  c(c cc::*c
( c(c cc:O*c
c c  ?:@*cc ?:O*c  c(c cc:@*c
( c(c cc:A*c
c cc  B:**cc  c(c cc:@*c
 =::*c ( c(c cc@A*c

c cDc Ac
c)c ,c
c

 Ec

XPath HOME
XPath Intro
XPath Nodes
XPath Syntax
XPath Axes
XPath Operators
XPath Vxamples
XPath Summary

XPath Reference
XPath Functions

XPath Examples
« Previous Next Chapter »

 !c%cc c
ccc% c%c2cc
c 
 c

The XML Example Document


 c'c c c('cc
cc c 
 c 'c

12
14c

´ xml version="1.0" encoding="ISO-8859-1" 

´ookstore

´ook category="COOKING"
´title lang="en"Everyday Italian´title
´authorGiada De aurentiis´author
´year005´year
´price0.00´price
´ook

´ook category="CHIDREN"
´title lang="en"Harry Potter´title
´author K. Rowling´author
´year005´year
´price9.99´price
´ook

´ook category="WEB"
´title lang="en"XQuery Kick Start´title
´authorames McGovern´author
´authorPer Bothner´author
´authorKurt Cagle´author
´authorames inn´author
´authoraidyanathan Nagarajan´author
´year00´year
´price 9.99´price
´ook

´ook category="WEB"
´title lang="en"earning XM´title
´authorErik T. Ray´author
´year00´year
´price9.95´price
´ook

´ookstore

w 'c c12
1c( cc%c' c

Loading the XML Document


*c 8 6 cccc
cc ccc
 c' c

 c(c
c
 c' 4c
var xmlhttp=new XMHttpRequest()

 c(cc(c' cD.0cAcc9E4c

var xmlhttp=new ActiveXOject("Microsoft.XMHTTP")

Selecting Nodes
*( %+c  c c((  c'%c(c c'ccc.  c0  cc
 c' c

.cc 
 c' c c c ccc'2c'c
c
 c' c

.  c0  c c c    DEc


cc  c c(
c cc

4c

xmlDoc.selectNodes(@ );

- ( +c
+c/ cc(c c c  DEc
cc  c c(
c c
c
4c

xmlDoc.evaluate(@ , xmlDoc, null, XPathResult.ANY_TYPE,null);

Select all the titles


" c('c 
 c  cc c c 4c

Example
ookstoreooktitle

Try it yourself »
Select the title of the first book
" c('c 
 c  c c c(c c(c2c c c c2 c

4c

Example
ookstoreook[1]title

Try it yourself »

"  ccc
c'cc" c 
 c c'c((  c cc.0cc c
' c

.0Acc cc

 ccG*Hcc c c(c +cccc c
cccc c cG,HFFc

h  

"c c cG*HccG,Hc


cc.0AL+c%cc c c   ccc

" c('c 
 c  c c c(c c(c2c c c c2 c

4c

Example
@.setProperty("Selectionanguage","XPath");
@.selectNodes("ookstoreook[1]title");

Try it yourself »

Select all the prices


" c('c 
 c  c c c(
cc c c 4c
Example
ookstoreookpricetext()

Try it yourself »

Select price nodes with price>35


" c('c 
 c  cc c c c'cc c ccA4c

Example
ookstoreook[price5]price

Try it yourself »

Select title nodes with price>35


" c('c 
 c  cc c c c'cc c ccA4c

Example
ookstoreook[price5]title

Try it yourself »

c /0c
c.c
c  c
c% c
c& c
c/ c
c0 
 c
XPath Summaryc

XPath Reference
c-c

You Have Learned XPath, Now What?


c  c c c c

XPath Summary
"cccc%c'cc(c(
cccc
c

7c c  c'cc ccc cc 


cc ccc
c
c

7c cc  c'cc c


c(c cc(cc c#cc
c

-c
 c(
cc+c  c2cccc8 (   c

Now You Know XPath, What's Next?


" c c ccc cc"+c$ %+c2+cc c

XSLTc

"cc c% c c c(cc( c

c"c%cc(
cc
cc c(
+c2 c "c

.(c%c'cc c
 cc"+c  ccc"cc

XQueryc

$ %ccc6 %ccc

$ %cc  cc6 %c%ccc cc+cc c


.(c%c'cc c
 cc$ %+c  ccc$ %cc

XLink and XPointerc

2cccc cc'c4c2cc c

2cc c ( ccc'%c(c c% 2ccc


c

.(c%c'cc c
 cc2cc +c  ccc2cc
 cc
XPath HOME
XPath Intro
XPath Nodes
XPath Syntax
XPath Axes
XPath Operators
XPath Examples
XPath Summary

XPath Reference
XPath Functions

XPath, XQuery, and XSLT Functions


« Previous Next Chapter »

" c('c (   c%c ( c c(c 6 c(cc)*+c$ %c


,*cc"c)*c

Functions Reference
ïc Accessor ïc AnyURI ïc Node
ïc Error and Trace ïc Boolean ïc Sequence
ïc Numeric ïc DurationDateTime ïc Context
ïc String ïc QName
" c (c ( c(c c(c
 cc(4c

" c*8.c(c c(c


 c4c455''''5)**A5 #(c

h    
Name Description

fn:node-name(node) Returns the node-name of the argument node

fn:nilled(node) Returns a Boolean value indicating whether the


argument node is nilled

fn:data(ieie) Takes a sequence of items and returns a sequence


of atomic values

fn:ase-uri() Returns the value of the ase-uri property of the


fn:ase-uri(node) current or specified node

fn:document-uri(node) Returns the value of the document-uri property for


the specified node

V      
Name Description

fn:error() Example:
fn:error(error) error(fn:QName('http:example.comtest',
fn:error(errordescri ion) 'err:toohigh'), 'Error: Price is too high')
fn:error(errordescri ionerror-objec)
8 4c8 c
455 
 
5 Pcc cc
104c ccc1cc c  c
 c 
c
fn:trace(!ebe) Used to deug queries

    `  

Name Description

fn:numer(rg) Returns the numeric value of the argument. The


argument could e a oolean, string, or node-set

0 
 4c
 D!,**!Ec
8 4c,**c
fn:as(n) Returns the asolute value of the argument

0 
 4cD,MEc
8 4c,Mc

0 
 4cD#,MEc
8 4c,Mc
fn:ceiling(n) Returns the smallest integer that is greater than the
numer argument

0 
 4c D,MEc
8 4cMc
fn:floor(n) Returns the largest integer that is not greater than
the numer argument

0 
 4c(D,MEc
8 4cc
fn:round(n) Rounds the numer argument to the nearest
integer

0 
 4cD,MEc
8 4cc
fn:round-half-to-even() Example: round-half-to-even(0.5)
Result: 0

0 
 4c#(##  D,AEc
8 4c)c

0 
 4c#(##  D)AEc
8 4c)c

      
Name Description

fn:string(rg) Returns the string value of the argument. The


argument could e a numer, oolean, or node-set

0 
 4cD,MEc
8 4c1,M1c
fn:codepoints-to-string(inin) Returns a string from a sequence of code points

0 
 4c ##D@M+c,*M+c)+c
,,M+c))+c,,A+c,*,Ec
8 4c!"QR !cc
fn:string-to-codepoints(sring) Returns a sequence of code points from a string

0 
 4c## D1"QR 1Ec
8 4c@M+c,*M+c)+c,,M+c))+c,,A+c,*,c
fn:codepoint-equal(co co
) Returns true if the value of comp1 is equal to the
value of comp, according to the Unicode code
point collation
(http:www.w.org0050xpath-
functionscollationcodepoint), otherwise it returns
false

fn:compare(co co
) Returns -1 if comp1 is less than comp, 0 if comp1
fn:compare(co co
coion) is equal to comp, or 1 if comp1 is greater than
comp (according to the rules of the collation that
is used)

0 
 4c
 D!!+c!!Ec
8 4c*c
fn:concat(sringsring) Returns the concatenation of the strings

0 
 4cD!c!+!c!+!-* F!Ec
8 4c!cc-* F!c
fn:string-join(>sringsring se ) Returns a string created y concatenating the string
arguments and using the sep argument as the
separator

0 
 4c# DD! !+c! !+c!!+c
!(F!E+c!c!Ec
8 4c!c c cc(Fc!c

0 
 4c# DD! !+c! !+c!!+c
!(F!EEc
8 4c!  (F!c

0 
 4# DDE+c! !Ec
8 4c!!c
fn:sustring(sringsren) Returns the sustring from the start position to the
fn:sustring(sringsr) specified length. Index of the first character is 1. If
length is omitted it returns the sustring from the
start position to the end

0 
 4cD!3  !+,+MEc
8 4c!3 !c

0 
 4cD!3  !+)Ec
8 4c!  !c
fn:string-length(sring) Returns the length of the specified string. If there is
fn:string-length() no string argument it returns the length of the
string value of the current node

0 
 4c# D!3  !Ec
8 4cOc
fn:normaliƒe-space(sring) Removes leading and trailing spaces from the
fn:normaliƒe-space() specified string, and replaces all internal sequences
of white space with one and returns the result. If
there is no string argument it does the same on the
current node

0 
 4c
< # D!c" cccc!Ec
8 4c!" c!c
fn:normaliƒe-unicode()

fn:upper-case(sring) Converts the string argument to upper-case

0 
 4c # D!" c!Ec
8 4c!" 0c!c
fn:lower-case(sring) Converts the string argument to lower-case

0 
 4c' # D!" c!Ec
8 4c! c
!c
fn:translate(sring sring
sring3) Converts string1 y replacing the characters in
string with the characters in string

0 
 4c D!,)4*!+!*!+!MA!Ec
8 4c!,)4MA!c

0 
 4c D!,)4*!+!*!+!AM!Ec
8 4c!,)4MA!c

0 
 4c D!,)4*!+!*,)!+!!Ec
8 4c!4!c
fn:escape-uri(sringURIesc-res) Example: escape-
uri("http:example.comtest#car", true())
Result: "http%A%F%Fexample.com%Ftest#car"
0 
 4c  #
D1455 
 
5 P1+c( DEEc
8 4c1455 
 
5 P1c

0 
 4c  #c
D1455 
 
5SQQ1+c( DEEc
8 4c
1455 
 
5STT&:TT&:1c
fn:contains(sring sring
) Returns true if string1 contains string, otherwise it
returns false

0 
 4cD!!+!!Ec
8 4c c
fn:starts-with(sring sring
) Returns true if string1 starts with string, otherwise
it returns false

0 
 4c#'D!!+!!Ec
8 4c c
fn:ends-with(sring sring
) Returns true if string1 ends with string, otherwise
it returns false

0 
 4c #'D!!+!!Ec
8 4c( c
fn:sustring-efore(sring sring
) Returns the start of string1 efore string occurs in
it

0 
 4c# ( D!,)5,*!+!5!Ec
8 4c!,)!c
fn:sustring-after(sring sring
) Returns the remainder of string1 after string
occurs in it

0 
 4c#( D!,)5,*!+!5!Ec
8 4c!,*!c
fn:matches(sring ern) Returns true if the string argument matches the
pattern, otherwise, it returns false

0 
 4c
 D1 1+c11Ec
8 4c c
fn:replace(sring ernre ce) Returns a string that is created y replacing the
given pattern with the replace argument

0 
 4c  D13 c.1+c11+c1I1Ec
8 4c!3 IIc.I!c

Example: replace("Bella Italia", "l", "")


Result: 'Bea Itaia'

fn:tokeniƒe(sring ern) Example: tokeniƒe("XPath is fun", "\s+")


Result: ("XPath", "is", "fun")

     ã
Name Description

fn:resolve-uri(rei!ebse)

    
 

Name Description

fn:oolean(rg) Returns a oolean value for a numer, string, or


node-set

fn:not(rg) The argument is first reduced to a oolean value y


applying the oolean() function. Returns true if the
oolean value is false, and false if the oolean value
is true

0 
 4cD DEEc
8 4c( c
fn:true() Returns the oolean value true

0 
 4c DEc
8 4c c
fn:false() Returns the oolean value false

0 
 4c( DEc
8 4c( c

    š  š  


 c0 c-ccK+cK cc"
cc

Name Description

fn:dateTime(deie) Converts the arguments to a date and a time


fn:years-from-duration(deiedr) Returns an integer that represents the years
component in the canonical lexical representation
of the value of the argument

fn:months-from-duration(deiedr) Returns an integer that represents the months


component in the canonical lexical representation
of the value of the argument

fn:days-from-duration(deiedr) Returns an integer that represents the days


component in the canonical lexical representation
of the value of the argument

fn:hours-from-duration(deiedr) Returns an integer that represents the hours


component in the canonical lexical representation
of the value of the argument

fn:minutes-from-duration(deiedr) Returns an integer that represents the minutes


component in the canonical lexical representation
of the value of the argument

fn:seconds-from-duration(deiedr) Returns a decimal that represents the seconds


component in the canonical lexical representation
of the value of the argument

fn:year-from-dateTime(deie) Returns an integer that represents the year


component in the localiƒed value of the argument

0 
 4c% #(
#
 "
D 4 "
D1)**A#*,#,*",)4*#
*M4,*1EEc
8 4c)**Ac
fn:month-from-dateTime(deie) Returns an integer that represents the month
component in the localiƒed value of the argument

0 
 4c
#(
#
 "
D 4 "
D1)**A#*,#,*",)4*#
*M4,*1EEc
8 4c*,c
fn:day-from-dateTime(deie) Returns an integer that represents the day
component in the localiƒed value of the argument

0 
 4c%#(
#
 "
D 4 "
D1)**A#*,#,*",)4*#
*M4,*1EEc
8 4c,*c
fn:hours-from-dateTime(deie) Returns an integer that represents the hours
component in the localiƒed value of the argument

0 
 4c#(
#
 "
D 4 "
D1)**A#*,#,*",)4*#
*M4,*1EEc
8 4c,)c
fn:minutes-from-dateTime(deie) Returns an integer that represents the minutes
component in the localiƒed value of the argument

0 
 4c
 #(
#
 "
D 4 "
D1)**A#*,#,*",)4*#
*M4,*1EEc
8 4c*c
fn:seconds-from-dateTime(deie) Returns a decimal that represents the seconds
component in the localiƒed value of the argument

0 
 4c #(
#
 "
D 4 "
D1)**A#*,#,*",)4*4**#
*M4,*1EEc
8 4c*c
fn:timeƒone-from-dateTime(deie) Returns the time ƒone component of the argument
if any

fn:year-from-date(de) Returns an integer that represents the year in the


localiƒed value of the argument

0 
 4c% #(
# D 4 D1)**A#*M#
)1EEc
8 4c)**Ac
fn:month-from-date(de) Returns an integer that represents the month in the
localiƒed value of the argument

0 
 4c
#(
# D 4 D1)**A#*M#
)1EEc
8 4cMc
fn:day-from-date(de) Returns an integer that represents the day in the
localiƒed value of the argument

0 
 4c%#(
# D 4 D1)**A#*M#
)1EEc
8 4c)c
fn:timeƒone-from-date(de) Returns the time ƒone component of the argument
if any

fn:hours-from-time(ie) Returns an integer that represents the hours


component in the localiƒed value of the argument

0 
 4c#(
#
D 4
D1,*4))4**1EEc
8 4c,*c
fn:minutes-from-time(ie) Returns an integer that represents the minutes
component in the localiƒed value of the argument

0 
 4c
 #(
#

D 4
D1,*4))4**1EEc
8 4c))c
fn:seconds-from-time(ie) Returns an integer that represents the seconds
component in the localiƒed value of the argument

0 
 4c #(
#

D 4
D1,*4))4**1EEc
8 4c*c
fn:timeƒone-from-time(ie) Returns the time ƒone component of the argument
if any

fn:adjust-dateTime-to- If the timeƒone argument is empty, it returns a


timeƒone(deieiezone) dateTime without a timeƒone. Otherwise, it returns
a dateTime with a timeƒone

fn:adjust-date-to- If the timeƒone argument is empty, it returns a date


timeƒone(deiezone) without a timeƒone. Otherwise, it returns a date
with a timeƒone

fn:adjust-time-to- If the timeƒone argument is empty, it returns a time


timeƒone(ieiezone) without a timeƒone. Otherwise, it returns a time
with a timeƒone

   
 ` 
Name Description

fn:QName()

fn:local-name-from-QName()
fn:namespace-uri-from-QName()

fn:namespace-uri-for-prefix()

fn:in-scope-prefixes()

fn:resolve-QName()

    ` 
Name Description

fn:name() Returns the name of the current node or the first


fn:name(nodese) node in the specified node set

fn:local-name() Returns the name of the current node or the first


fn:local-name(nodese) node in the specified node set - without the
namespace prefix

fn:namespace-uri() Returns the namespace URI of the current node or


fn:namespace-uri(nodese) the first node in the specified node set

fn:lang(ng) Returns true if the language of the current node


matches the language of the specified language

0 
 4cD1 1Ecc c(c
=c
4?1 1B=5Bc

0 
 4cD1 1Ecc( c(c
=c
4?1 1B=5Bc
fn:root() Returns the root of the tree to which the current
fn:root(node) node or the specified elongs. This will usually e a
document node

      

N  c-cc 6  c

Name Description

fn:index-of(>ieie sercie) Returns the positions within the sequence of items


that are equal to the searchitem argument

0 
 4c #(cDD,A+cM*+c)A+cM*+c,*E+cM*Ec
8 4cD)+cMEc

0 
 4c #(cDD11+c11+c11+c11+c
121E+c11Ec
8 cD,+cMEc

0 
 4c #(cDD,A+cM*+c)A+cM*+c,*E+c,@Ec
8 4cDEc
fn:remove(>ieie  osiion) Returns a new sequence constructed from the
value of the item arguments - with the item
specified y the position argument removed

0 
 4c
 DD11+c11+c1 (1E+c*Ec
8 4cD11+c11+c1 (1Ec

0 
 4c
 DD11+c11+c1 (1E+c,Ec
8 4cD11+c1 (1Ec

0 
 4c
 DD11+c11+c1 (1E+cMEc
8 4cD11+c11+c1 (1Ec
fn:empty(ieie) Returns true if the value of the arguments IS an
empty sequence, otherwise it returns false

0 
 4c
%D
 DD11+c11E+c,EEc
8 4c( c
fn:exists(ieie) Returns true if the value of the arguments IS NOT
an empty sequence, otherwise it returns false

0 
 4c D
 DD11E+c,EEc
8 4c( c
fn:distinct-values(>ieie coion) Returns only distinct (different) values

0 
 4c# DD,+c)+c+c,+c)EEc
8 4cD,+c)+cEc
fn:insert-efore(>ieie  osinsers) Returns a new sequence constructed from the
value of the item arguments - with the value of the
inserts argument inserted in the position specified
y the pos argument

0 
 4c # ( DD11+c11E+c*+c11Ec
8 4cD11+c11+c11Ec

0 
 4c # ( DD11+c11E+c,+c11Ec
8 4cD11+c11+c11Ec

0 
 4c # ( DD11+c11E+c)+c11Ec
8 4cD11+c11+c11Ec

0 
 4c # ( DD11+c11E+cA+c11Ec
8 4cD11+c11+c11Ec
fn:reverse(>ieie ) Returns the reversed order of the items specified

0 
 4c   DD11+c11+c1 (1EEc
8 4cD1 (1+c11+c11Ec

0 
 4c   DD11EEc
8 4cD11Ec
fn:susequence(>ieie sren) Returns a sequence of items from the position
specified y the start argument and continuing for
the numer of items specified y the len argument.
The first item is located at position 1

0 
 4c 6  DDU
,+cU
)+c
U
+E+cEc
8 4cDU
+cEc

0 
 4c 6  DDU
,+cU
)+cU
+c
E+c)+c)Ec
8 4cDU
)+cU
Ec
fn:unordered(>ieie ) Returns the items in an implementation dependent
order

-c"c" c c%c(c 6  cc

Name Description

fn:ƒero-or-one(ieie) Returns the argument if it contains ƒero or one


items, otherwise it raises an error

fn:one-or-more(ieie) Returns the argument if it contains one or more


items, otherwise it raises an error

fn:exactly-one(ieie) Returns the argument if it contains exactly one


item, otherwise it raises an error
06+c*+c.  cc0  cc

Name Description

fn:deep-equal( r  r


coion) Returns true if param1 and param are deep-equal
to each other, otherwise it returns false

&  c-c

Name Description

fn:count(>ieie ) Returns the count of nodes

fn:avg(>rgrg ) Returns the average of the argument values

0 
 4cDD,+)+EEc
8 4c)c
fn:max(>rgrg ) Returns the argument that is greater than the
others

0 
 4c
 DD,+)+EEc
8 4cc

0 
 4c
 DD!!+c!2!EEc
8 4c!2!c
fn:min(>rgrg ) Returns the argument that is less than the others

0 
 4c
DD,+)+EEc
8 4c,c

0 
 4c
DD!!+c!2!EEc
8 4c!!c
fn:sum(rgrg) Returns the sum of the numeric value of each node
in the specified node-set

-ccN   c 6  c

Name Description

fn:id(>sringsring node) Returns a sequence of element nodes that have an


ID value equal to the value of one or more of the
values specified in the string argument

fn:idref(>sringsring node) Returns a sequence of element or attriute nodes


that have an IDREF value equal to the value of one
or more of the values specified in the string
argument

fn:doc(URI)

fn:doc-availale(URI) Returns true if the doc() function returns a


document node, otherwise it returns false

fn:collection()
fn:collection(sring)

á     
Name Description

fn:position() Returns the index position of the node that is


currently eing processed

0 
 4c552GDE=?Hc
8 4c  c c(c c2c 
cc
fn:last() Returns the numer of items in the processed node
list

0 
 4c552GDEHc
8 4c  c cc2c 
c
fn:current-dateTime() Returns the current dateTime (with timeƒone)

fn:current-date() Returns the current date (with timeƒone)

fn:current-time() Returns the current time (with timeƒone)

fn:implicit-timeƒone() Returns the value of the implicit timeƒone

fn:default-collation() Returns the value of the default collation

fn:static-ase-uri() Returns the value of the ase-uri

« Previous Next Chapter »