xsl-list
[Top] [All Lists]

RE: date duration grouping question

2006-01-31 04:20:08
Clearly there's more than once answer: you could group (1,2,3 Jan), (4,5,6
Jan) or you could group (2,3,4 Jan), (5,6,7 Jan), or you could set the
baseline to the earliest dateTime, 2006-01-05T18:49:00, or to its date part,
etc.

Assuming 2.0 and schema-awareness, use

<xsl:variable name="origin" as="xs:dateTime"
select="xs:date('2006-01-01T00:00:00')"/>
<xsl:variable name="three-days" as="xdt:dayTimeDuration"
select="xdt:dayTimeDuration('P3D')"/>

<xsl:for-each-group select="times" 
         group-by="((@start - $origin) div $three-days) idiv 1">

If not schema-aware, you need to cast the attribute to a dateTime.

If not on 2.0, you're a masochist.

Michael Kay
http://www.saxonica.com/
 

-----Original Message-----
From: Kent Seegmiller [mailto:hookjaw20(_at_)comcast(_dot_)net] 
Sent: 31 January 2006 07:02
To: XSLT
Subject: [xsl] date duration grouping question

I am trying to group a list of datetimes by 3 day intervals
<alltimes>
  <times dur="PT3H52M" start="2006-01-05T18:49:00" 
end="2006-01-05T22:42:00" 
/>
  <times dur="PT4H16M" start="2006-01-06T19:48:00" 
end="2006-01-07T00:05:00" 
/>
  <times dur="PT3H50M" start="2006-01-08T18:00:00" 
end="2006-01-08T21:51:00" 
/>
  <times dur="PT5H8M" start="2006-01-10T19:51:00" 
end="2006-01-11T00:59:00" 
/>
  <times dur="PT3H39M" start="2006-01-11T19:26:00" 
end="2006-01-11T23:05:00" 
/>
  <times dur="PT3H57M" start="2006-01-12T20:49:00" 
end="2006-01-13T00:46:00" 
/>
  <times dur="PT0H59M" start="2006-01-13T20:51:00" 
end="2006-01-13T21:50:00" 
/>
  <times dur="PT2H22M" start="2006-01-17T00:29:00" 
end="2006-01-17T02:52:00" 
/>
  <times dur="PT3H23M" start="2006-01-17T18:33:00" 
end="2006-01-17T21:56:00" 
/>
  <times dur="PT3H19M" start="2006-01-18T18:36:00" 
end="2006-01-18T21:55:00" 
/>
  <times dur="PT3H19M" start="2006-01-20T18:36:00" 
end="2006-01-20T21:55:00" 
/>
</alltimes>
How would I group the @start attributes by 3 days? 


--~------------------------------------------------------------------
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>
--~--





--~------------------------------------------------------------------
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>