0

我有这段 XML 并想在之后立即获得号码Chapter

<para>Insolvency Rules, r 12.12, which gives the court a broad discretion, unfettered by the English equivalent of the heads of Order 11, r 1(1) (which are now to be found, in England, in CPR, Chapter 6, disapplied in the insolvency context by Insolvency Rules, r 12.12(1)). </para>

当我使用这个 XSLT 转换时

<xsl:value-of select="translate(substring-after(current(),'Chapter'), translate(substring-after(current(),'Chapter'),'0123456789',''), '')"/>

我得到这个输出

612121

Butut 我只想要6.

请让我知道我应该怎么做。

我不想使用类似的声明

<xsl:value-of select="substring-before(substring-after(current(),'Chapter'), ,',')"/>

因为每个实例的章节编号都会有所不同,介于 1 到 15 之间。

4

1 回答 1

1

尝试这个:

    <xsl:variable name="vS" select="concat(substring-after(current(),'Chapter '),'Z')"/>
    <xsl:value-of select=
           "substring-before(translate($vS,translate($vS,'0123456789',''),'Z'),'Z')"/>

这是基于:https : //stackoverflow.com/a/4188249/2115381 感谢@Dimitre Novatchev

更新:如果“章节”之后的空间数量未知,您可以使用以下内容:

<xsl:variable name="vS" select="concat(substring-after(current(),'Chapter'),'Z')"/>

<xsl:value-of select=
        " translate(
        substring-before(translate($vS,translate($vS,' 0123456789',''),'Z'),'Z')
     , ' ','')"/>
于 2013-04-30T15:07:28.407 回答