Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml XSLT将带空格的字符串数字转换为数字_Xml_Xslt - Fatal编程技术网

Xml 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

我对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"?>
<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(.), ' ', ''))