xsl-list
[Top] [All Lists]

RE: [xsl] self axis vs .

2008-06-06 16:46:27
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(_at_)saxonica(_dot_)com] 
Sent: Friday, June 06, 2008 5:21 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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