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

Re: xsl:counter and xsl:counter-increment with XSLT

Subject: Re: xsl:counter and xsl:counter-increment with XSLT
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 05 Nov 1999 07:59:31 -0800
xslt counter
At 99/11/05 08:07 -0700, George Martell wrote:
The problem is that, upon changing from XSL to XSLT, my xsl stylesheets no longer support the use of "counter" and "counter-increment." How can I regain the counter feature?

I had to rewrite my stylesheets rethinking the approach to utilize position() and <xsl:number> ... this wasn't initially easy because not all templates were being invoked with the appropriate node set to produce the correct values for position(), but the fact that <xsl:number> is based on the source node tree meant it was sometimes easier to use that (though my select="expression" attribute sometimes was a bit complex qualifying the nodes being counted).


But, though I found no rule of thumb, in the end it turned out it wasn't difficult, just a matter of thinking of the problem differently. Being classically trained in programming, counters were easy to use. Trying to think in the new approach without being caught in classical concepts was difficult, but the actual use of position() and <xsl:number> turns out to be straightforward if you keep your mindset away from the "old" way of doing things.

While I haven't given you a "replacement" for counter, I hope the above gives some direction on how to look at a different approach. Just think of those constructs you have relative to the set of nodes being processed and the nodes' locations in the source node tree.

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

p.s. one thing I did while doing the conversion was to just comment out the use of the counter constructs until I had debugged the use of position() and <xsl:number> ... that way if I did have a problem, I didn't have to rethink what the old counter solution was, I just looked in the comments at my use of the old constructs ... once I was up and running and fully debugged, I removed the comments.

--
G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/m/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Web site: XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath      ISBN 1-894049-02-0
Next instructor-led training:  1999-11-08, 1999-11-09, 1999-12-05/06,
-                1999-12-07, 2000-02-27/28, 2000-05-11/12, 2000-05-15


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.