Re: [xsl] Understanding Identity Transformations

Subject: Re: [xsl] Understanding Identity Transformations
From: Karl Stubsjoen <kstubs@xxxxxxxxx>
Date: Mon, 14 Feb 2005 12:35:45 -0700
[FOLLOW UP]

I get it!

This:
<xsl:template match="*[@cat!='BLUE']" />

Will match all nodes where the cat attribute is not equal to 'BLUE'
and... all nodes which do not have a cat attribute!!!

Really what I want is:
<xsl:template match="FOO[not(@cat='BLUE')]" />

Which will match all nodes where the cat attribute is not equal to
'BLUE' and... here is the important pars... and match only FOO element
who have a cat attribute!

Errr.... but couldn't get the first example to work until I
distinguished that the element FOO is the one I was interested in
matching.  Hmmmm.... I will feel triumphant when I can rewrite this
with *[not(...)] rather than FOO[not(...)].  I guess the problem is
that the top level node was not being matched.  So how to avoid
colliding with the top level node in this case where there is no cat
attribute?

Karl

On Mon, 14 Feb 2005 12:14:01 -0700, Karl Stubsjoen <kstubs@xxxxxxxxx> wrote:
> Ok.. .the following is working great, but I am using != operand.  How
> do you write the below match using not() and achieve same results?
> 
> <xsl:template match="@* | node()">
>  <xsl:copy>
>        <xsl:apply-templates select="@*"/>
>        <xsl:apply-templates />
>  </xsl:copy>
> </xsl:template>
> 
> <xsl:template match="*[@cat!='BLUE']" />

Current Thread