的自定义格式

发布于 2024-11-18 14:57:20 字数 425 浏览 4 评论 0原文

是否可以为 定义自定义格式?

我有这样的情况:需要标准的基于字母的格式,但字母表中的某些字符是被禁止的(奇怪的要求,但这是客户所要求的)。例如,不能使用字母 i,因此当使用 时,我应该得到序列:a, b, c, d, e, f , g, h, j, k, ..., aa, ab, ..., ah, aj, ...

该项目使用 XSLT 2.0 和 Saxon,因此如果存在特定于 Saxon 的解决方案,即好的。

XSLT 2.0 是否提供定义自定义格式序列的功能? Saxon 是否提供注册自定义序列以与 一起使用的功能?

Is it possible to define a custom format for <xsl:number>?

I have the case where a standard alpha-based format is desired, but certain characters in the alphabet are forbidden (strange requirement, but it is what the client requires). For example, the letter i cannot be used, so when using <xsl:number> I should get the sequence: a, b, c, d, e, f, g, h, j, k, ..., aa, ab, ..., ah, aj, ...

The project is using XSLT 2.0 and Saxon, so if a solution exists that is specific to Saxon, that is okay.

Does XSLT 2.0 provide the capability to define a custom format sequence? Does Saxon provide a capability to register a custom sequence for use with <xsl:number>?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

因为看清所以看轻 2024-11-25 14:57:20

XSLT 2.0 为 xsl:number 提供了 format 属性,您可以通过该属性使用格式标记 aa。计算出的数字取决于 value 属性内计算的表达式,并将根据 format 进行格式化。

鉴于此,您可以考虑首先评估正确的数字序列,排除那些与特定字母匹配的数字。

例如,以下指令:

  <xsl:number value="$sequence" format="aa"/>

将打印(注意排除了 i):

 a.b.c.d.e.f.g.h.j.k.l.m

if $sequence 计算结果为(注意跳过了 9):

1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13

注意,如果您有 12 个元素,您的表达式应该能够跳过不需要的数字(i 为 9)并增加 1 个元素。位置为 12 的最后一个元素应该有相应的数字 13。

所以你需要的只是计算所需序列的算法;这绝对取决于您的输入文档。

参考文献:XSLT 2.0 建议

XSLT 2.0 provides the format attribute for xsl:number by which you can use the format token aa for example. The computed number depends by the expression evaluated inside value attribute and will be formatted accordingly to format.

Given this, you can think of first evaluating the correct sequence of numbers excluding those that will match for a particular letter.

For instance, the following instruction:

  <xsl:number value="$sequence" format="aa"/>

will print (notice i excluded):

 a.b.c.d.e.f.g.h.j.k.l.m

if $sequence evaluates to (notice 9 skipped):

1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13

Notice that if you have 12 elements your expression should be able to skip the unwanted number (9 for i) and increase the following of one. The last element with position 12, should have corresponding number 13.

So what you need, is just the algorithm that computes the wanted sequence; which depends definitely from your input document.

References: XSLT 2.0 Rec.

怀念你的温柔 2024-11-25 14:57:20

您可以通过编写接口 net.sf.saxon.lib.Numberer 的实现来自定义 Saxon 中 xsl:number 的输出:您可能希望将其设为 net.sf.saxon.expr.number.Numberer_en 的子类。您需要研究源代码并找出需要覆盖的内容。

在 Saxon PE/EE 中,您可以在 Saxon 配置文件中注册用于给定语言的编号器。对于 Saxon HE,它需要更多的工作:您必须实现 LocalizerFactory 接口并使用配置注册您的 LocalizerFactory。

You can customize the output of xsl:number in Saxon by writing an implementation of the interface net.sf.saxon.lib.Numberer: probably you will want to make this a subclass of net.sf.saxon.expr.number.Numberer_en. You'll need to study the source code and work out what needs overriding.

In Saxon PE/EE you can register the Numberer to be used for a given language in the Saxon configuration file. For Saxon HE it requires a bit more work: you have to implement the interface LocalizerFactory and register your LocalizerFactory with the Configuration.

被你宠の有点坏 2024-11-25 14:57:20

编辑:存在一个替代的、更通用的解决方案,并作为单独的答案发布。我留下这个答案,因为它对某些人来说可能仍然有价值。

我喜欢@empo的想法(我对其进行了修改),但我认为可能很难找到可行的解决方案。需要一个聪明的算法/方程来根据原始序列得出正确的序列号,以避免获得不包含禁止字符的标签。这时,我忘记了这样的算法。

我想出的一种方法是创建自己的函数,而不是使用 。本质上,我们正在处理一个基数 23 的集合,即字母 az,但不包括字符 il< /code> 和 o。我想出的函数最多只能达到 zz,但这应该足以满足需要(提供最多 552 个项目的标签)。

<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:ewh="http://www.earlhood.com/XSL/Transform"
                exclude-result-prefixes="#all">

<xsl:output method="xml" indent="yes"/>

<xsl:variable name="letters" select="'abcdefghjkmnpqrstuvwxyz'"/>
<xsl:variable name="lbase" select="23"/>

<xsl:function name="ewh:get-alpha-label" as="xs:string">
  <xsl:param name="number" as="xs:integer"/>
  <xsl:variable name="quotient" select="$number idiv $lbase"/>
  <xsl:variable name="remainder" select="$number mod $lbase"/>
  <xsl:variable name="p1">
    <xsl:choose>
      <xsl:when test="($quotient gt 0) and ($remainder = 0)">
        <xsl:value-of select="substring($letters,($quotient - 1),1)"/>
      </xsl:when>
      <xsl:when test="($quotient gt 0) and ($remainder gt 0)">
        <xsl:value-of select="substring($letters,$quotient,1)"/>
      </xsl:when>
      <xsl:otherwise/>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="p0">
    <xsl:choose>
      <xsl:when test="$remainder = 0">
        <xsl:value-of select="substring($letters,$lbase,1)"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="substring($letters,$remainder,1)"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:value-of select="concat($p1,$p0)"/>
</xsl:function>

<xsl:template match="/">
  <result>
    <value n="9"><xsl:value-of select="ewh:get-alpha-label(9)"/></value>
    <value n="12"><xsl:value-of select="ewh:get-alpha-label(12)"/></value>
    <value n="15"><xsl:value-of select="ewh:get-alpha-label(15)"/></value>
    <value n="23"><xsl:value-of select="ewh:get-alpha-label(23)"/></value>
    <value n="26"><xsl:value-of select="ewh:get-alpha-label(26)"/></value>
    <value n="33"><xsl:value-of select="ewh:get-alpha-label(33)"/></value>
    <value n="46"><xsl:value-of select="ewh:get-alpha-label(46)"/></value>
    <value n="69"><xsl:value-of select="ewh:get-alpha-label(69)"/></value>
    <value n="70"><xsl:value-of select="ewh:get-alpha-label(70)"/></value>
    <value n="200"><xsl:value-of select="ewh:get-alpha-label(200)"/></value>
    <value n="552"><xsl:value-of select="ewh:get-alpha-label(552)"/></value>
  </result>
</xsl:template>

</xsl:stylesheet>

当我执行上面的代码时,我得到以下输出:

<result>
   <value n="9">j</value>
   <value n="12">n</value>
   <value n="15">r</value>
   <value n="23">z</value>
   <value n="26">ac</value>
   <value n="33">ak</value>
   <value n="46">az</value>
   <value n="69">bz</value>
   <value n="70">ca</value>
   <value n="200">hs</value>
   <value n="552">zz</value>
</result>

如果 XSLT 能够提供定义与 一起使用的自定义字符序列的功能,那就太好了。似乎这样的功能可以概括 而不依赖于自定义扩展,我不知道是否有任何 XSLT 引擎提供 代码>.

EDIT: An alternate, more general, solution exists and is posted as a separate answer. I'm leaving this answer since it still may be of value to some.

