Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

for statement in xsl

Status
Not open for further replies.

msalvador

Programmer
Nov 13, 2001
33
0
0
IT
Hi i've to do a simple for statement.
That begin 1 to 4.
p.e. in VB for i=1 to 4

my xml file are formatted as following:
<root>
<customer name=&quot;pippo&quot; surname=&quot;pluto&quot; age=&quot;25&quot;/>
<customer name=&quot;pippo&quot; surname=&quot;pluto&quot; age=&quot;25&quot;/>
<customer name=&quot;pippo&quot; surname=&quot;pluto&quot; age=&quot;25&quot;/>
<customer name=&quot;pippo&quot; surname=&quot;pluto&quot; age=&quot;25&quot;/>
</root>
i've to put attribute information in a table.
like this


<xsl:for-each select=&quot;root/CO_Customer_Identify&quot;>
<tr>
<xsl:for-each 1 to 4> ???????????????
<td>
<xsl:value-of select=&quot;@*&quot; />
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
 
There is no such thing as a &quot;for loop&quot; in XSL, only a for-each loop. You'll have to mimic the logic of a for loop using parameters, named templates and an &quot;if&quot; statement.

Try the following code (you'll have to customize it to work with your xml):

Code:
<xsl:template match=&quot;whatever&quot;>
  <xsl:call-template name=&quot;loop&quot;>
    <xsl:with-param name=&quot;counter&quot; select=&quot;1&quot;/> 
  </xsl:call-template>
</xsl:template>

<xsl:template name=&quot;loop&quot;>
  <xsl:param name=&quot;counter&quot;>1</xsl:param>
  <xsl:if test=&quot;$counter &lt; 4&quot;>
    Do whatever the loop should do here.....
    <xsl:call-template name=&quot;loop&quot;>
      <xsl:with-param name=&quot;counter&quot; select=&quot;$counter + 1&quot;/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

Hope this helps....K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top