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

Re: [xsl] Including node in group when grouping key is null

Subject: Re: [xsl] Including node in group when grouping key is null
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxx>
Date: Thu, 9 Jan 2014 12:10:24 -0500


Gerrit offers an elegant solution provided your @type values are
controlled to avoid 'primary' in the data. :-)

More generally, you should find that group-by="@type" does not fail to
group nodes for which @type is empty. If you want to avoid those, you
need to select="author[exists(@type)". If you want to include them,
they'll be grouped with a key of '' (the empty string), along with
those that have @type=''. This is because the value returned by
@group-by is cast to a string, and string(()) is "".

Assuming @type will never be 'primary' (or whatever fallback value you
choose), Gerrit's solution succeeds in grouping authors with no @type
separately from authors with @type=''. Which is another reason to like

Cheers, Wendell

Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables

On Thu, Jan 9, 2014 at 2:16 AM, Imsieke, Gerrit, le-tex
<gerrit.imsieke@xxxxxxxxx> wrote:
> On 09.01.2014 08:11, Steve Fogel wrote:
>> <xsl:for-each-group select="author" group-by="@type">
> group-by="(@type, 'primary')[1]"

Current Thread