XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
peter teichertSubject: howto loop through a sequence
Author: peter teichert
Date: 06 Nov 2007 08:56 AM
Originally Posted: 05 Nov 2007 09:59 AM
Hi XSLT programmers,

I am looking for a solution how to loop through a sequence.
Please look the following code snippet:

How I can choose $input[1,3,5] and $input[2,4,6] ?
Or should I change the <xsl:apply-templates> statement ?

<xsl:template match="/">

<xsl:variable name="input" as="item()*">
<xsl:sequence select="('B100000', 100, 'B105100', 50, 'B106311', 10)"/>

<xsl:apply-templates select="in:ingredient/in:ing[@in:id=$input[1]]">
<xsl:with-param name="input_amt" select="$input[2]"/>


<xsl:template match="in:ingredient/in:ing">
<xsl:param name="input_amt">0</xsl:param>

<xsl:variable name="GCAL" select="in:GCAL * $input_amt"/>

Peter Teichert

(Deleted User) Subject: howto loop through a sequence
Author: (Deleted User)
Date: 09 Nov 2007 07:27 AM
Something like this should work:

<xsl:for-each select="1 to (count($input) div 2)">
<xsl:variable xmlns:xs="http://www.w3.org/2001/XMLSchema" name="x" select="xs:int(.)*2"/>

<xsl:apply-templates select="in:ingredient/in:ing[@in:id=$input[$x - 1]]">
<xsl:with-param name="input_amt" select="$input[$x]"/>


Hope this helps,

Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.