xsl-list
[Top] [All Lists]

Re: [xsl] self axis vs .

2008-06-07 06:45:02
On Sat, Jun 7, 2008 at 3:36 AM, Florent Georges <lists(_at_)fgeorges(_dot_)org> 
wrote:
   <xsl:apply-template select="*"/>

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

I agree that your suggestion above is more clean.

Following are some use cases where I find self:: axis to be useful.

<xsl:template match="*[not(self::elem)]">
   <!-- do something -->
</xsl:template>

<xsl:template match="*">
   <xsl:if test="not(self::elem)">
      <!-- do something -->
   </xsl:if>
</xsl:template>

Of course there could be alternates ways of writing the logic, like
using the name() or local-name() function.

We could start of a discussion of for-each vs. apply-templates :) You
suggested xsl:apply-template over the for-each example I posted. There
are times when I *don't want to* define a template. I just want to do
for-each at the place where I am.


-- 
Regards,
Mukul Gandhi

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