Description
The functx:min-non-empty-string function returns the minimum of the values in $strings, throwing out all zero-length strings. Like the functx:min-string function, it treats untyped values like strings. This is in contrast to the built-in fn:min function, which treats untyped values like numbers (and raises an error if they are not numbers).
The values in $strings must be untyped, or match the type xs:string.
Arguments and Return Type| Name | Type | Description |
$strings |
xs:string* |
the sequence of strings to search |
| return value |
xs:string? |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for July 2004 - January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:min-non-empty-string
( $strings as xs:string* ) as xs:string? {
min($strings[. != ''])
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function min-non-empty-string
( $strings as xs:string* ) as xs:string? {
fn:min($strings[. != ''])
} |
Exampleslet $in-xml := | <authors>
<author>
<fName/>
<lName>Smith</lName>
</author>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>John</fName>
<lName>Doe</lName>
</author>
</authors> | return |
| XQuery Example | Results | Explanation |
|---|
functx:min-non-empty-string( $in-xml//fName )
|
John
|
Calling the functx:min-string function would have returned a zero-length string (""). Calling the fn:min function instead would have raised an error. |
See Also| fn:min | The minimum of a sequence of values | | functx:min-string | The minimum of a sequence of values, treating them like strings |
History |
|