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

RE: Recursion/ Iteration problem.

Subject: RE: Recursion/ Iteration problem.
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Wed, 11 Apr 2001 23:36:46 +0100
change recursion to iteration
> The foll is the XSL that shd pull the first 10 hotels out of
> many in an XML
> doc. I am getting the first hotel printed 10 times instead of
> the first 10.
> Any suggestions?

Well, the context node doesn't change on each recursion, and the data that
you output doesn't depend on the counter, which is the only thing that does
change, so it's not surprising that you get the same output each time.

You need to supply the list of hotels as a parameter to the template, and on
each recursion, set the value of this to e.g. <xsl:with-param name="list"
select="list[position() &gt; 1]"

Mike Kay
Software AG
>
>
> <?xml version='1.0' encoding='utf-8' ?>
> <xsl:stylesheet xmlns:xinclude="http://www.w3.org/1999/XML/xinclude"
> xmlns:xlink="http://ww.w3.org/TR/xlink"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> exclude-result-prefixes="xinclude xlink" version="1.0"><xsl:output
> method="xml"/>
> 	<xsl:template match="/" name="index">
> 		<vxml version="1.0">
> 			<form id="business1">
> 				<field name="busFinder">
> 					<prompt>
> 						<xsl:text>The
> closest 5</xsl:text>
> 						<xsl:value-of
> select="Go2LocationResponse/Data/ListingsResponse/@searchValue"/>
> 						<xsl:text>are</xsl:text>
> 					</prompt>
>
>       				<xsl:call-template name="TEMP">
>         				<xsl:with-param
> name="counter" select="1" />
>       				</xsl:call-template>
>
> 				</field>
> 			</form>
> 		</vxml>
> 	</xsl:template>
>
> 	<xsl:template name="TEMP">
> 		<xsl:param name="counter" />
> 		<xsl:if test="$counter &lt; 11">
> 			<prompt>
> 				<xsl:value-of
> select="Go2LocationResponse/Data/ListingsResponse/Listing/@com
> panyName"/>
> 				<xsl:text>, located at</xsl:text>
> 				<xsl:value-of
> select="Go2LocationResponse/Data/ListingsResponse/Listing/Loca
> tion/Address/@
> street"/>
> 				<xsl:text>.</xsl:text>
> 			</prompt>
> 			<xsl:call-template name="KMFDM">
> 				<xsl:with-param name="counter"
> select="$counter + 1" />
> 			</xsl:call-template>
>   		</xsl:if>
> 	</xsl:template>
>
> </xsl:stylesheet>
>
> TIA
> --SR
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.