xsl-list
[Top] [All Lists]

Re: [xsl] self axis vs .

2008-06-06 17:20:59
On Fri, 2008-06-06 at 23:16 +0530, Mukul Gandhi wrote:
On Fri, Jun 6, 2008 at 9:28 PM, Wendell Piez 
<wapiez(_at_)mulberrytech(_dot_)com> wrote:
It also works to test whether the current node is actually an 'elem' when
you process it or traverse from it.

Since when it isn't, it is silently filtered out, this could be regarded as
either a feature or a bug.

I consider self::elem to be a very useful facility just for this reason.

the following example illustrates this:

<xsl:for-each select="*">
  <xsl:if test="self::elem">
    <!-- do something -->
  </xsl:if>
</xsl:for-each>

(not a big fan of for-each, but...) this could be:

<xsl:apply-templates select="self:oneelem" mode="one"/>
<xsl:apply-templates select="self:twoelem" mode="two"/>
<xsl:apply-templates select="self:threeelem" mode="three"/>

no need for ifs



Here I am traversing element nodes of any name. If a node in the list
is 'elem', I want to do something ...



same as above


--~------------------------------------------------------------------
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>