xsl-list
[Top] [All Lists]

Re: [xsl] self axis vs .

2008-06-06 15:07:09
Mukul Gandhi wrote:

  Hi

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

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

  As in:

    <xsl:apply-template select="*"/>

    <xsl:template match="elem">
       <!-- do something -->
    </xsl:template>

;-)

  More seriously, I think I haven't seen the (almost) single use I ever
made of self::, within XPath expression:

    *[not(self::to-ignore)]

  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(.))]

  Regards,

--drkm























      
_____________________________________________________________________________ 
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr


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