RE: [xsl] Incrementing number in a for loop ??

Subject: RE: [xsl] Incrementing number in a for loop ??
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 31 Jul 2003 10:41:43 -0400
At 2003-07-31 09:44 -0400, Dipesh Khakhkhar wrote:
When i m parsing my xsl file i m creating quotes like this and it is HARDCODED
and this I counted and put into my xsl file as show below where at someplace i
need like this.


<xsl:text>
``````````````````````````````</xsl:text>
And at other place i need something like this.
<xsl:text>
``````</xsl:text>
...
int quoteCount = 30; // for example this many quotes i need
for(int i = 0; i < quoteCount ; i++)
     printf("`");

I hope this helps.


............ Ken

T:\ftemp>type dipesh.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

<xsl:output method="text"/>

<xsl:template match="/">
  <xsl:text>First is 30: </xsl:text>
  <xsl:call-template name="do-quotes">
    <xsl:with-param name="count" select="30"/>
  </xsl:call-template>
  <xsl:text>&#xa;Second is only 20: </xsl:text>
  <xsl:call-template name="do-quotes">
    <xsl:with-param name="count" select="20"/>
  </xsl:call-template>
</xsl:template>

<xsl:template name="do-quotes">
  <xsl:param name="count" select="0"/>
  <xsl:if test="$count">
    <xsl:text>'</xsl:text>
    <xsl:call-template name="do-quotes">
      <xsl:with-param name="count" select="$count - 1"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>saxon dipesh.xsl dipesh.xsl
First is 30: ''''''''''''''''''''''''''''''
Second is only 20: ''''''''''''''''''''
T:\ftemp>



--
Upcoming hands-on courses: in-house corporate training available;
North America public:                     XSLT/XPath Aug 12, 2003

G. Ken Holman                mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                      Definitive XSLT and XPath
ISBN 0-13-140374-5                              Definitive XSL-FO
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X              Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:    http://XMLGuild.info
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc


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



Current Thread