2017-04-26 84 views
0

我正在使用<xsl:number>来计数<proceduralStep>。 (我使用的天线众议院6.2)从xsl中排除具有某些属性值的元素:数字

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

但我想排除有家长或孩子与属性的任何proceduralStep @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 

另一个问题是WH连接使用<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"/>

引发错误:只有 '孩子' 和 '属性' 轴允许在谓词外的匹配模式

回答

1

But I want to exclude any proceduralStep that has a parent or child with attribute @changeType='delete'

要计算proceduralStep不包括那些与属性@changeType='delete'使用一个子节点:

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

过于此扩展到父节点,你可以使用:

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

注意a!=bnot(a=b)不一样。

+0

非常感谢!这很好。我并没有理解为什么'a!= b'不等于'not(a = b)'(我仍然遇到了这样的问题:在这个级别重新开始编号。) – Caroline

+0

** 1。**因为'a!= b'将不**返回真,当'a'不存在时。 ** 2。**我怀疑你想使用'level =“any”'。很难确定使用你的例子。 –

+0

嵌套步骤需要'level = multiple',所以我会努力。太糟糕了,因为'level =“任何”'编号正确。迈克尔,你真的很有帮助,我很感激! – Caroline

相关问题