• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

looping xsl

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have an xml file and an xsl file.i want to loop though for n times based on a xml node value and display that many number of links at the bottom of teh ouput .I have created a template for that in the xsl file but it does not do the intended job.
i other words the xml has a node called totalrecords .what i want is to print the numbers 1 to n(where n is the total record node value).
can any one please correct the file and send me an answer for this.Thanks a lot for the help in advance.
XML file:
<?xmlspysamplexml C:\Documents and Settings\bnatarajan\Desktop\Quote Docs\XML\Quote_summary.xml?>
<?xml-stylesheet type="text/xsl" href="C:\Documents and Settings\bnatarajan\Desktop\Quote Docs\XSL\Quote_summary.xsl"?>
<ROWSET>
<ROW RowNum="1">
<Qoute_id>010206001023451</Qoute_id>
<Region>east</Region>
<Dealer_name>AMXDLR1</Dealer_name>
<JDEID>12341</JDEID>
<JobName>MAT1</JobName>
<Date_Sub>10/1/2002 12:00:00 AM</Date_Sub>
<Date_mod>10/2/2002 12:00:00 AM</Date_mod>
</ROW>
<ROW RowNum="2">
<Qoute_id>010206001023452</Qoute_id>
<Region>west</Region>
<Dealer_name>AMXDLR2</Dealer_name>
<JDEID>12342</JDEID>
<JobName>MAT2</JobName>
<Date_Sub>10/19/2002 12:00:00 AM</Date_Sub>
<Date_mod>10/20/2002 12:00:00 AM</Date_mod>
</ROW>
<ROW RowNum="3">
<Qoute_id>010206001023453</Qoute_id>
<Region>north</Region>
<Dealer_name>AMXDLR3</Dealer_name>
<JDEID>12342</JDEID>
<JobName>MAT3</JobName>
<Date_Sub>10/21/2002 12:00:00 AM</Date_Sub>
<Date_mod>10/21/2002 12:00:00 AM</Date_mod>
</ROW>
<ROW RowNum="4">
<Qoute_id>010206001023454</Qoute_id>
<Region>south</Region>
<Dealer_name>AMXDLR4</Dealer_name>
<JDEID>12343</JDEID>
<JobName>MAT4</JobName>
<Date_Sub>10/29/2002 12:00:00 AM</Date_Sub>
<Date_mod>10/29/2002 12:00:00 AM</Date_mod>
</ROW>
<ROW RowNum="5">
<Qoute_id>010206001023455</Qoute_id>
<Region>central</Region>
<Dealer_name>AMXDLR5</Dealer_name>
<JDEID>12345</JDEID>
<JobName>MAT5</JobName>
<Date_Sub>10/30/2002 12:00:00 AM</Date_Sub>
<Date_mod>10/30/2002 12:00:00 AM</Date_mod>
</ROW>
<TotalRecords>5</TotalRecords>
</ROWSET>
XSL File:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/child::ROWSET">

<table width="620" border="0" cellspacing="0" cellpadding="0">

<tr>
<th align="left" valign="top" width="110" class="tablebg"><span class="tableHead">Quote_id</span></th>
<th align="left" valign="top" width ="60" class="tablebg"><span class="tableHead">Region</span></th>
<th align="left" valign="top" width="50" class="tablebg"><span class="tableHead">Dealer</span></th>
<th align="left" valign="top" width="40" class="tablebg"><span class="tableHead">JDE ID</span></th>
<th align="left" valign="top" width="60" class="tablebg"><span class="tableHead">Job Name</span></th>
<th align="left" valign="top" width="100" class="tablebg"><span class="tableHead">Date Submitted</span></th>
<th align="left" valign="top" width="100" class="tablebg"><span class="tableHead">Date Modified
</span></th>
<th align="left" valign="top" width="100" class="tablebg"><span class="tableHead"></span></th>

</tr>
<xsl:for-each select="/ROWSET/ROW">

<tr>
<td align="left" valign="top" class="tablebodycopy">

<xsl:value-of select="Qoute_id"/>
</td>

<td align="left" valign="top" class="tablebodycopy">

<xsl:value-of select="Region"/>

</td>
<td align="left" valign="top" class="tablebodycopy">
<xsl:value-of select="Dealer_name" />
</td>

<td align="left" valign="top" class="tablebodycopy">
<xsl:value-of select="JDEID" />
</td>

<td align="left" valign="top" class="tablebodycopy">
<xsl:value-of select="JobName" />
</td>

<td align="left" valign="top" class="tablebodycopy">
<xsl:value-of select="Date_Sub" />
</td>
<td align="left" valign="top" class="tablebodycopy">
<xsl:value-of select="Date_mod" />
</td>

<td align="left" valign="top">


<a>
<xsl:attribute name="href">
Edit.aspx?id=<xsl:value-of select="OP_ID" />
</xsl:attribute>Edit
</a><a href="javascript:history.back();" >/Cancel
</a>

</td>

</tr>
<tr><td colspan="13" align="left" valign="top"><img src="images/rulecc.gif" width="600" height="3"></img></td></tr>

</xsl:for-each>

</table>
</xsl:template>
<xsl:template name="hyphens" >
<xsl aram name="howMany" >1</xsl aram>
<xsl:if test="$howMany < 5">
<!-- Add 1 hyphen to result tree. -->
<table><tr><td>
<xsl:value-of select="$howMany" />

</td></tr></table>
<!-- Print remaining ($howMany - 1) hyphens. -->
<xsl:call-template name="hyphens" >
<xsl:with-param name="howMany" select="$howMany +1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
 
reply
    Bookmark Topic Watch Topic
  • New Topic