I like @empo's thinking (I mod'ed it up), but I think it may be hard to get a working solution. A clever algorithm/equation is required to come up with the correct sequence number based on the raw sequence to avoid getting a label that does not contain the forbidden characters. At this time, such an algorithm escapes me.

One method I came up with is to create my own function, and not use <xsl:number>. In essence, we are dealing with a base 23 set, the letters a to z, but excluding the characters i, l, and o. The function I came up with only goes up to zz, but that should be sufficient for what is needed (provides labelling up to 552 items).

<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:ewh="http://www.earlhood.com/XSL/Transform"
                exclude-result-prefixes="#all">

<xsl:output method="xml" indent="yes"/>

<xsl:variable name="letters" select="'abcdefghjkmnpqrstuvwxyz'"/>
<xsl:variable name="lbase" select="23"/>

<xsl:function name="ewh:get-alpha-label" as="xs:string">
  <xsl:param name="number" as="xs:integer"/>
  <xsl:variable name="quotient" select="$number idiv $lbase"/>
  <xsl:variable name="remainder" select="$number mod $lbase"/>
  <xsl:variable name="p1">
    <xsl:choose>
      <xsl:when test="($quotient gt 0) and ($remainder = 0)">
        <xsl:value-of select="substring($letters,($quotient - 1),1)"/>
      </xsl:when>
      <xsl:when test="($quotient gt 0) and ($remainder gt 0)">
        <xsl:value-of select="substring($letters,$quotient,1)"/>
      </xsl:when>
      <xsl:otherwise/>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="p0">
    <xsl:choose>
      <xsl:when test="$remainder = 0">
        <xsl:value-of select="substring($letters,$lbase,1)"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="substring($letters,$remainder,1)"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:value-of select="concat($p1,$p0)"/>
</xsl:function>

<xsl:template match="/">
  <result>
    <value n="9"><xsl:value-of select="ewh:get-alpha-label(9)"/></value>
    <value n="12"><xsl:value-of select="ewh:get-alpha-label(12)"/></value>
    <value n="15"><xsl:value-of select="ewh:get-alpha-label(15)"/></value>
    <value n="23"><xsl:value-of select="ewh:get-alpha-label(23)"/></value>
    <value n="26"><xsl:value-of select="ewh:get-alpha-label(26)"/></value>
    <value n="33"><xsl:value-of select="ewh:get-alpha-label(33)"/></value>
    <value n="46"><xsl:value-of select="ewh:get-alpha-label(46)"/></value>
    <value n="69"><xsl:value-of select="ewh:get-alpha-label(69)"/></value>
    <value n="70"><xsl:value-of select="ewh:get-alpha-label(70)"/></value>
    <value n="200"><xsl:value-of select="ewh:get-alpha-label(200)"/></value>
    <value n="552"><xsl:value-of select="ewh:get-alpha-label(552)"/></value>
  </result>
</xsl:template>

</xsl:stylesheet>

When I execute the above, I get the following output:

<result>
   <value n="9">j</value>
   <value n="12">n</value>
   <value n="15">r</value>
   <value n="23">z</value>
   <value n="26">ac</value>
   <value n="33">ak</value>
   <value n="46">az</value>
   <value n="69">bz</value>
   <value n="70">ca</value>
   <value n="200">hs</value>
   <value n="552">zz</value>
</result>

It would be nice of XSLT provided the capability to define a custom character sequence for use with <xsl:number>. Seems like such a capability would generalize <xsl:number> w/o relying on custom extensions, which I do not know if any XSLT engine provides for <xsl:number>.

三生路 2024-11-25 14:57:20

在发布我对问题的原始解决方案后,我提出了以下更通用的解决方案。该解决方案是纯 XSLT,并且在基础上仍然使用 ,因此应该适用于任何格式类型。

<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:ewh="http://www.earlhood.com/XSL/Transform"
                exclude-result-prefixes="#all">

<!-- Description: XSLT to generate a alpha formatted sequence
     label (via <xsl:number>), but disallowing specific characters
     from being used.
  -->

