home contribute faq download

FunctX XQuery Functions

functx:min-string

The minimum of a sequence of values, treating them like strings

Google
Webxqueryfunctions.com

Description

The functx:min-string function returns the minimum of the values in $strings. It differs from the built-in fn:min function only in treats values of all types like strings. The fn:min function, by contrast, treats untyped and numeric values like numbers (and an error is raised if they are not numbers).

Arguments and Return Type

NameTypeDescription
$strings xs:anyAtomicType* the sequence of strings
return value xs:string?

XQuery Function Declaration

See XSLT definition.
XQuery Syntax for January 2007 (1.0):
declare namespace functx = "http://www.functx.com"; 
declare function functx:min-string 
  ( $strings as xs:anyAtomicType* )  as xs:string? {
       
   min(for $string in $strings return string($string))
 } ;
XQuery Syntax for July 2004 - November 2005 (CR):
declare namespace functx = "http://www.functx.com"; 
declare function functx:min-string 
  ( $strings as xdt:anyAtomicType* )  as xs:string? {
       
   min(for $string in $strings return string($string))
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function min-string 
  ( $strings as xdt:anyAtomicType* )  as xs:string? {
       
   fn:min(for $string in $strings return fn:string($string))
 }

Examples

let $in-xml :=
<in-xml>
  <x>a</x>
  <y>c</y>
  <z>b</z>
</in-xml>
return
XQuery ExampleResultsExplanation
functx:min-string( $in-xml/* )
a
Calling the fn:min function instead would have raised an error.
functx:min-string( (100,25,3) )
100

See Also

fn:minThe minimum of a sequence of values
functx:min-non-empty-stringThe minimum of a sequence of strings, ignoring "empty" values
functx:min-determine-typeThe minimum value in a sequence, figuring out its type (numeric or string)
functx:max-stringThe maximum of a sequence of values, treating them like strings

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley