|
Subject: Re: [xsl] 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 |
<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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Grouping by distinct comb, Simon Pepping | Thread | [xsl] format-number issue, henry human |
| Re: [xsl] Grouping by distinct comb, Simon Pepping | Date | Re: [xsl] XSLT 2 processors, Michael Kay |
| Month |