Chapter 5. Functions

This chapter contains an alphabetical reference of the 36 functions contained in the XPath and XSLT languages. The majority of these come from XPath.

XPath Functions

The XPath recommendation itself groups its 27 functions into four categories, according to their role, as shown in Table 5-1.

Table 5-1. XPath functions

Node-set functions

String functions

Boolean functions

Number functions

last( )

string( )

boolean( )

number( )

position( )

concat( )

not( )

sum( )

count( )

starts-with( )

true( )

floor( )

id( )

contains( )

false( )

ceiling( )

local-name( )

substring-before( )

lang( )

round( )

namespace-uri( )

substring-after( )

  

name( )

substring( )

  
 

string-length( )

  
 

normalize-space( )

  
 

translate( )

  

The only function in XPath 1.0 that returns a node-set is the id( ) function. The rest return a number, string, or boolean.

XSLT Functions

XSLT adds nine functions of its own:

document( )generate-id( )
key( )system-property( )
format-number( )element-available( )
current( )function-available( )
unparsed-entity-uri( ) 

Of these, three return a node-set: document( ), key( ), and current( ). The other functions return a number, string, or boolean.

Data Type Conversions

XSLT and XPath are dynamically typed languages. Whenever it is possible for the XSLT processor to convert a given value to a value of the expected data type, it does so automatically. The particular rules for converting to each of the four XPath data types are described next.

Tip

When being converted to another data type, result ...

Get XSLT 1.0 Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.