<!-- Algorithm: Given the index value of the item to generate
     a label for via <xsl:number>, we adjust the value so the resulting
     label avoids the use of the forbidden characters.

     This is achieved by converting the index value into a baseX
     number, with X the number of allowed characters.

     The baseX number will be converted into a reverse sequence
     of numbers for each ^E place.  For example, the number 12167
     converted to base23 will generate the following reverse sequence:

       Place:    (23^0, 23^1, 23^2, 23^3)
       Sequence: (   0,    0,    0,    1)   // 1000 in base23

     Having it in right-to-left order makes processing easier.

     Each item in the sequence will be a number from 0 to baseX-1.

     With the sequence, we can then just call <xsl:number> on
     each item and reverse concatenate the result.

     NOTE: Since <xsl:number> does not like 0 as a given value,
     the sequence must be processed so each item is within the
     range of 1-to-baseX.  For example, the above base23 example
     will be translated to the following:

       (23, 22, 22)
  -->

<xsl:output method="xml" indent="yes"/>

<!-- Number of allowed characters: This should be total number of chars of
     format-type desired minus the chars that should be skipped. -->
<xsl:variable name="lbase" select="23"/>
<!-- Sequence of character positions not allowed, with 1=>a to 26=>z -->
<xsl:variable name="lexcs" select="(9,12,15)"/> <!-- i,l,o -->

<!-- Helper Function:
     Convert integer to sequence of number of given base.
     The sequence of numbers is in reverse order: ^0,^1,^2,...^N.
  -->
<xsl:function name="ewh:get_base_digits" as="item()*">
  <xsl:param name="number" as="xs:integer"/>
  <xsl:param name="to"     as="xs:integer"/>
  <xsl:variable name="Q" select="$number idiv $to"/>
  <xsl:variable name="R" select="$number mod $to"/>
  <xsl:sequence select="$R"/>
  <xsl:if test="$Q gt 0">
    <xsl:sequence select="ewh:get_base_digits($Q,$to)"/>
  </xsl:if>
</xsl:function>

<!-- Helper Function:
     Compute carry-overs in reverse-base digit sequence.  XSLT starts
     numbering at 1, so we cannot have any 0s.
  -->
<xsl:function name="ewh:compute_carry_overs" as="item()*">
  <xsl:param name="digits" as="item()*"/>
  <xsl:variable name="d" select="subsequence($digits, 1, 1)"/>
  <xsl:choose>
    <xsl:when test="($d le 0) and (count($digits) = 1)">
      <!-- 0 at end of list, nothing to do -->
    </xsl:when>
    <xsl:when test="$d le 0">
      <!-- If digit <=0, need to perform carry-over operation -->
      <xsl:variable name="next" select="subsequence($digits, 2, 1)"/>
      <xsl:choose>
        <xsl:when test="count($digits) le 2">
          <xsl:sequence select="$lbase + $d"/>
          <xsl:sequence select="ewh:compute_carry_overs($next - 1)"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:sequence select="$lbase + $d"/>
          <xsl:sequence select="ewh:compute_carry_overs(($next - 1,
              subsequence($digits, 3)))"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:when test="count($digits) le 1">
      <xsl:sequence select="$d"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:sequence select="$d"/>
      <xsl:sequence select="ewh:compute_carry_overs(subsequence($digits, 2))"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:function>

<!-- Helper Function:
     Given a number in the base range, determine number for
     purposes of <xsl:number>.  We loop thru the exclusion
     list and add 1 for each exclusion letter that has
     been passed.  The $digit parameter should be a number
     in the range [1..$lbase].
  -->
<xsl:function name="ewh:compute_digit_offset" as="xs:integer">
  <xsl:param name="digit"      as="xs:integer"/>
  <xsl:param name="excludes"   as="item()*"/>
  <xsl:variable name="l" select="subsequence($excludes, 1, 1)"/>
  <xsl:variable name="result">
    <xsl:choose>
      <xsl:when test="$digit lt $l">
        <xsl:value-of select="0"/>
      </xsl:when>
      <xsl:when test="count($excludes) = 1">
        <xsl:value-of select="1"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="rest">
          <xsl:value-of select="ewh:compute_digit_offset($digit+1,
              subsequence($excludes,2))"/>
        </xsl:variable>
        <xsl:value-of select="1 + $rest"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:value-of select="$result"/>
