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

Re: Grouping by distinct combinations of descendant e

Subject: Re: Grouping by distinct combinations of descendant elements in xsl 2.0 and xpath 2.0
From: Simon Pepping <sampepping@xxxxxxxxx>
Date: Mon, 13 Feb 2012 14:29:06 +0100
Re:  Grouping by distinct combinations of descendant  e
<xsl:for-each-group select="$ap-groups"
group-by="xx:get-dates(Appointment/@Date,'')">

should be replaced by a simple call to string-join:

<xsl:for-each-group select="$ap-groups"
group-by="string-join(Appointment/@Date,':')">

Simon

On Mon, Feb 13, 2012 at 14:02, Simon Pepping <sampepping@xxxxxxxxx> wrote:
> Hi,
>
> This does the grouping that you want:
>
>   <xsl:template match="/">
>     <xsl:variable name="appointments" as="element(Appointment)+">
>       <xsl:for-each select="//Invitee">
>         <Appointment Date="{../@Date}" TimeOfDay="{../@TimeOfDay}"
> AppointmentType="{../@AppointmentType}"
>           Firstname="{@Firstname}" Surname="{@Surname}"
> Name="{concat(@Firstname,@Surname)}"/>
>       </xsl:for-each>
>     </xsl:variable>
>     <xsl:variable name="ap-groups" as="element(ap-group)+">
>       <xsl:for-each-group select="$appointments"
> group-by="concat(@TimeOfDay,'-',@AppointmentType,'-',@Name)">
>         <ap-group key="{current-grouping-key()}">
>           <xsl:for-each select="current-group()">
>             <xsl:copy-of select="."/>
>           </xsl:for-each>
>         </ap-group>
>       </xsl:for-each-group>
>     </xsl:variable>
>     <xsl:variable name="ap-groups-by-set">
>       <xsl:for-each-group select="$ap-groups"
> group-by="xx:get-dates(Appointment/@Date,'')">
>         <ap-group-by-set key="{current-grouping-key()}">
>           <xsl:for-each select="current-group()">
>             <xsl:copy-of select="."/>
>           </xsl:for-each>
>         </ap-group-by-set>
>       </xsl:for-each-group>
>     </xsl:variable>
>     <Appointments>
>       <xsl:for-each select="$ap-groups-by-set">
>         <xsl:copy-of select="."/>
>       </xsl:for-each>
>     </Appointments>
>   </xsl:template>
>
>   <xsl:function name="xx:get-dates">
>     <xsl:param name="Dates"/>
>     <xsl:param name="dates"/>
>     <xsl:choose>
>       <xsl:when test="$Dates">
>         <xsl:variable name="dates-c">
>           <xsl:if test="$dates">
>             <xsl:text>:</xsl:text>
>           </xsl:if>
>         </xsl:variable>
>         <xsl:value-of
>
select="xx:get-dates($Dates[position()!=1],concat($dates,$dates-c,$Dates[1]))
"/>
>       </xsl:when>
>       <xsl:otherwise>
>         <xsl:value-of select="$dates"/>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:function>

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.