RE: [xsl] self axis vs .

Subject: RE: [xsl] self axis vs .
From: "Scott Trenda" <Scott.Trenda@xxxxxxxx>
Date: Fri, 6 Jun 2008 18:46:01 -0500
I use <xsl:apply-templates select="self::elem" mode="someMode" /> when
I'm in a more generic template and have to do the equivalent of a
<xsl:if test="name() = 'elem'"><xsl:call-template name="someMode"
/></xsl:if>, but can't implement the other template as a named template
for one reason or another.

It's just better, more compact syntax, immediately accessible in XSLT
1.0. I don't see why people would be discouraging the use of the self::
axis.

~ Scott


-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Friday, June 06, 2008 5:21 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] self axis vs .

>   But for excluding a set of names from an XPath in XSLT, I
> rather use the following:
>
>     <xsl:variable name="to-exclude" as="element()+">
>        <elem1/>
>        <ns:elem/>
>        ...
>     </xsl:variable>
>
>     *[not(node-name(.) = $to-exclude/node-name(.))]

And there I was thinking "there's no point doing lazy construction of
trees;
no-one in their right mind is going to create an element and then only
access its name".

I think I prefer the more direct:

* except (elem1 | ns:elem)

Michael Kay
http://www.saxonica.com/

Current Thread