Subject: Re: [xsl] what does this statement mean? From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 10 Mar 2005 10:44:43 GMT |
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). It's not that line that is causing the problem, and it's not a loop and not infinite, but you are repeatedly processing nodes many (but finite) amount of times. <xsl:apply-templates select="*[1]" means apply templates to the first child. the idea then is the tempolate that is applied handles that node then applies templates to its next sibling (just teh next one) and you repeat this process handling siblings one at a time so that in teh end you have handles all the children. this gives a bit more control than the usual <xsl:apply-templates select="*" which directly processes all children. But you have <xsl:template match="*" mode="walker"> <!-- problems during execution--> <xsl:apply-templates select="following-sibling::*" mode="walker"/> </xsl:template> so you don't just handle the next sibling you handle all following siblings (and each of them handles all its sibligs so if you number your siblings <x> 1 2 3 4 </x> the processing order is 1 2 3 4 4 3 4 4 So if you have 100 children the last child will be processed 100 times. You want <xsl:apply-templates select="following-sibling::*[1]" mode="walker"/> so that the processing order is 1 2 3 4 David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] what does this statement mean, RQamar | Thread | RE: [xsl] what does this statement , Jarno.Elovirta |
RE: [xsl] what does this statement , Jarno.Elovirta | Date | Re: [xsl] what does this statement , RQamar |
Month |