English | Français | Deutsch | Magyar | >> 中文 << | Polski ZVON > Tutorials > XSLT Tutorial
>> 页 42 << | 上一条 | 下一条 | 目录 | 元素索引

测试,看元素的值是否是数字。

XSLT stylesheet 1

XML源码
<source>

<number>253</number>
<number>sd12</number>
<number>-64</number>
<number>2.25.25</number>
<number>2.25</number>

</source>

输出
<DIV>253</DIV>

<DIV>sd12 is not a number</DIV>

<DIV>-64</DIV>

<DIV>2.25.25 is not a number</DIV>

<DIV>2.25</DIV>

用HTML察看
253
sd12 is not a number
-64
2.25.25 is not a number
2.25
XSLT stylesheet
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="number">
     <DIV>
          <xsl:value-of select="."/>
          <xsl:if test="string(number(.))='NaN'"> is not a number</xsl:if>
     </DIV>
</xsl:template>


</xsl:stylesheet>