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

fn:min

Category:

Aggregation

Origin:

XPath 2.0

Return value:

A sequence consisting of an atomic item which has the minimum value of all items of the input sequence – after unification of their types.

Call/Arguments:

fn:min($inputSequence?, $collation-URI)

$inputSequence:

A sequence of one or more xs:anyAtomicType atomic items. If the input sequence does not completely consists of items of atomic type, the relevant items are atomised in advance. If the input sequence is empty, the empty sequence is returned.

$collation-URI:

Optional. The second argument consists of a xs:string string which names the URI string of the collation to be used. The value has to lexically correspond to the xs:anyURI type. If no second argument is passed on, the default collation is used for the string comparison.

Purpose of use:

The fn:min() function always returns a sequence of a sole item which has the lowest value of all items of an input sequence passed on to the function. The type of the returned minimum value does not necessarily have to be equal to the type of the corresponding item of the input sequence since the return always occurs after a type unification.

If several or all items have the same minimum value, only one of the relevant items is returned (which one exactly is dependent on the implementation).

If the input sequence is empty, the function returns the empty sequence. An error is not reported. But if exactly this is desired, the existence of a return value can be tested by means of the fn:exactly-one() function (see example 3 of fn:max()).

The items of the input sequence have to be atomic and in a form (referred to as total order) which guarantees their comparability by means of the le operator (»less or equal«). Basically, »total order« means that it must be determinable for two items being recognised as unequal which of the two is greater or less than the other. A basic requirement is that all values have the same type, whereby also subtypes (derived types) of the appropriate types are permitted.

If the items of the input sequence are of xs:untypedAtomic type, they are converted to the number type xs:double.

If the equality of the types and thus the comparability is not guaranteed or cannot be achieved by type conversion, an appropriate error is outputted: »Invalid argument type« (err:FORG0006).

Comparison of numerical values:

The equality of the types of numerical values is also achieved by type promotion (conversion into a superordinated numeric type). If the input sequence contains one or more items of the NaN value, the function returns the NaN value.

Comparison of date and time values:

The comparability of values of the types xs:dateTime, xs:date or xs:time requires the fundamental presence or absence of a timezone indication. If such a value has not an appropriate indication, the implicit timezone indication is added resulting from the evaluation context. The date or time value is – if required – normalised on this basis and used in this form for the comparisons. In case (normalised) minimum values only differ by their timezone indication, it is decided by the implementation which of the values is returned.

Comparison of duration values:

Duration values to be compared all have to be of xs:yearMonthDuration type or of xs:dayTimeDuration type.

Comparison of URI values and strings:

The comparison between xs:anyURI URI values and xs:string character strings is, after the conversion of items of the xs:anyURI type into xs:string, determined by means of a collation. For this purpose, the default collation or the collation determined by the second function argument is used.

In the simplest case the comparison of character strings is made character by character, whereby the following applies:

[0 – 9] < [A – Z] < [a – z]

The vaue passed on for the indication of the collation has to lexically correspond to the xs:anyURI type. If the collation is not supported, the error message »Unsupported collation« (err:FOCH0002) occurs.

In case a collation has been indicated, but the items of the input sequence (after a possible type conversion) do not have the xs:string type, the collation argument is ignored without reporting an error. This happens, for example, in case the input sequence consists of numeric types.

Example 1 – minimum of a numeric sequence:

fn:min((4, 5, 6, 7))

returns: 4 (of xs:integer type).

Example 2 – minimum of a string sequence:

fn:min(('bb','aa','AA'))

returns: 'AA' (of xs:string type).

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

fn:min($arg as xs:anyAtomicType*) as xs:anyAtomicType?

fn:min($arg as xs:anyAtomicType*, $collation as string) as xs:anyAtomicType?

   

<< 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