home contribute faq download

FunctX XSLT Functions

fn:min

The minimum of a sequence of values

Google
Webdatypic.com

Description

The fn:min function finds the minimum of a sequence of values. The $arg sequence can only contain values of one type, or a type derived from it. The one exception is that they can be all numeric, in which case numeric promotion rules apply. That type must be ordered; it must be possible to compare the values using the < and > operators.

The fn:min function assumes untyped values are numeric unless they are explicitly cast to xs:string. To treat untyped data as strings, use the fn:string function as shown in the last example below.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameTypeDescription
$arg xs:anyAtomicType* the sequence of values
$collation xs:string the collation to use for comparing strings
return value xs:anyAtomicType?

Examples

<xsl:variable name="ordDoc" select="doc('https://www.datypic.com/functx./input/order.xml')"/>
XPath ExampleResults
min( (2.0, 1, 3.5, 4) )
1
min( ('a', 'b', 'c') )
a
min($ordDoc//item/@color) 
Error FORG0006, if color is untyped
min($ordDoc//item//string(@color))
zero-length string
min($ordDoc//item/@color/string(.))
beige

See Also

functx:min-determine-typeThe minimum value in a sequence, figuring out its type (numeric or string)
functx:min-nodeThe XML node whose typed value is the minimum
functx:min-stringThe minimum of a sequence of values, treating them like strings
functx:min-non-empty-stringThe minimum of a sequence of strings, ignoring "empty" values
fn:maxThe maximum of a sequence of values

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading:

XQuery