带有备用组分隔符的 xslt 2.0 格式数字重复模式
xslt 2.0 format-number repeating pattern with alternate group-separator
我试图理解为什么 XSLT 2.0
在尝试为 format-number
函数提供备用 grouping-separator
时重复以下模式,如下所示:
<xsl:decimal-format grouping-separator="-" name="hyphenFormatting"/>
<xsl:template match="/">
<xsl:value-of select="format-number(642120, '####-##', 'hyphenFormatting')"/>
</xsl:template>
输出:64-21-20
当我预期输出为:6421-20
有没有一种方法可以绕过这种模式重复,以便它从字面上评估我的掩码?
您使用的是 Saxon 吗?使用 Saxon 9.8,我得到了与您相同的行为。
规范在 2.0 和 3.0 之间重新表述。在 2.0 中它说:
In addition, if these integer-part-grouping-positions are at regular
intervals (that is, if they form a sequence N, 2N, 3N, ... for some
integer value N, including the case where there is only one number in
the list), then the sequence contains all integer multiples of N as
far as necessary to accommodate the largest possible number.
而 3.0 表示如下(第三条规则是新的):
The grouping is defined to be regular if the following conditions
apply:
There is an least one grouping-separator in the integer part of the sub-picture.
There is a positive integer G (the grouping size) such that the position of every grouping-separator in the integer part of the
sub-picture is a positive integer multiple of G.
Every position in the integer part of the sub-picture that is a positive integer multiple of G is occupied by a grouping-separator.
If the grouping is regular, then the integer-part-grouping-positions sequence contains all integer
multiples of G as far as necessary to accommodate the largest possible
number.
因此您的分组在 2.0 定义下是规则的,但在 3.0 定义下不是。 Saxon 显然正在执行 2.0 定义。我怀疑此更改旨在作为错误修复,但 Saxon 似乎尚未实施此更改。
作为解决方法,您可以将图片定义为
#-###############################################-##
额外的分组分隔符放在最左边,你永远不会有这么大的数字。
(在这里提出了一个撒克逊问题:https://saxonica.plan.io/issues/3669)
我试图理解为什么 XSLT 2.0
在尝试为 format-number
函数提供备用 grouping-separator
时重复以下模式,如下所示:
<xsl:decimal-format grouping-separator="-" name="hyphenFormatting"/>
<xsl:template match="/">
<xsl:value-of select="format-number(642120, '####-##', 'hyphenFormatting')"/>
</xsl:template>
输出:64-21-20
当我预期输出为:6421-20
有没有一种方法可以绕过这种模式重复,以便它从字面上评估我的掩码?
您使用的是 Saxon 吗?使用 Saxon 9.8,我得到了与您相同的行为。
规范在 2.0 和 3.0 之间重新表述。在 2.0 中它说:
In addition, if these integer-part-grouping-positions are at regular intervals (that is, if they form a sequence N, 2N, 3N, ... for some integer value N, including the case where there is only one number in the list), then the sequence contains all integer multiples of N as far as necessary to accommodate the largest possible number.
而 3.0 表示如下(第三条规则是新的):
The grouping is defined to be regular if the following conditions apply:
There is an least one grouping-separator in the integer part of the sub-picture.
There is a positive integer G (the grouping size) such that the position of every grouping-separator in the integer part of the sub-picture is a positive integer multiple of G.
Every position in the integer part of the sub-picture that is a positive integer multiple of G is occupied by a grouping-separator.
If the grouping is regular, then the integer-part-grouping-positions sequence contains all integer multiples of G as far as necessary to accommodate the largest possible number.
因此您的分组在 2.0 定义下是规则的,但在 3.0 定义下不是。 Saxon 显然正在执行 2.0 定义。我怀疑此更改旨在作为错误修复,但 Saxon 似乎尚未实施此更改。
作为解决方法,您可以将图片定义为
#-###############################################-##
额外的分组分隔符放在最左边,你永远不会有这么大的数字。
(在这里提出了一个撒克逊问题:https://saxonica.plan.io/issues/3669)