home contribute faq download

FunctX XSLT Functions

functx:min-non-empty-string

The minimum of a sequence of strings, ignoring "empty" values

Google
Webdatypic.com

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

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

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:min-non-empty-string" as="xs:string?"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="strings" as="xs:string*"/>

  <xsl:sequence select="
   min($strings[. != ''])
 "/>

</xsl:function>

Examples

<xsl:variable name="in-xml" as="item()*">
<authors>
   <author>
      <fName/>
      <lName>Smith</lName>
   </author>
   <author>
      <fName>Kate</fName>
      <lName>Jones</lName>
   </author>
   <author>
      <fName>John</fName>
      <lName>Doe</lName>
   </author>
</authors>
</xsl:variable>
XPath ExampleResultsExplanation
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:minThe minimum of a sequence of values
functx:min-stringThe minimum of a sequence of values, treating them like strings

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, https://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery