RE: Incrementing a counter
> 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? You need to think about a higher-level description of your problem, and not about how you would solve it in an imperative programming language. > > > 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 This "sorting and comparing to the previous category" is a procedural algorithm for doing grouping. Grouping in XSLT 2.0 is done using xsl:for-each-group; in 1.0 it's done (clumsily) using keys as described at http://www.jenitennison.com/xslt/grouping. Numbering items within a group can be done using the position() function. Michael Kay http://www.saxonica.com/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format