2
我想删除XSLT中formattedValue属性中的英镑符号(£)。你能帮忙吗?如何从XSLT中的XML特性中删除英镑符号?
<price value="£99.99" formattedValue="£99.99">55.55</price>
我需要的输出 99.99
基本上,需要删除XSLT井号
我想删除XSLT中formattedValue属性中的英镑符号(£)。你能帮忙吗?如何从XSLT中的XML特性中删除英镑符号?
<price value="£99.99" formattedValue="£99.99">55.55</price>
我需要的输出 99.99
基本上,需要删除XSLT井号
使用翻译:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="price">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="price/@formattedValue">
<xsl:attribute name="{name()}">
<xsl:value-of select="translate(., '£', '')"/>
</xsl:attribute>
</xsl:template>
您可以使用该translate()
功能:
translate(@formattedValue, '£', '')
或者,我会在这个特殊的情况下,建议为短,可能更有效率 - 使用substring()
功能:
substring(@formattedValue, 2)
的[要在所有的XSLT版本去掉小数点]可能重复( http://stackoverflow.com/questions/8836850/to-remove-decimal-point-in-all-xslt-versions) – 2012-01-17 06:25:32