Xslt 未正确创建定位标记

Xslt 未正确创建定位标记,xslt,Xslt,嗨,我有下面的xslt用于创建锚定标记 <xsl:template match="para/text()"> <xsl:variable name="numx"> <xsl:number format="1" level="any"/> </xsl:variable> <xsl:choose> <xsl:when test="(contains(substring(substring-after(current(

嗨,我有下面的xslt用于创建锚定标记

    <xsl:template match="para/text()">

<xsl:variable name="numx">
<xsl:number format="1" level="any"/>
</xsl:variable>
<xsl:choose>
    <xsl:when test="(contains(substring(substring-after(current(),'.'),4,1),')')  or contains(substring(substring-after(current(),'.'),4,1),'.') or contains(substring(substring-after(current(),'.'),4,1),' ')) and (contains(substring (current(),string-length(substring-before(current(), '.')) -1,2),' ')) and contains(substring(current(),string-length(substring-before(current(), '.')) -2,1),$numx)">


<xsl:variable name="before">
<xsl:value-of select="normalize-space(substring(current(),string-length(substring-before(current(), '.')) -1,2))"/>
</xsl:variable>

<xsl:variable name="NewN">
    <xsl:value-of select="concat('0',$before)"/>
</xsl:variable>
<xsl:variable name="after">
<xsl:value-of select="substring(substring-after(current(),'.'),1,3)"/>
</xsl:variable>

<xsl:variable name="befdNumb">
<xsl:value-of select="substring-before(current(),$before)"/>
</xsl:variable>



<xsl:variable name="aftdNumb">
<xsl:value-of select="substring-after(current(),$after)"></xsl:value-of>
</xsl:variable>


    <xsl:value-of select="$befdNumb"/>
<xsl:text> </xsl:text>
    <a href="{concat('er:#CLI_CH_',$NewN,'/','P',normalize-space($before),'-',$after)}">

        <xsl:value-of select="concat(normalize-space($before),'.',$after)"/>
    </a>    
       <xsl:value-of select="$aftdNumb"/>
    </xsl:when>



    <xsl:when test="(contains(substring(substring-after(current(),'.'),4,1),')')  or contains(substring(substring-after(current(),'.'),4,1),'.') or contains(substring(substring-after(current(),'.'),4,1),' ')) and contains(substring (current(),string-length(substring-before(current(), '.')) -2,1),' ')">
<xsl:variable name="before">
<xsl:value-of select="substring(current(),string-length(substring-before(current(), '.')) -2,3)"/>
</xsl:variable>

<xsl:variable name="NewN">
    <xsl:value-of select="$before"/>
</xsl:variable>
<xsl:variable name="after">
<xsl:value-of select="substring(substring-after(current(),'.'),1,3)"/>
</xsl:variable>

<xsl:variable name="befdNumb">
<xsl:value-of select="substring-before(current(),$before)"/>
</xsl:variable>



<xsl:variable name="aftdNumb">
<xsl:value-of select="substring-after(current(),$after)"></xsl:value-of>
</xsl:variable>

<xsl:value-of select="$befdNumb"/>
        <xsl:text> </xsl:text>
    <a href="{concat('er:#CLI_CH_',$NewN,'/','P',normalize-space($before),'-',$after)}">

        <xsl:value-of select="concat(normalize-space($before),'.',$after)"/>
    </a>

    <xsl:value-of select="$aftdNumb"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="."/>
    </xsl:otherwise>
</xsl:choose>
</xsl:template> 

但是这个xslt正在得到应用,也就是说,如果文本如下所示,就会创建锚定标记(在整个文本中只有“.”)

通过下文第12.012段讨论的方式之一,向公司送达债权人签署的要求书

但我希望它也适用于以下文本

<para>the major issues here concern the notion of principal and ancillary jurisdictions, the ideal being that the ancillary jurisdiction will defer to the principal jurisdiction on most important matters, with a view to bringing about a just, practical and economically rational winding-up of affairs. A relatively recent development in connection with that ideal concerns the judicial promotion of court-endorsed agreements known as "crossborder protocols" between liquidators and similar officers appointed in different jurisdictions. It is important in this context, however, not to lose sight of the fact that certain matters of "administration" always remain governed by Hong Kong law. See paragraphs 12.016 to 12.032 below.</para>
这里的主要问题涉及主管辖权和辅助管辖权的概念,理想情况是辅助管辖权将在大多数重要事项上服从主管辖权,以实现公正、实际和经济合理的事务清算。与这一理想有关的一个相对较新的发展是,在司法上促进清算人和在不同司法管辖区任命的类似官员之间的法院认可的协议,称为“交叉命令协议”。然而,在这一背景下,重要的是,不要忽视“行政”的某些问题总是受香港法律管辖的事实。见下文第12.016至12.032段。
请告诉我怎么做。我需要将此号码转换为er:#CLI_Chu 12/P12-016和er:#CLI_Chu 12/P12-032


谢谢

我很确定有更好的方法来实现这一点,但因为还不完全清楚xslt应该做什么,所以我还是支持您的解决方案

您需要执行一些递归模板调用。 将当前的“para/text()”模板更改为以文本作为参数的命名模板。 但将每个current()替换为$text

<xsl:template name="mytext">
        <xsl:param name="text" />


<xsl:variable name="numx">
    <xsl:number format="1" level="any"/>
</xsl:variable>
    <xsl:choose>
                <xsl:when test="(contains(substring(substring-after($text,'.'),4,1),')') 
                          or     contains(substring(substring-after($text,'.'),4,1),'.')
                          or     contains(substring(substring-after($text,'.'),4,1),' ')) 
                          and (contains(substring ($text,string-length(substring-before($text, '.')) -1,2),' '))
                          and contains(substring($text,string-length(substring-before($text, '.')) -2,1),$numx)">

是否可以显示您当前使用的XML,并解释转换背后的逻辑?谢谢Hi@TimC,我已经更新了我的查询,很抱歉,我不能显示我的整个xml文档,因为它非常大。Hi@hr_117这只适用于第一个数字(“请参见下面的第12.016至12.032段”,这里它只适用于12.016),但不适用于第二个数字。要使这项工作,请添加对原始部分的递归调用。将
替换为
非常感谢各位老板,这很有效。你很和蔼。再次感谢:-)
</xsl:template>
<xsl:template match="para/text()">
    <xsl:call-template name="mytext" >
        <xsl:with-param  name="text" select="." />
    </xsl:call-template>
</xsl:template>
<xsl:when test="contains(substring-after($text,'.'),'.')">
    <xsl:value-of select="substring-before($text,'.')"/>
    <xsl:text>.</xsl:text>
    <xsl:call-template name="mytext">
        <xsl:with-param  name="text" select="substring-after($text,'.')"/>
    </xsl:call-template>
</xsl:when>
<xsl:otherwise>
    <xsl:value-of select="$text"/>
</xsl:otherwise>