xsl-list
[Top] [All Lists]

Re: [xsl] group-by an optional attribute

2011-11-22 12:03:45
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(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--