[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] group-by an optional attribute


Subject: Re: [xsl] group-by an optional attribute
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Nov 2011 13:03:03 -0500

At 2011-11-22 18:22 +0100, Martin Honnen wrote:
Mark wrote:

I tried to formulate an alternative, thinking this would group-by the
true value of @line were it present, or by zero in its absence, but it
fails:
<xsl:for-each-group select="current-group()" group-by="if(Stamp/@line)
then Stamp/@line else 0">

Can you post details as to why exactly this fails? Do you get an error? Does group-by="if (Stamp/@line) then number(Stamp/@line) else 0" work better?

Whenever I have the expression "if ( x ) then x else y" and x is a node, as can be used in this example, I use:


(x,y)[1]

... which in your example translates to:

group-by="number((Stamp/@line,0)[1])"

I hope this helps.

. . . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


Current Thread
Keywords
xml