xsl-list
[Top] [All Lists]

[xsl] Incrementing a counter

2007-06-13 16:37:08
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






--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>