[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: date duration grouping question

Subject: RE: date duration grouping question
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 31 Jan 2006 11:20:08 -0000
2006 01 01t00 00 00
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@xxxxxxxxxxx] 
> Sent: 31 January 2006 07:02
> To: XSLT
> Subject:  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? 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.