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

Re: !!!counters in XSL!!!

Subject: Re: !!!counters in XSL!!!
From: Alexey Gokhberg <alexei@xxxxxxxxxx>
Date: Thu, 05 Apr 2001 10:53:43 +0200
xslt counters
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

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.