Subject: For-each issues
Posted By: hiskeyd Post Date: 2/27/2006 6:22:58 PM
Hi,

I am a bit of a newbie with XSL and I am stuck with the following issue.

I am selecting a bunch of "Date" records with a for-each loop, from that I then want to (within that for-each loop) grab all the records associated with a certain date.  

So for instance:

Date1:  Item1, Item2, Item3
Date2:  Item4, Item5, Item6  etc.

But  I can't seem to wrap my head around the syntax for doing this.  
right now my code outputs this

Date1: Item1
Date1: Item2
Date1: Item3
Date2: Item4
etc.

Thats with one for-each loop.

So once I have selected all the "Date" records how do I then compare within that to get all the records associated with the certain date?

I tried doing it with a nested for-each loop, where I was just selecting all the "Date" records again with a for-each, the same as the parent for-each loop, but it ends up not working.  

Any ideas?  Is there a much easier way to do this?  As I said, I'm a newbie, I've been working with XSL for about three days.

hiskeyd
http://www.vicasting.com
Reply By: mhkay Reply Date: 2/27/2006 7:01:02 PM
It's a bit hard to work out what the problem is as you haven't shown the structure of your data and you haven't shown any code. Are there duplicate dates and you want to process each group of duplicates once only? In that case, it's a grouping problem. Grouping is quite tough to tackle in XSLT 1.0 - see www.jenitennison.com/xslt/grouping for advice - it gets much easier in 2.0 with an xsl:for-each-group construct.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Go to topic 39440

Return to index page 357
Return to index page 356
Return to index page 355
Return to index page 354
Return to index page 353
Return to index page 352
Return to index page 351
Return to index page 350
Return to index page 349
Return to index page 348