Subject: RE: [xsl] Incrementing number in a for loop ?? From: Dipesh Khakhkhar <dkhakhkh@xxxxxxxxxxxxxxx> Date: Thu, 31 Jul 2003 09:44:29 -0400 |
hi, First of all thanks a mile for answering my query which confirmed my guess that i can not increment variable in xsl. Well my xsl is like this. 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> So i was trying to confirm that can i declare a variable and code in other languages as under: -------------------------------------------------------------------- int quoteCount = 30; // for example this many quotes i need for(int i = 0; i < quoteCount ; i++) printf("`"); // cout << "`" \ // Console.Write("`") // System.Out.print("`"); --------------------------------------------------------------------- Thanks for taking out your time and answering my question. Well i thought from here i will get conformace for my guessing thats why i asked question like this and if it bothered someone i am really sorry for that. Regards, Dipesh > >Date: Wed, 30 Jul 2003 21:27:00 -0400 >From: cknell@xxxxxxxxxx >Subject: RE: [xsl] Incrementing number in a for loop ?? > >Variables, once declared, cannot be changed. You could pass the old value to the called template with a parameter and declare a variable inside the template which adds one to the value passed as a parameter when the template is called recursively, but probably there's a better way to achieve the result. We could tell more if you supply a stripped-down example of your source XML and your stylesheet. >- -- >Charles Knell >cknell@xxxxxxxxxx - email > > > >- -----Original Message----- >From: Dipesh Khakhkhar <dkhakhkh@xxxxxxxxxxxxxxx> >Sent: Wed, 30 Jul 2003 19:56:22 -0400 >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >Subject: [xsl] Incrementing number in a for loop ?? > >Hi, > >I am creating a text output from xml and at some places i have to give >hardcoded special characters. > >Is is possible to declare a variable having numerical value and incrementing >it using expression inside for loop ? > >If somebody can throw some light on this issue i would be grateful. > >Regards, >Dipesh > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > >------------------------------ > >Date: Wed, 30 Jul 2003 21:27:18 -0400 >From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> >Subject: Re: [xsl] Incrementing number in a for loop ?? > >At 2003-07-30 19:56 -0400, Dipesh Khakhkhar wrote: >>I am creating a text output from xml and at some places i have to give >>hardcoded special characters. > >This not a very explicit description of a problem that needs to be solved >using incrementing variables. > >>Is is possible to declare a variable having numerical value and incrementing >>it using expression inside for loop ? > >No ... this is a FFFFAQ ... even a simple query will tell you the answer to >this question: > > http://www.google.com/search?as_q=increment+global+variable+xslt > >Gee, it even happens to be my answer that is at the top of the list tonight. > >>If somebody can throw some light on this issue i would be grateful. > >Variables in XSLT do not vary within their scope. Now your question has >been answered, but you only asked a yes/no question and you haven't given >enough detail for anyone to help you with your real problem. > >If you take a moment to describe the nature of the problem you are trying >to solve where you think you need a varying variable, people on the list >will be able to tell you about the position() function or the <xsl:number/> >instruction, or about tree walking with recursive template calls, or any of >a number of other XSLT facilities that may be able to help you solve your >problem. > >And please take your time to try and do *some* research before asking >people to take from their time to answer your questions that have already >been answered. > >I hope this helps. > >............... Ken > > >- -- >Upcoming hands-on courses: in-house corporate training available; >North America public: XSL-FO Aug 4,2003; 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 > >------------------------------ > >Date: Wed, 30 Jul 2003 18:39:35 -0700 (PDT) >From: Mukul Gandhi <mukulw3@xxxxxxxxx> >Subject: Re: [xsl] Incrementing number in a for loop ?? > >You *cannot increment* variables in XSLT. But you may >use count() and possibly other workarounds to generate >serial nos. > >Regards, >Mukul > >> Is is possible to declare a variable having >> numerical value and incrementing >> it using expression inside for loop ? >> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Incrementing number in a , cknell | Thread | RE: [xsl] Incrementing number in a , G. Ken Holman |
Re: [xsl] dynamic sort order, Nathan Shaw | Date | [xsl] processing XML on the server,, Tyler Drake |
Month |