XPath, XQuery, and XSLT Function Reference
XPath, XQuery, and XSLT Function Reference
Select Language HOME HTML C SS JAVASC RIPT JQUERY XML ASP.NET PHP SQL MORE...
R EFER ENC ES | EXAMPLES | FO R UM | ABO UT
Like
50k
XPath Tutorial
XPath HOME XPath Intro XPath Nodes XPath Syntax XPath Axes XPath Operators XPath Examples XPath Summary
WEB HOSTING
Best Web Hosting eUK Web Hosting UK Reseller Hosting C loud Hosting
Functions Reference
Accessor Error and Trace Numeric String AnyURI Boolean Duration/Date/Time QName Node Sequence Context
WEB BUILDING
XML Editor - Free Trial! FREE Website BUILDER FREE Website C reator
XPath Reference
XPath Functions
The default prefix for the function namespace is fn: The URI of the function namespace is: http://www.w3.org/2005/xpath-functions STATISTICS
Browser Statistics
Accessor Functions
Name fn:node-name(node) fn:nilled(node) Description Returns the node-name of the argument node Returns a Boolean value indicating whether the argument node is nilled Takes a sequence of items and returns a sequence of atomic values Returns the value of the base-uri property of the current or specified node Returns the value of the document-uri property for the specified node
fn:data(item.item,...)
fn:trace(value,label)
www.w3schools.com/xpath/xpath_functions.asp
1/9
3/26/13
fn:floor(num)
Functions on Strings
Name fn:string(arg) Description Returns the string value of the argument. The argument could be a number, boolean, or node-set Example: string(314) Result: "314" fn:codepoints-to-string(int,int,...) Returns a string from a sequence of code points Example: codepoints-to-string(84, 104, 233, 114, 232, 115, 101) Result: 'Thrse' fn:string-to-codepoints(string) Returns a sequence of code points from a string Example: string-to-codepoints("Thrse") Result: 84, 104, 233, 114, 232, 115, 101 fn:codepoint-equal(comp1,comp2 ) Returns true if the value of comp1 is equal to the value of comp2, according to the Unicode code point collation (http://www.w3.org/2005/02/xpathfunctions/collation/codepoint), otherwise it returns false Returns -1 if comp1 is less than comp2, 0 if comp1 is equal to comp2, or 1 if comp1 is greater than comp2 (according to the rules of the collation that is used) Example: compare('ghi', 'ghi') Result: 0 fn:concat(string,string,...) Returns the concatenation of the strings Example: concat('XPath ','is ','FUN!') Result: 'XPath is FUN!' fn:string-join((string,string,...),sep) Returns a string created by concatenating the string arguments and using the sep argument as the separator Example: string-join(('We', 'are', 'having', 'fun!'), ' ') Result: ' We are having fun! ' Example: string-join(('We', 'are', 'having', 'fun!')) Result: 'Wearehavingfun!' Example:string-join((), 'sep') Result: '' fn:substring(string,start,len ) fn:substring(string,start) Returns the substring from the start position to the specified length. Index of the first character is 1. If length is omitted it returns the substring from the start position to the end Example: substring('Beatles',1,4) Result: 'Beat' Example: substring('Beatles',2) Result: 'eatles'
fn:compare(comp1,comp2 ) fn:compare(comp1,comp2,collation )
fn:string-length(string) fn:string-length()
Returns the length of the specified string. If there is no string argument it returns the length of the string value of the current node Example: string-length('Beatles') Result: 7
www.w3schools.com/xpath/xpath_functions.asp
2/9
3/26/13
fn:normalize-space(string) fn:normalize-space()
www.w3schools.com/xpath/xpath_functions.asp
3/9
3/26/13
Functions for anyURI
Name fn:resolve-uri(relative,base)
Description
fn:months-from-duration(datetimedur)
fn:days-from-duration(datetimedur)
fn:hours-from-duration(datetimedur)
fn:minutes-from-duration(datetimedur)
fn:seconds-from-duration(datetimedur)
fn:year-from-dateTime(datetime)
www.w3schools.com/xpath/xpath_functions.asp
4/9
3/26/13
fn:minutes-from-dateTime(datetime)
fn:adjust-date-to-timezone(date,timezone)
fn:adjust-time-to-timezone(time,timezone)
Functions on Nodes
Name fn:name() Description Returns the name of the current node or the first node in the
www.w3schools.com/xpath/xpath_functions.asp
5/9
3/26/13
fn:name(nodeset) fn:local-name() fn:local-name(nodeset) fn:namespace-uri() fn:namespace-uri(nodeset) fn:lang(lang)
Functions on Sequences
General Functions on Sequences Name fn:index-of((item,item,...),searchitem) Description Returns the positions within the sequence of items that are equal to the searchitem argument Example: index-of ((15, 40, 25, 40, 10), 40) Result: (2, 4) Example: index-of (("a", "dog", "and", "a", "duck"), "a") Result (1, 4) Example: index-of ((15, 40, 25, 40, 10), 18) Result: () fn:remove((item,item,...),position ) Returns a new sequence constructed from the value of the item arguments - with the item specified by the position argument removed Example: remove(("ab", "cd", "ef"), 0) Result: ("ab", "cd", "ef") Example: remove(("ab", "cd", "ef"), 1) Result: ("cd", "ef") Example: remove(("ab", "cd", "ef"), 4) Result: ("ab", "cd", "ef") fn:empty(item,item,...) Returns true if the value of the arguments IS an empty sequence, otherwise it returns false Example: empty(remove(("ab", "cd"), 1)) Result: false fn:exists(item,item,...) Returns true if the value of the arguments IS NOT an empty sequence, otherwise it returns false Example: exists(remove(("ab"), 1)) Result: false
fn:distinct-values((item,item,...),collation )
Returns only distinct (different) values Example: distinct-values((1, 2, 3, 1, 2)) Result: (1, 2, 3)
fn:insert-before((item,item,...),pos,inserts )
Returns a new sequence constructed from the value of the item arguments - with the value of the inserts argument inserted in the position specified by the pos argument Example: insert-before(("ab", "cd"), 0, "gh") Result: ("gh", "ab", "cd") Example: insert-before(("ab", "cd"), 1, "gh") Result: ("gh", "ab", "cd") Example: insert-before(("ab", "cd"), 2, "gh") Result: ("ab", "gh", "cd") Example: insert-before(("ab", "cd"), 5, "gh") Result: ("ab", "cd", "gh")
fn:reverse((item,item,...))
Returns the reversed order of the items specified Example: reverse(("ab", "cd", "ef")) Result: ("ef", "cd", "ab") Example: reverse(("ab"))
www.w3schools.com/xpath/xpath_functions.asp
6/9
3/26/13
fn:one-or-more(item,item,...)
fn:exactly-one(item,item,...)
Equals, Union, Intersection and Except Name fn:deep-equal(param1,param2,collation ) Description Returns true if param1 and param2 are deep-equal to each other, otherwise it returns false
Aggregate Functions Name fn:count((item,item,...)) fn:avg((arg,arg,...)) Description Returns the count of nodes Returns the average of the argument values Example: avg((1,2,3)) Result: 2 fn:max((arg,arg,...)) Returns the argument that is greater than the others Example: max((1,2,3)) Result: 3 Example: max(('a', 'k')) Result: 'k' fn:min((arg,arg,...)) Returns the argument that is less than the others Example: min((1,2,3)) Result: 1 Example: min(('a', 'k')) Result: 'a' fn:sum(arg,arg,...) Returns the sum of the numeric value of each node in the specified node-set
Functions that Generate Sequences Name fn:id((string,string,...),node) Description 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 Returns a sequence of element or attribute nodes that have an IDREF value equal to the value of one or more of the values specified in the string argument
fn:idref((string,string,...),node)
fn:doc(URI) fn:doc-available(URI) Returns true if the doc() function returns a document node, otherwise it returns false
fn:collection() fn:collection(string)
Context Functions
Name Description
www.w3schools.com/xpath/xpath_functions.asp
7/9
3/26/13
fn:position()
Previous
Next Chapter
Generate advanced XSLT stylesheets, web pages and reports using intuitive drag-and-drop functionality, intelligent entry-helpers, and more. See how easy it is to work with XSLT in this tool from the makers of XMLSpy. Features include: Visual drag & drop stylesheet design Auto-generation of XSLT 1.0/2.0 and XSL:FO Advanced report design based on XML, XBRL and database sources Support for HTML5, CSS3, and JavaScript True electronic form design through absolute positioning in design templates Advanced functions for dynamic presentation Ability to import existing and external XSLT files Charts, graphs, bar codes, and more 32 bit & 64 bit versions And much more! Download a free trial today!
Try it now!
Top 10 Tutorials
HTML Tutorial HTML5 Tutorial C SS Tutorial C SS3 Tutorial JavaScript Tutorial jQuery Tutorial SQL Tutorial PHP Tutorial ASP.NET Tutorial XML Tutorial
Top 10 References
HTML/HTML5 Reference C SS 1,2,3 Reference C SS 3 Browser Support JavaScript HTML DOM XML DOM PHP Reference jQuery Reference ASP.NET Reference HTML C olors
Examples
HTML Examples C SS Examples XML Examples JavaScript Examples HTML DOM Examples XML DOM Examples AJAX Examples ASP.NET Examples Razor Examples ASP Examples SVG Examples
Quizzes
HTML Quiz HTML5 Quiz XHTML Quiz C SS Quiz JavaScript Quiz jQuery Quiz XML Quiz ASP Quiz PHP Quiz SQL Quiz
Color Picker
Statistics
Browser Statistics Browser OS Browser Display
RE P O RT E RRO R
HO ME
TO P
P RI N T
FO RU M
A BO U T
A D V E RT I SE WI T H U S
W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content.
www.w3schools.com/xpath/xpath_functions.asp
8/9
3/26/13
www.w3schools.com/xpath/xpath_functions.asp
9/9