RE: [xsl] what does this statement mean?

Subject: RE: [xsl] what does this statement mean?
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Thu, 10 Mar 2005 12:41:48 +0200

> Im trying to rearrange the order of my XML elements using the
> <xsl:copy>
> feature of XSLT 2.0. However Im having trouble with one line of code
> which causes my processor to run into an infinite loop.
> Could someone please let me know what this particular
> <xsl:apply-templates select="*[1]" mode="walker"/> means and what
> exactly its trying to do (this was a piece of code that was
> suggested by
> someone from this list).

Might have been me, I use the "walker" mode name for that sort of grouping.
Basically it's a grouping method that walks through a flat list of elements
and the "walker" mode templates decide whether to stop the walking or

> The full code is shown below :
> ----------------------------
> <xsl:template match="/">
>     <Top>
>         <xsl:apply-templates select="Top/SubConcepts"/>
>     </Top>
> </xsl:template>
> <xsl:template match="SubConcepts">
>     <xsl:copy>
>       <xsl:apply-templates select="@*"/>
>       <xsl:for-each select="descendant::SubConcept">
>         <xsl:copy>
>           <xsl:apply-templates select="@*"/>
>           <xsl:apply-templates select="*[1]" mode="walker"/>
>     <!--problem with this line of code-->
>         </xsl:copy>
>       </xsl:for-each>
>     </xsl:copy>
> </xsl:template>
> <xsl:template match="Value | ChildConcept" mode="walker">
> <!-- problems during execution-->
>     <xsl:apply-templates select="."/>
>     <xsl:apply-templates select="following-sibling::*" mode="walker"/>

This should be

  <xsl:apply-templates select="following-sibling::*[1]" mode="walker"/>

i.e. continue to the next sibling, not to all of them.

> </xsl:template>
> <xsl:template match="*" mode="walker">
>             <!-- problems during execution-->
>     <xsl:apply-templates select="following-sibling::*" mode="walker"/>

Same here, it should be

  <xsl:apply-templates select="following-sibling::*[1]" mode="walker"/>


Jarno - Neuroticfish: Skin (Binary 2002)

Current Thread