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


... which in your example translates to:


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
Crane Softwrights Ltd.  
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile:
Legal business disclaimers:

Current Thread