2017-04-26 81 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

相關問題