[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

what does this statement mean?

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.