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

しかし、私はちょうど欲しいです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 に答える