[xsl] matching when the attribute or element is NOT there

Subject: [xsl] matching when the attribute or element is NOT there
From: Carl Yu <carl.yu@xxxxxxxxxxxx>
Date: Wed, 19 Mar 2003 11:41:14 -0800 (PST)
So this works for detecting when elements or attributes exist...

<xsl:template match="/main/child[subchild]">
<xsl:text>Child contains a subchild element.</xsl:text>
</xsl:template>

<xsl:template match="/main/child[@attr]">
<xsl:text>Child contains the attr attribute.</xsl:text>
</xsl:template>

This does not work... is there another way to do this in the match statement?  I 
know I can write this with an if statement, but I'm trying to do some grouping 
work that requires the check occur in the match statement.

<xsl:template match="/main/child[not(subchild)]">
<xsl:text>Child does not contain a subchild element.</xsl:text>
</xsl:template>

<xsl:template match="/main/child[not(@attr)]">
<xsl:text>Child does not contain the attr attribute.</xsl:text>
</xsl:template>

Any help?
Thanks,
Carl


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread