Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 根据上下文选择子字符串_Xslt - Fatal编程技术网

Xslt 根据上下文选择子字符串

Xslt 根据上下文选择子字符串,xslt,Xslt,我有这段XML,希望在章节之后立即获得编号 <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

我有这段XML,希望在
章节之后立即获得编号

<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>
但是我只想要
6

请告诉我该怎么做

我不想用这种说法

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

因为每种情况下的章节号都会有所不同,介于1和15之间。

尝试以下方法:

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

这是基于:感谢 @迪米特里·诺瓦切夫

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

<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')
     , ' ','')"/>

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