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

Incrementing a counter

Subject: Incrementing a counter
From: "Warren, Keith" <KWARREN@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 13 Jun 2007 18:36:30 -0500
 Incrementing a counter
I'm a newbie to XSLT, but have a lot of scripting experience.

I have a problem that I cannot solve and would appreciate some help.
>From what I understand about variables in XSLTs, you can't change the
value. So if that's true, how can I increment a counter?

My problem is that I need to to create a single header that appears over
a list of similar items. In the XML file, we store the "Category"
attribute. So I may have 20 Sports items, 10 News items and 5 Features
items. I need to transform the XML into a text file that should look like
this:

Sports
1.
2.
3.
etc

News
1.
2.
3.
etc

Features
1.
2.
3.
etc

In my scripting experience, I would sort the list by category, create
a counter and loop through the list of items comparing each subsequent
item to the previous item. It it was the same, I would ignore the
category. That may not be the most elegant solution, but it works

How would I achieve that with XSLT?

Thanks,
KW

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.