|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xslt 2. index-of, nodes
Dave,
>> Erm... my point was that if you were processing the group as a whole
>> then you could use the position() function to get you the position of
>> the <loc> within the group. Something like:
>>
>> <xsl:for-each-group select="loc" group-by="@hl">
>> <xsl:for-each-group select="current-group()" group-by="@side">
>> <xsl:for-each-group select="current-group()" group-by="@pos">
> Ah!
> That's clearer. I've just been fighting group-by="concat...
> which fails :-)
Oh? It shouldn't fail -- you should be able to do:
<xsl:for-each-group select="loc"
group-by="concat(@hl, '+', @side, '+', @pos)">
...
</xsl:for-each-group>
instead of the nesting above, just like you would in the use attribute
of <xsl:key> in 1.0.
Or you can do:
<xsl:for-each-group select="loc"
group-by="string-join((@hl, @side, @pos), '+')">
...
</xsl:for-each-group>
The reason that I didn't use it in the example is that (a) using
concat() is ugly (and string-join() only marginally less so),
particularly because you have to come up with a suitable separator for
the values that you want to include in the grouping key and (b) if
your attributes were typed (e.g. @pos as an xs:integer) then using
separate <xsl:for-each-group>s gives you datatype-aware grouping,
whereas using concat() or string-join() won't unless you are careful.
>> (I can't believe that no one apart from me is bothered about having
>> to nest <xsl:for-each-group> as in the above when you want to group
>> by several things at once.)
>
> Is this a starter for ten for Jeni's own equivalent of Muenchian
> techniques?
I would personally prefer something like:
<xsl:for-each select="loc">
<xsl:group by="@hl" />
<xsl:group by="@side" />
<xsl:group by="@pos" />
...
</xsl:for-each>
but I've suggested it before and no one else seems to think it's worth
changing.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








