从XSL:number中排除具有某些属性值的元素



我正在使用 <xsl:number>来计数 <proceduralStep>。(我正在使用天线6.2(

<xsl:number count="proceduralStep" from="content" level="multiple" format="1.1.1.1.1"/>

,但我想排除具有具有属性@changeType='delete'

的父母或孩子的任何程序步骤

XML看起来像任何一个:

    <proceduralStep><para>Install This.</para></proceduralStep>
    <proceduralStep><para changeMark="1" changeType="delete">Delete this line.</para></proceduralStep>
    <proceduralStep><para>Continue with ths</para></proceduralStep>
    <proceduralStep><para><changeInline  changeMark="1" changeType="delete">And this line.</changeInline></para></proceduralStep>
    <proceduralStep><para>Continue with this</para></proceduralStep>
<revst changeMark="1" >
    <proceduralStep><para>Turn the screw....</para></proceduralStep>
    <proceduralStep><para>Hold assembly tool....</para></proceduralStep>
    </revst>

,输出应该看起来像这样

    1.2.11 Install This
           Delete this line
    1.2.12 Continue with ths

另一个问题是使用<revst>作为<proceduralStep>的包装器时,编号将重新启动:

    1.2.13 Continue with this
    1.2.1 Turn the screw....
    1.2.2 Hold assembly tool...

而不是:

    1.2.13 Continue with this
    1.2.14 Turn the screw....
    1.2.15 Hold assembly tool...

<xsl:number count="ancestor-or-self::*[changeType!='delete']" from="content" level="multiple" format="1.1.1.1.1"/>

抛出错误:仅在匹配模式外允许外面的匹配模式

允许使用"孩子"one_answers"属性"轴

,但我想排除任何有父母或孩子的程序信息 使用属性@changeType='delete'

计数proceduralStep不包括具有属性的子节点的 @changeType='delete'使用:

count="proceduralStep[not(*/@changeType = 'delete')]"

要将其扩展到父节点,您可以使用:

count="proceduralStep[not(*/@changeType = 'delete' or parent::*/@changeType = 'delete')]"

请注意,a!=bnot(a=b)不同。

最新更新