</xsl:function>

<!-- Retrieve alpha sequence label.
     This is the main function to call.
  -->
<xsl:function name="ewh:get-alpha-label" as="xs:string">
  <xsl:param name="number" as="xs:integer"/>
  <xsl:variable name="basedigits"
                select="ewh:get_base_digits($number,$lbase)"/>
  <xsl:variable name="digits"
                select="ewh:compute_carry_overs($basedigits)"/>
  <xsl:variable name="result" as="item()*">
    <xsl:for-each select="$digits">
      <xsl:variable name="digit" select="."/>
      <!-- Should not have any 0 values.  If some reason we do,
           we ignore assuming they are trailing items. -->
      <xsl:if test="$digit != 0">
        <xsl:variable name="value">
          <xsl:value-of select="$digit +
              ewh:compute_digit_offset($digit,$lexcs)"/>
        </xsl:variable>
        <xsl:variable name="number">
          <xsl:number value="$value" format="a"/>
        </xsl:variable>
        <xsl:sequence select="$number"/>
      </xsl:if>
    </xsl:for-each>
  </xsl:variable>
  <xsl:value-of select="string-join(reverse($result),'')"/>
</xsl:function>

<!-- For testing -->
<xsl:template match="/">
  <result>
    <xsl:for-each select="(1 to 1000,12166,12167,12168,279840,279841,279842)">
      <value n="{.}"><xsl:value-of select="ewh:get-alpha-label(.)"/></value>
    </xsl:for-each>
  </result>
</xsl:template>

</xsl:stylesheet>

I came up with the following, more generalized solution, after posting my original solution to the problem. The solution is pure XSLT and at the base, still uses <xsl:number>, so should be applicable to any format type.

<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:ewh="http://www.earlhood.com/XSL/Transform"
                exclude-result-prefixes="#all">

<!-- Description: XSLT to generate a alpha formatted sequence
     label (via <xsl:number>), but disallowing specific characters
     from being used.
  -->

<!-- Algorithm: Given the index value of the item to generate
     a label for via <xsl:number>, we adjust the value so the resulting
     label avoids the use of the forbidden characters.

     This is achieved by converting the index value into a baseX
     number, with X the number of allowed characters.

     The baseX number will be converted into a reverse sequence
     of numbers for each ^E place.  For example, the number 12167
     converted to base23 will generate the following reverse sequence:

       Place:    (23^0, 23^1, 23^2, 23^3)
       Sequence: (   0,    0,    0,    1)   // 1000 in base23

     Having it in right-to-left order makes processing easier.

     Each item in the sequence will be a number from 0 to baseX-1.

     With the sequence, we can then just call <xsl:number> on
     each item and reverse concatenate the result.

     NOTE: Since <xsl:number> does not like 0 as a given value,
     the sequence must be processed so each item is within the
     range of 1-to-baseX.  For example, the above base23 example
     will be translated to the following:

       (23, 22, 22)
  -->

<xsl:output method="xml" indent="yes"/>

<!-- Number of allowed characters: This should be total number of chars of
     format-type desired minus the chars that should be skipped. -->
<xsl:variable name="lbase" select="23"/>
<!-- Sequence of character positions not allowed, with 1=>a to 26=>z -->
<xsl:variable name="lexcs" select="(9,12,15)"/> <!-- i,l,o -->

<!-- Helper Function:
     Convert integer to sequence of number of given base.
     The sequence of numbers is in reverse order: ^0,^1,^2,...^N.
  -->
<xsl:function name="ewh:get_base_digits" as="item()*">
  <xsl:param name="number" as="xs:integer"/>
  <xsl:param name="to"     as="xs:integer"/>
  <xsl:variable name="Q" select="$number idiv $to"/>
  <xsl:variable name="R" select="$number mod $to"/>
  <xsl:sequence select="$R"/>
  <xsl:if test="$Q gt 0">
    <xsl:sequence select="ewh:get_base_digits($Q,$to)"/>
  </xsl:if>
