Re: [xsl] A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14)

Subject: Re: [xsl] A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 5 May 2005 09:47:51 +0100
> How long did it take you to come up with this solution?  

As anyone reading this list may have noticed, my typing isn't that
accurate so it probably look me longer to type it in (and a lot longer to
type that last reply) than it did to actually come up with the code.
Starting from scratch it would have taken longer as I wouldn't have had
a clear view of the criterion for what constituted a range from the
original description, but once someone (Michael, I think) commented the
test for whether a <B> element terminated a range could be a simple test
whether any other element overlapped this one, the rest of it followed
more or less naturally.

> Have you seen similar problems like this in the past 

Once it is was clear that there was an atomic test that you could do
that flagged when the group needed to change then it's pretty much a
standard grouping question of the type that we see on this list every day
for the last 7 years or so:-) The thing that makes this one a bit more
interesting (and stops the usual grouping solutions working out of the
box) is that you need to add an attribute to the grouping element that
you don't know until the end of the group. As you have to add attributes
before child elements this means that you have to save up the child
elements to add later, hence the $g parameter. Apart from that it's a
standard "tree walking" grouping method, another example of which I
posted in another thread earlier in the week (in that case grouping on
processing instruction nodes)

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread