Subject: Re: [xsl] !!!counters in XSL!!! From: Alexey Gokhberg <alexei@xxxxxxxxxx> Date: Thu, 05 Apr 2001 10:53:43 +0200 |
Rosa I-Ting Cheng wrote: > > can anyone please tell me whether you can have counters in XSL? I mean I > want to increment a variable each time I go into a certain for-each loop. > > or how can I counter the number of nodes with the "node" attribute equaling > to say "here"? > Hello, Rosa Unfortunately, there are no counters in XSLT. Even worse, the ortodox XSLT tradition considers counters incompatible with the very phylosophy of XSLT. This makes life of programmers which migrate from the commonly used tools to XSLT quite difficult. Usually, people who need counters in their XSLT stylesheets get an advice from XSLT gurus to use some awful methods which require calling XSLT templates recursively. But, if you want to be 100% XSLT conforming, you have to use such methods. However, if 100% conformance is not that important for you, you may check documentation of the particular XSLT processor you are using. Many XSLT implementations provide extensions which can be used to emulate counters. For example, if you are using SAXON, you can try the <saxon:assign> extension element. If you are using MSXML3, you can code counters in JScript using <msxml:script> extension element. And so on. But be careful: once you started using extensions, your stylesheets become processor-dependent. You might have difficulties porting those stylesheets between different XSLT implementations. Kind regards, Alexey Gokhberg Unicorn Enterprises SA http://www.unicorn-enterprises.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] !!!counters in XSL!!!, Jeni Tennison | Thread | Re: [xsl] !!!counters in XSL!!!, David Carlisle |
Re: [xsl] Customised sorting, G. Ken Holman | Date | Re: [xsl] Transforming XSL document, Francis Norton |
Month |