</xsl:function>

<!-- Helper Function:
     Compute carry-overs in reverse-base digit sequence.  XSLT starts
     numbering at 1, so we cannot have any 0s.
  -->
<xsl:function name="ewh:compute_carry_overs" as="item()*">
  <xsl:param name="digits" as="item()*"/>
  <xsl:variable name="d" select="subsequence($digits, 1, 1)"/>
  <xsl:choose>
    <xsl:when test="($d le 0) and (count($digits) = 1)">
      <!-- 0 at end of list, nothing to do -->
    </xsl:when>
    <xsl:when test="$d le 0">
      <!-- If digit <=0, need to perform carry-over operation -->
      <xsl:variable name="next" select="subsequence($digits, 2, 1)"/>
      <xsl:choose>
        <xsl:when test="count($digits) le 2">
          <xsl:sequence select="$lbase + $d"/>
          <xsl:sequence select="ewh:compute_carry_overs($next - 1)"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:sequence select="$lbase + $d"/>
          <xsl:sequence select="ewh:compute_carry_overs(($next - 1,
              subsequence($digits, 3)))"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:when test="count($digits) le 1">
      <xsl:sequence select="$d"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:sequence select="$d"/>
      <xsl:sequence select="ewh:compute_carry_overs(subsequence($digits, 2))"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:function>

<!-- Helper Function:
     Given a number in the base range, determine number for
     purposes of <xsl:number>.  We loop thru the exclusion
     list and add 1 for each exclusion letter that has
     been passed.  The $digit parameter should be a number
     in the range [1..$lbase].
  -->
<xsl:function name="ewh:compute_digit_offset" as="xs:integer">
  <xsl:param name="digit"      as="xs:integer"/>
  <xsl:param name="excludes"   as="item()*"/>
  <xsl:variable name="l" select="subsequence($excludes, 1, 1)"/>
  <xsl:variable name="result">
    <xsl:choose>
      <xsl:when test="$digit lt $l">
        <xsl:value-of select="0"/>
      </xsl:when>
      <xsl:when test="count($excludes) = 1">
        <xsl:value-of select="1"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="rest">
          <xsl:value-of select="ewh:compute_digit_offset($digit+1,
              subsequence($excludes,2))"/>
        </xsl:variable>
        <xsl:value-of select="1 + $rest"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:value-of select="$result"/>
</xsl:function>

<!-- Retrieve alpha sequence label.
     This is the main function to call.
  -->
<xsl:function name="ewh:get-alpha-label" as="xs:string">
  <xsl:param name="number" as="xs:integer"/>
  <xsl:variable name="basedigits"
                select="ewh:get_base_digits($number,$lbase)"/>
  <xsl:variable name="digits"
                select="ewh:compute_carry_overs($basedigits)"/>
  <xsl:variable name="result" as="item()*">
    <xsl:for-each select="$digits">
      <xsl:variable name="digit" select="."/>
      <!-- Should not have any 0 values.  If some reason we do,
           we ignore assuming they are trailing items. -->
      <xsl:if test="$digit != 0">
        <xsl:variable name="value">
          <xsl:value-of select="$digit +
              ewh:compute_digit_offset($digit,$lexcs)"/>
        </xsl:variable>
        <xsl:variable name="number">
          <xsl:number value="$value" format="a"/>
        </xsl:variable>
        <xsl:sequence select="$number"/>
      </xsl:if>
    </xsl:for-each>
  </xsl:variable>
  <xsl:value-of select="string-join(reverse($result),'')"/>
</xsl:function>

<!-- For testing -->
<xsl:template match="/">
  <result>
    <xsl:for-each select="(1 to 1000,12166,12167,12168,279840,279841,279842)">
      <value n="{.}"><xsl:value-of select="ewh:get-alpha-label(.)"/></value>
    </xsl:for-each>
  </result>
</xsl:template>

</xsl:stylesheet>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文