Description
The functx:is-a-number function returns true if the value is number (can be cast to a numeric type) and is not the value NaN. If the argument is the empty sequence or a zero-length string, it returns false .
Arguments and Return TypeName | Type | Description |
$value |
xs:anyAtomicType? |
the value to test |
return value |
xs:boolean |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:is-a-number" as="xs:boolean"
xmlns:functx="http://www.functx.com">
<xsl:param name="value" as="xs:anyAtomicType?"/>
<xsl:sequence select="
string(number($value)) != 'NaN'
"/>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <in-xml>
<a>123</a>
<b>abc</b>
</in-xml> |
| </xsl:variable> |
XPath Example | Results |
---|
functx:is-a-number('123') |
true |
functx:is-a-number(123) |
true |
functx:is-a-number(' 123 ') |
true |
functx:is-a-number('') |
false |
functx:is-a-number('123abc') |
false |
functx:is-a-number('NaN') |
false |
functx:is-a-number($in-xml/a) |
true |
functx:is-a-number($in-xml/b) |
false |
See Alsofn:number | Converts a value or a node to a number |
History |
Recommended Reading:
|