Xml XSLT将带空格的字符串数字转换为数字
我对xslt转换有问题。Xml XSLT将带空格的字符串数字转换为数字,xml,xslt,Xml,Xslt,我对xslt转换有问题。 如何将数字“2 402.83”转换为数字。不幸的是,当我使用函数number(字符串()时,我得到了NaN。我尝试使用replace函数number(replace(string(.),'',),但它不返回任何内容(js中的异常:Uncaught TypeError:未能在“Node”上执行“appendChild”:参数1不是“Node”类型) 我的xml: <?xml version="1.0" encoding="UTF-8"?> <catalo
如何将数字“2 402.83”转换为数字。不幸的是,当我使用函数
number(字符串()
时,我得到了NaN。我尝试使用replace函数number(replace(string(.),'',)
,但它不返回任何内容(js中的异常:Uncaught TypeError:未能在“Node”上执行“appendChild”:参数1不是“Node”类型)
我的xml:
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd number="1" price="2 402.82"/>
</catalog>
我的xslt:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="catalog/cd">
<xsl:for-each select="@price">
<span>
<xsl:value-of select="number(replace(string(.),' ', ''))" />
</span>
</xsl:for-each>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT 1.0中没有
replace
功能,请改用translate
:
number(translate(string(.), ' ', ''))