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

Re: recursive loop in XSL stylesheet is failing

Subject: Re: recursive loop in XSL stylesheet is failing
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 25 Mar 2010 20:05:42 +0100
Re:  recursive loop in XSL stylesheet is failing
George wrote:
Thanks a lot guys in order to shed light on my view about variables!!

Great, thank you very much David for the modified stylesheet.

Unfortunately it does not give the result I expected. It stops after the output of Date. It seems that it does not like the key() function.

Are you sure that it is called correctly this way:
 > <xsl:apply-templates select="key('c',CategoryID,$c)"/>

Yes, that is possible, but only with XSLT 2.0 (that David used).


If you use XSLT 1.0 then you need to change the code slightly:


<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:key name="c" match="Category" use="@ID"/>
<xsl:variable name="c" select="document('Categories.xml')"/>
<xsl:template match="Entry">
<xsl:text>&#10;</xsl:text>
<xsl:value-of select="Date"/>
<xsl:apply-templates select="key('c',CategoryID,$c)"/>

Change the above line to <xsl:variable name="cat" select="CategoryID"/> <xsl:for-each select="$c"> <xsl:apply-templates select="key('c', $cat)"/> </xsl:for-each>

<xsl:text>;</xsl:text>
<xsl:value-of select="Recipient"/>
<xsl:text>;</xsl:text>
<xsl:value-of select="Value"/>
</xsl:template>

<xsl:template match="Category">
 <xsl:apply-templates select="key('c',@ParentID,$c)"/>

and the above line to <xsl:variable name="pid" select="@ParentID"/> <xsl:for-each select="$c"> <xsl:apply-templates select="key('c', $pid)"/> </xsl:for-each>



--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

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.