0

我有以下 xml 文档。

<chapter>
    <para>
        <phrase>3.006</phrase> Parties may agree to undergo a particular ADR technique in the event of a dispute between them by entering into an ADR agreement. There are a number of ADR procedures to choose from. The procedure may involve only the parties to the dispute (such as negotiation), or may involve an independent third party. The third party may facilitate the parties&#x2019; own consensual resolution of the dispute (as in mediation/conciliation), or the third party may give an opinion on the issues in dispute (as is usually the case with a Dispute Review Board). The third party may produce a binding decision (such as adjudication) or a non-binding decision (such as expert determination). These various ADR techniques will be discussed (in paras.3.007-3.111) below. They can be compared with partnering which involves dispute avoidance (see paras.3.112 to 3.127), and the more traditional arbitration and litigation (see paras.3.128 to 3.172).
    </para>
    <para>
        <phrase>3.008</phrase> It may be stating the obvious, but negotiation can (and should) be used on its own to resolve a dispute. In fact, many dispute resolution clauses in commercial contracts require the parties to try to resolve disputes between them by negotiation prior to the initiation of any arbitration or legal proceedings. A common dispute resolution clause will use words to the effect of &#x201C;the parties shall use their best efforts in good faith to reach a reasonable and equitable resolution&#x201D; (the concept of good faith negotiation will be discussed further in para.3.020 below). Alternatively, negotiation can be used as a facilitating technique in one of the many other methods of dispute resolution. It is of particular importance in mediation or conciliation (which is discussed in para.3.027 below).
    </para>
    <para>Arbitration agreements are discussed in more detail in Chapter 9.</para>
</chapter>

这里实际上我想要一个将数字转换为超链接的 xslt,如下所示。

Case1:
如果找到类似的东西3.128,则应将其转换为

<a href="er:#AHK_CH_03/P03-128">3.128</a> 

情况2:
如果找到类似Chapter 9的东西,应该将其转换为

<a href="er:#AHK_CH_18>Chapter 9</a>.

请让我知道我该怎么做。

谢谢。

4

1 回答 1

1

使用 XSLT 2.0,我们可以生成给定的 XSLT 以获得所需的输出:

XSLT:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="text()">
    <xsl:analyze-string select="." regex="(([Cc]hapter)\s(\d+))">
      <xsl:matching-substring>
        <a href="{concat('er:#AHK_CH_',regex-group(3))}">
          <xsl:value-of select="."/>
        </a>
      </xsl:matching-substring>
      <xsl:non-matching-substring>
        <xsl:analyze-string select="." regex="([0-9])\.([0-9]+)">
          <xsl:matching-substring>
            <a
              href="{concat('er:#AHK_CH_',format-number(number(regex-group(1)),'00'),'/P',format-number(number(regex-group(1)),'00'),'-',regex-group(2))}">
              <xsl:value-of select="."/>
            </a>
          </xsl:matching-substring>
          <xsl:non-matching-substring>
            <xsl:value-of select="."/>
          </xsl:non-matching-substring>
        </xsl:analyze-string>
      </xsl:non-matching-substring>
    </xsl:analyze-string>
  </xsl:template>

</xsl:stylesheet>

输出:

    <a href="er:#AHK_CH_03/P03-006">3.006</a> Parties may agree to undergo a particular ADR technique in the event of a dispute between them by entering into an ADR agreement. There are a number of ADR procedures to choose from. The procedure may involve only the parties to the dispute (such as negotiation), or may involve an independent third party. The third party may facilitate the parties’ own consensual resolution of the dispute (as in mediation/conciliation), or the third party may give an opinion on the issues in dispute (as is usually the case with a Dispute Review Board). The third party may produce a binding decision (such as adjudication) or a non-binding decision (such as expert determination). These various ADR techniques will be discussed (in paras.<a href="er:#AHK_CH_03/P03-007">3.007</a>-<a href="er:#AHK_CH_03/P03-111">3.111</a>) below. They can be compared with partnering which involves dispute avoidance (see paras.<a href="er:#AHK_CH_03/P03-112">3.112</a> to <a href="er:#AHK_CH_03/P03-127">3.127</a>), and the more traditional arbitration and litigation (see paras.<a href="er:#AHK_CH_03/P03-128">3.128</a> to <a href="er:#AHK_CH_03/P03-172">3.172</a>).


    <a href="er:#AHK_CH_03/P03-008">3.008</a> It may be stating the obvious, but negotiation can (and should) be used on its own to resolve a dispute. In fact, many dispute resolution clauses in commercial contracts require the parties to try to resolve disputes between them by negotiation prior to the initiation of any arbitration or legal proceedings. A common dispute resolution clause will use words to the effect of “the parties shall use their best efforts in good faith to reach a reasonable and equitable resolution” (the concept of good faith negotiation will be discussed further in para.<a href="er:#AHK_CH_03/P03-020">3.020</a> below). Alternatively, negotiation can be used as a facilitating technique in one of the many other methods of dispute resolution. It is of particular importance in mediation or conciliation (which is discussed in para.<a href="er:#AHK_CH_03/P03-027">3.027</a> below).

  Arbitration agreements are discussed in more detail in <a href="er:#AHK_CH_9">Chapter 9</a>.
于 2013-05-27T09:24:23.560 回答