Converts the argument to a number.
number number(object?)
Converts its argument to a number as follows.
If the argument is omitted, it defaults to a node-set with the context node as its only member.
Note Thenumber()
function should not be used for conversion of numeric data occurring in an element in an XML document unless the element is of a type that represents numeric data in a language-neutral format (that would typically be transformed into a language-specific format for presentation to a user). In addition, thenumber()
function cannot be used unless the language-neutral format used by the element is consistent with the XML Path Language (XPath) syntax for a number.
XML File
None; the XSLT file calls itself.
XSLT File (number.xsl)
<?xml version='1.0'?> <?xml-stylesheet type="text/xsl" href="number.xsl"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html> <body> <h3>number() Function</h3> <ul> <li> <b>number('2048')</b> = <xsl:value-of select="number('2048')"/> </li> <li> <b>number('-2048')</b> = <xsl:value-of select="number('-2048')"/> </li> <li> <b>number('text')</b> = <xsl:value-of select="number('text')"/> </li> <li> <b>number('109.54' div '1')</b> = <xsl:value-of select="number('109.54' div '1')"/> </li> </ul> </body> </html> </xsl:template> </xsl:stylesheet>
Formatted Output
number() Function
Processor Output
<html><body><h3>number() Function</h3><ul><li><b>number('2048')</b> = 2048</li><li><b>number('-2048')</b> = 2048</li><li><b>number('text')</b> = NaN</li><li><b>number('109.54')</b> = 109.54</li></ul></body></html>
Data Types in Schemas | XDR Schema Data Types Reference | XML Data Types Reference