使用 xslt1.0 的 .csv 数字格式 [英] number format for .csv using xslt1.0
本文介绍了使用 xslt1.0 的 .csv 数字格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 xml 中有标记,有时值为 -ve 数字,有时值为 +ve 数字,我想将 -ve(例如 -10)数字显示为 (10) 我的意思是使用 xslt1.0 使用括号.
I have tag in xml which value sometimes -ve number and sometimes +ve number and I want to show the -ve(e.g -10) number as (10) I mean with bracket using xslt1.0.
你能帮我吗?
我正在使用以下模板,但它不起作用.
I am using below template but it is not working.
<xsl:call-template name="fmtNumber">
<xsl:with-param name="amt" select="retailer:Amount" />
</xsl:call-template>
<xsl:template name="fmtNumber">
<xsl:param name="amt" />
<xsl:value-of
select="format-number($amt, ' $###,##0 ;($###,##0)')" />
</xsl:template>
它在 csv 文件中将结果显示为 $(10) 但是,我想要 (10),我的意思是没有美元 sumbol.
it is showing the result in csv file as $(10) but, I want (10), I mean without dollar sumbol.
推荐答案
请在您的处理器上运行以下样式表(带有任何 XML 源)并发布结果代码.
Please run the following stylesheet (with any XML source) on your processor and post the resulting code.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="num" select="-123" />
<xsl:template match="/">
<result>
<version><xsl:value-of select="system-property('xsl:version')"/></version>
<vendor><xsl:value-of select="system-property('xsl:vendor')"/></vendor>
<test><xsl:value-of select="format-number($num, '#,##0;(#,##0)')"/></test>
</result>
</xsl:template>
</xsl:stylesheet>
这篇关于使用 xslt1.0 的 .csv 数字格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文