xsl-list
[Top] [All Lists]

[xsl] group-by an optional attribute

2011-11-22 11:12:53
Hi,
Consider:
<xsl:for-each-group select="current-group()" group-by="Stamp/@line"

This fails because @line is an optional attribute and does not always appear in the XML. The only cure I can think of is to run a pre-processing stylesheet that, should the @line attribute be absent from a <Stamp> element, adds an @line="0" to each <Stamp> element. This is not a problem, but I wondered if there were another more elegant means making the group-by work?

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

Thanks for any help,
Mark



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