2016-06-22 35 views
0

我嘗試在他們選擇沒有斜體文字段落(XSLT 2.0):XSLT的選擇:如果有至少一個後代沒有一定的標準

<p>Some <hi rend="italic">italic text</hi></p> 
<p>Some <hi rend="bold">bold text</hi> and some <hi rend="italic">italic Text</hi></p> 
<p>Some <hi rend="bold">bold text</hi></p> 

我只希望有P [3]。我想這和它的作品:

<xsl:template match="p"> 
    <xsl:if test="p[not(child::hi[@rend='italic'])]"> ... do something </if> 
    </xsl:template> 

但我真正的問題是更深層次的動這一層:我只想用至少一個段落,沒有斜體文字的文本:

<text> 
    <p>Some Text</p> 
    <p>Some <hi rend="bold">text</hi> and some <hi rend="italic">italic</hi> text</p> 
</text> 
<text> 
    <p>Some <hi rend="bold">text</hi></p> 
    <p>Some other text</p> 
</text> 
<text> 
    <p>Some <hi rend="italic">text</hi></p> 
    <p>Some <hi rend="italic">text</hi></p> 
</text> 

我如何選擇前兩個文本但不是第三個文本?

回答

1

在第一部分,你只是想

<xsl:template match="p[not(hi[@rend = 'italic'])]">...</xsl:template> 

對於第二部分

<xsl:template match="text[p[not(hi[@rend = 'italic'])]]">...</xsl:template> 
相關問題