Re: mixed content grouping by whitespace
There are two flavours of grouping conditions: patterns and expressions. group-starting/ending-with require patterns while group-by and group-adjacent accept any XPath expression. The latter are being applied to each item of the so-called population in order to calculate grouping keys, the former match specific nodes in the population that will lead or terminate a group.
For all but the nodes marked-up as WS in our example, evaluating self::tei:seg[@type='sep'] yields the empty sequence. Since the empty sequence cannot be used as a grouping key for group-adjacent , its boolean value is calculated, which is false for empty sequences . I could have used empty() instead of boolean() which would just flip each node's true()/false() key. In this case, I would have to swap the "when current-grouping-key" and the "otherwise" actions accordingly, or test="not(current-grouping-key())".
In the word wrap example, it's a matter of taste whether to use group-starting-with or group-adjacent. But try to tackle the group-adjacent example given in the spec  using group-starting-with (or group-ending-with), and you'll find yourself writing all kinds of complicated lookaheads and lookbehinds that for-each-group promised to liberate you from. The same holds for trying to solve group-starting-with problems using group-adjacent. There's a reason THey created all 4 forms of for-each-group. And THey saw it was good.
 http://www.w3.org/TR/xslt20/#err-XTTE1100  http://www.w3.org/TR/xpath-functions/#func-boolean  http://www.w3.org/TR/xslt20/#d5e21264
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format