Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Help required in Grouping by category >Thread Next - Re: Help required in Grouping by category Re: Help required in Grouping by categoryTo: NULL Date: 5/11/2007 8:14:00 AM You're using a Microsoft style XML recordset so I'll assume you are using XSLT 1.0. Your thinking in a more procedural way, XSLT is functional and there's no way to loop through records and alter variables. Grouping is usually done using the Muenchian technique, there are examples here: http://www.jenitennison.com/xslt/grouping/muenchian.xml -- Joe Fawcett (MVP - XML) http://joe.fawcett.name "RJN" <rjn@y...> wrote in message news:%230Hmid4kHHA.3656@T...... > Hi > > I'm new to xsl and need help in grouping elements in xsl. > > I've an xml as below > > <rs:data ItemCount="4"> > <z:row Title="Title1" Description="Desc1" Category="AAA" /> > <z:row Title="Title2" Description="Desc2" Category="AAA" /> > <z:row Title="Title3" Description="Desc3" Category="BBB" /> > <z:row Title="Title4" Description="Desc4" Category="CCC" /> > </rs:data> > > There are multiple elements in each category. I would want to render > this xml grouped by Category through an xsl as: > > AAA > Title1, Desc1 > Title2, Desc2 > > BBB > Title3, Desc3 > > CCC > Title4, Desc4 > > > I thought I'll apply the for-each loop and then either create an array > which contains the distinct category or create a delimited string with > the distinct categories. Once I've the distinct categories, I can apply > the for-each loop again and apply the xpath to get the corresponding > categories.It seems xsl doesn't support array, nor does it allow me to > change the value of variable. It doesn't allow me declare the variable > and then assign the value inside the for-each loop. > > Could someone help me with this xsl transformation? Is there a way that > I can declare a global variable under xsl:stylesheet and change value of > when looping through the nodes? > > Your help is greatly appreciated. > > Regards > > rn > > > > > > > > > *** Sent via Developersdex http://www.developersdex.com *** | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
