xsl-list
[Top] [All Lists]

matching when the attribute or element is NOT there

2003-03-19 12:41:14
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[(_at_)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



<Prev in Thread] Current Thread [Next in Thread>