XSLT and XPath function reference in alphabetical order

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z



Functions for sequences


XPath 2.0

Return value:

A sequence in which the order of the items cannot be predetermined due to a possible optimisation by the application.




A sequence which, as a rule, results from the processing of a XPath expression whose processing shall be optimised.

Purpose of use:

The fn:unordered() function accepts a XPath expression which generates a sequence (theoretically also a literal input sequence, see notice) and marks the result sequence as a so-called unordered sequence. This explicitly allows an application to optimise the processing of this XPath expression without having to take into account the order of the items regularly resulting from the expression, for example the order resulting from the document order of the source.

Therefore, the order in which the result sequence is outputted is undetermined (or dependent on the reaction of the application to the respective structure of the queried source).

The use of fn:unordered() makes sense in case the processing of the query may be sped up by it and at the same time the order of the items in the resulting sequence is irrelevant. This is, for example, the case if the sequence shall be sorted afterwards, which means the order is probably not preserved.

Notice: application on a literal sequence is useless!
The application of fn:unordered() on a literal (i.e. directly passed on) input sequence makes little sense since the function outputs it unchanged. So, no random order of the items is generated, as possibly could be expected.

Estimation of the relevance for XSLT:

The fn:unordered() function will probably be rather of importance in the scope of the processing of queries in the mere XQuery context than for XPath in the context of XSLT.

Example – application in XQuery query:

     for $a in $priceList_1/books/book,
         $b in $priceList_2/books/book
         where $a/isbn = $b/isbn
         and $a/price > $b/price
     return <book>{ $a/title, $a/price, $b/price }</book>

This expression (a XQuery query) compares two price lists of books and returns a sequence of those books which are cheaper in list 2 than in list 1. The books to be compared are identified via their (identical) ISBN numbers. The fn:unordered() function gives the application the freedom to optimise the query in every way possible.

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

fn:unordered($sourceSeq as item()*) as item()*


<< back next >>




Copyright © Galileo Press, Bonn 2008
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSLT 2.0 & XPath 2.0" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

Galileo Press, Rheinwerkallee 4, 53227 Bonn, Germany