【发布时间】:2016-09-21 13:39:25
【问题描述】:
在 XSLT 中是否有一些函数或一些东西来允许低格式数字 比如 1 会变成 01
如果我有
<a>10</a>
<b>5</b>
它们会显示为
A10
and
B05
【问题讨论】:
-
A”和“B”字符应该从哪里来?
在 XSLT 中是否有一些函数或一些东西来允许低格式数字 比如 1 会变成 01
如果我有
<a>10</a>
<b>5</b>
它们会显示为
A10
and
B05
【问题讨论】:
<xsl:template match="root/*">
<xsl:value-of select="format-number(.,'00')"/>
</xsl:template>
XSLT 1.0 大写的节点名:
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:value-of select="translate(name(), $smallcase, $uppercase)" />
综合:
<xsl:value-of select="concat(translate(name(), $smallcase, $uppercase), format-number(.,'00'))" />
【讨论】:
format-number(5, '00')
返回“05”。
同样,
format-number(10, '00')
返回“10”。
【讨论】: