Reputation: 36403
Given the XML
<blockquote>
<attribution>foo</attribution>
<para>bar</para>
</blockquote>
I have the XSL template
<xsl:template match="dbk:blockquote">
<blockquote>
<xsl:apply-templates select="*[not(dbk:attribution)]" />
<xsl:apply-templates select="dbk:attribution" />
</blockquote>
</xsl:template>
where the first apply-templates
should select all child elements of the dbk:blockquote
that are not of type dbk:attribution
. (This is necessary to move attributions to the bottom.)
However, it in fact matches every node. Why?
Upvotes: 1
Views: 3758
Reputation: 60414
You want to use the self
axis:
<xsl:apply-templates select="*[not(self::dbk:attribution)]" />
This selects child elements that are not themselves a dbk:attribution
element. Your version selects child elements that do not contain a dbk:attribution
child.
Upvotes: 7
Reputation: 19648
I am no xpath expert. But I think this should work.
<xsl:template match="dbk:blockquote">
<blockquote>
<xsl:apply-templates select="*[local-name(.) != 'attribution']" />
<xsl:apply-templates select="*[local-name(.) = 'attribution']" />
</blockquote>
</xsl:template>
Upvotes: 0