This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Matching braches without a certain node
- To: "'XSL-List at mulberrytech dot com'" <XSL-List at mulberrytech dot com>
- Subject: Matching braches without a certain node
- From: Theodore Weatherly <tweather at slamdunknetworks dot com>
- Date: Tue, 28 Nov 2000 12:30:17 -0800
- Reply-To: xsl-list at mulberrytech dot com
Suppose we have this XML:
<top>
<middle id="1">
<data>value</data>
<foo>bar</foo>
</middle>
<middle id="2">
<data>value</data>
</middle>
<middle id="3">
<data>value</data>
<foo>bar</foo>
</middle>
</top>
I want to match the 'middle' nodes that _don't_ have the 'foo' node (id==2).
This seems to work:
<xsl:template match="/">
[stuff before]
<xsl:for-each select="//middle">
<xsl:if test="not (foo[node()]">
[Whatever I want to do]
</xsl:if>
</xsl:for-each>
</xsl:template>
(You get the general idea.) Isn't there any simpler way to do this?? I'd
rather do something where, in one line, I match the 'middle' nodes without
the 'foo' tag, and then do an unconditional loop over these nodes.
Thanks!
-Ted
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list