Re: [xsl] What is the equivalent of this statement ?

Subject: Re: [xsl] What is the equivalent of this statement ?
From: Liam R E Quin <liam@xxxxxx>
Date: Fri, 13 Jul 2012 14:05:55 -0400
On Sat, 2012-07-14 at 00:47 +0700, Lucent Lau wrote:
> Hello,
> 
> If I have this XML structure:
> 
> <root>
> <elemA>
>      <elemB>
>          <elemC id="1"/>
> </elemB>
> </elemA>
> </root>
> 
> what is the equivalent of this statement if I do not want to
> specifically use elemC
> <xsl:apply-templates select="node()[ not( self::elemC[@id=('1')])]" />
> 
> Can I say:
> <xsl:apply-templates select="node()[ not( self::elemA/*/*[@id=('1')])]" />
> 
No, because there's no elemA in the same context as an elemC.
Presumably this is in a template that matches elemB, and you are
processing the whitespace node but not the selcted element node.

I'd probably have an empty template with
  match="elemA/elemB/elemC[id = 1]"

and then just use apply-templates.

You could also say, node()[not(@id = 1)] if no other element has @id.

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml

Current Thread