xsl-list
[Top] [All Lists]

RE: Nested for-each-group

2004-09-28 06:01:13

Thanks Mike, 

Plenty to work with there :)

Cheers
andrew


group-starting-with and group-ending-with partition the 
population: the first/last item in the population starts/ends 
a group whether or not it matches the pattern. 

The simplest way to discard the spurious groups in this case 
is probably to do 

xsl:if test="position()=last()" 

in the outer group, and

xsl:if test="position()=1"

in the inner group.

An interesting way of tackling the problem. I think I would have used
"intersect":

<div>
 <xsl:value-of select="
    sum (    
      (col[(_at_)colname=$s]/(.|following-sibling::col)
               intersect
       col[(_at_)colname=$e]/(.|preceding-sibling::col))/@width)"/>
</div>

Unless I thought about it more carefully (!), in which case I 
would use a predicate of the form:

sum(col[. is $S or . is $E or (. >> $S and . << $E)])

Yet another solution:

for $s in index-of(col/@colname, $start),
    $e in index-of(col/@colname, $end)
return
    sum(subsequence(col/@width, $s, $e - $s + 1)), 


<Prev in Thread] Current Thread [Next in Thread>