Hi,
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 continue.
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"/>
Cheers,
Jarno - Neuroticfish: Skin (Binary 2002)
--~------------------------------------------------------------------
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>
--~--