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

Re: Re: Incrementing a Global variable

Subject: Re: Re: Incrementing a Global variable
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 28 Aug 2003 14:42:59 +0100
xsl hebrew
> Sorry to chip in.This discussion started with my
> problem and it's still unsolved. 

I thought some solutions had been posted, another is at the end.

> Which could have been done straight
> away if there were some provision of incrementing a
> variable in XSLT.

I don't beliee that the logic of the program below would have been any
simpler if it was expressed as a loop rather than as recursion.


> (ft:assign

you've mentioned ft:assign a few times but I don't think you've said
what bamespace you have ft bound to so I don't know what extension this
is. I know saxon has such an extension, but as i said in an earlier mail
it makes no sense to use assignment for any result that you want to be
portable between systems.

gv.xml

<?xml version="1.0" encoding="UTF-8"?>
<Students>
	<Student>
		<Name>SAM</Name>
		<TOption>English </TOption>
	</Student>
	<Student>
		<Name>RAJ</Name>
		<TOption>English </TOption>
	</Student>
	<Student>
		<Name>RON</Name>
		<TOption>English </TOption>
	</Student>
	<Student>
		<Name>JON</Name>
		<TOption>German  </TOption>
	</Student>
	<Student>
		<Name>DON</Name>
		<TOption>German  </TOption>
	</Student>
	<Student>
		<Name>MON</Name>
		<TOption>Hebrew  </TOption>
	</Student>
	<Student>
		<Name>GON</Name>
		<TOption>Hebrew  </TOption>
	</Student>
</Students>


gv.xsl


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


<xsl:template match="Students">
<html>
<head><title>test</title></head>
<body>
<table>
<xsl:call-template name="row"/>
</table>
</body>
</html>
</xsl:template>

<xsl:template name="row">
 <xsl:param name="p" select="1"/>
 <xsl:param name="s" select="Student[1]"/>
 <tr>
 <td><xsl:value-of select="$p"/></td>
 <td><xsl:value-of select="$s/Name"/></td>
 <td><xsl:value-of select="$s/TOption"/></td>
 </tr>
 <xsl:choose>
 <xsl:when test="$s/TOption=$s/following-sibling::Student/TOption">
 <xsl:call-template name="row">
   <xsl:with-param name="p" select="$p+1"/>
   <xsl:with-param name="s" select="$s/following-sibling::Student[1]"/>
 </xsl:call-template>
 </xsl:when>
 <xsl:when test="$s/following-sibling::Student">
 <tr>
 <td><xsl:value-of select="$p+1"/></td>
 <td> </td>
 <td> </td>
 </tr>
 <xsl:call-template name="row">
   <xsl:with-param name="p" select="$p+2"/>
   <xsl:with-param name="s" select="$s/following-sibling::Student[1]"/>
 </xsl:call-template>
 </xsl:when>
 
 <xsl:otherwise>
<tr>
 <td><xsl:value-of select="$p+1"/></td>
 <td>total</td>
 <td><xsl:value-of select="count(Student)"/></td>
</tr>
  <xsl:for-each select="(document('')//*)[position() +$p &lt; 15]">
<tr>
 <td><xsl:value-of select="$p+1+position()"/></td>
 <td> </td>
</tr>
   </xsl:for-each>
 </xsl:otherwise>
 </xsl:choose>

</xsl:template>


</xsl:stylesheet>

gv.html

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
      <title>test</title>
   </head>
   <body>
      <table>
         <tr>
            <td>1</td>
            <td>SAM</td>
            <td>English </td>
         </tr>
         <tr>
            <td>2</td>
            <td>RAJ</td>
            <td>English </td>
         </tr>
         <tr>
            <td>3</td>
            <td>RON</td>
            <td>English </td>
         </tr>
         <tr>
            <td>4</td>
            <td></td>
            <td></td>
         </tr>
         <tr>
            <td>5</td>
            <td>JON</td>
            <td>German  </td>
         </tr>
         <tr>
            <td>6</td>
            <td>DON</td>
            <td>German  </td>
         </tr>
         <tr>
            <td>7</td>
            <td></td>
            <td></td>
         </tr>
         <tr>
            <td>8</td>
            <td>MON</td>
            <td>Hebrew  </td>
         </tr>
         <tr>
            <td>9</td>
            <td>GON</td>
            <td>Hebrew  </td>
         </tr>
         <tr>
            <td>10</td>
            <td>total</td>
            <td>7</td>
         </tr>
         <tr>
            <td>11</td>
            <td></td>
         </tr>
         <tr>
            <td>12</td>
            <td></td>
         </tr>
         <tr>
            <td>13</td>
            <td></td>
         </tr>
         <tr>
            <td>14</td>
            <td></td>
         </tr>
         <tr>
            <td>15</td>
            <td></td>
         </tr>
      </table>
   </body>
</html>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.