[xsl] what does this statement mean?

Subject: [xsl] what does this statement mean?
From: RQamar <qamar_rahil@xxxxxxxxxxx>
Date: Thu, 10 Mar 2005 10:20:28 +0000
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).


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"/>
</xsl:template>


<xsl:template match="*" mode="walker"> <!-- problems during execution-->
<xsl:apply-templates select="following-sibling::*" mode="walker"/>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>


</xsl:stylesheet>


My inpur file is -------------

<Top>
 <PrimeConcept id="0001" type="none">A</PrimeConcept>
 <SubConcepts>
    <SubConcept id="0002" name="A1">
      <Value ref="0003">hasProperty1 AB</Value>
      <Value ref="0004">hasProperty2 XY</Value>

      <SubConcept id="0004" name="XY">
          <ChildConcept ref="0005">XY1</ChildConcept>
          <SubConcept id="0005" name="XY1">
             <ChildConcept ref="0007">XY11</ChildConcept>
             <ChildConcept ref="0008">XY12</ChildConcept>
          </SubConcept>
          <ChildConcept ref="0006">XY2</ChildConcept>
       </SubConcept>

  </SubConcept>
 </SubConcepts>
</Top>
----------------

The desired output is

----------------

<Top>
 <PrimeConcept id="0001" type="none">A</PrimeConcept>
 <SubConcepts>
    <SubConcept id="0002" name="A1">
      <Value ref="0003">hasProperty1 AB</Value>
      <Value ref="0004">hasProperty2 XY</Value>
  </SubConcept>
  <SubConcept id="0004" name="XY">
          <ChildConcept ref="0005">XY1</ChildConcept>
          <ChildConcept ref="0006">XY2</ChildConcept>
   </SubConcept>
     <SubConcept id="0005" name="XY1">
             <ChildConcept ref="0007">XY11</ChildConcept>
             <ChildConcept ref="0008">XY12</ChildConcept>
    </SubConcept>
 </SubConcepts>
</Top>

---------------

Thanks
Rahil

Current Thread