| Function Library | |
| Variables | |
| Examples | |
| funtions used to maniuplate the XPath | |
| Can be used for a node-test or a predicate | |
| All functions use return-type function-name(parameters) |
|
| return-type |
|
| parameters |
|
| * | selects all nodes |
| boolean boolean( object ) |
converts anything passed to it to a boolean example
|
| number ceiling( number ) | rounds a passed number to the smallest integer
that is not smaller than the passed number
example
|
| comment() | gets the comments for that element |
| string concat( string1, string2+) | concats all strings passed into one string
example
|
| boolean contains( string1, string2 ) | returns true if string1 contains string2
example
|
| number count( node-set ) | returns the number of nodes in the passed node-set
example
|
| boolean false() | always returns false, xpath does not have a true or false
literal value
example
|
| number floor( number ) | rounds a passed number to the largest integer that is not
larger than the passed number
example
|
| node-set id( string ) | matches the id inside the parenthesis only works in validated documents, because that's where you get attributes that are id values |
| boolean lang() | returns true if the language of the context node is the same as the passed language parameter |
| boolean last( string ) | returns the index number of the last node in the current node-set
example
|
| literal name | ie: person::text()????? returns true for all nodes <person> if the node test is "person" (if the type is an element) |
| string local-name( nodeset? ) | returns the local part of the name of the first node in the
passed node-set, if no nodeset is passed, the current context node is used
example
|
| string name( nodeset? ) | returns the the name of the first node in the passed node-set,
if no nodeset is passed, the current context node is used
example
|
| string namepace-uri( nodeset? ) | returns the the URI of the first node in the passed node-set,
if no nodeset is passed, the current context node is used
example
|
| string normalize-space( string? ) | returns the the whitespace-normalized version of the passed
string
example
|
| node() | returns true for all nodes except attributes and namespaces |
| boolean not() | returns the inverse of the passed value
example
|
| number number( object? ) | converts a parameter to a number, if nothing is passed, the
current context node is used
example
|
| number position() | gets the position of the current notext node-set returns 1 for the first node in the context node-set |
| processing-instruction( name? ) | true for all processing instruction nodes (no parameters are necessary), but the parameters must match, if you are testing for that, and does the processsing-instruction |
| number round( number ) | rounds a passed number to the nearest integer value
example
|
| string starts-with( string1, string2 ) | returns true if string1 starts with string2 value
example
|
| string string( object? ) | converts the passed object to a string value, if nothing is passed, the result is an empty string |
| string string-length( string? ) | returns the number of characters in the passed string
example
|
| string substring( string, number1, number2 ) | returns the substring between the two numbers passed. (starts
at the first number, and goes to the length of number2) If no number2 is
passed, starts at the number1 and returns the string till the end of the
passed string
example
|
| string substring-after( string1, string2 ) | returns the substring following the first occurence of string2
inside string1
example
|
| string substring-before( string1, string 2) | returns the substring preceding the first occurence of string2
inside string1
example
|
| number sum( node-set ) | returns the sum of allthe nodes in the set
example
|
| string text( string ) | gets the text |
| string translate( string1, string2, string3) | string1 is the string to be changed string2 defines which characters to be changed string3: what those characters should be changed to example
"G" gets dropped because it's listed in string2 and dropped in string3 |
| boolean true() | always returns true, xpath does not have a true or false literal
value
example
|