Re: [xsl] Is there a way to sometimes bypass a nested for-each group?

Subject: Re: [xsl] Is there a way to sometimes bypass a nested for-each group?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 24 Jul 2008 14:41:09 +0100
> " you were telling me to replace a non-existent sequence with an empty 
> sequence?


No to replace sequences of o-or-1 element nodes, by sequence of strings
of length 1.

You were selecting on SubHeading which selects elemets (an arbitrary
number, but I think that you know from the context that there will be 0
or 1 items in each case.

for-each group (conceptually) first finds all the distinct values  for
the group-by expression and then makes a group for each putting into
each group every item for which the group-by expression includes this
key value. This means that items for which the group--by expression
yields the emptysequence end up in no group.

If instead you do
string(SubHeading)
the the situation is rather different. Firstly if some item has two
subheadings you get an error (from string) rather than the item being
put in two groups. Secondly (and more importantly here) if there is no
subheading you now generate a grouping key (that is a sequence (of
length 1) of values) it's just that the value in this case is "".
this is a perfectly good value for xsl:for-each-group to group on so it
puts all the items that return "" into one group.

David



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread