Re: [xsl] self axis vs .

Subject: Re: [xsl] self axis vs .
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Sat, 7 Jun 2008 00:06:40 +0200 (CEST)
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

Current Thread