[Home] [By Thread] [By Date] [Recent Entries]
are you using xslt 2 or 1 I'm using Mozilla's XSLT engine (in XULRunner) so as far as I can tell this is XSLT 1.0. In xslt 1 if you want to to much "processing" at the same time as grouping it's almost always easier to do it in two passes, first use the muenchian grouping, as you have it, to remove duplicates and sort, but don't process each group, then (by using a second stylesheet or a x:node-set() extension process the sorted nodes. As described the processing os probably simple enough to do it in one pass, but it's on the edge and if it gets any more complicated definitely doing it in two passes is easier and more maintanable. You're definitely right here, unfortunately the system that performs the transform isn't really built for using multiple passes - and Mozilla's engine doesn't seem to support node-set() yet (it looks like we have to wait for Firefox 3.0 for that.) If on the other hand you're using xslt2 this kind of processing is made much easier with xsl:for-each-group. Yes, looking at John's post this really seems the way to go. I look forward to a version of XULRunner coming out with XSLT 2.0 support :-) In the meantime I think I've come up with a workaround. It means I have to put an xsl:if statement inside every single xsl:for-each, to only do things when position() < 5. It would've been nice to be able to put that condition in the variable definition instead, but as far as I can tell at this point the position() is relative to the rest of the document, not relative to just the nodes I've selected. <xsl:variable name="aAllYears" select="//year[count(. | key('funding-years', .)[1]) = 1 and (. >= $firstYear)]"/> <xsl:for-each select="$aAllYears">
<xsl:sort select="." />
<xsl:if test="position() < 5">
Year: <xsl:value-of select="."/><br/>
</xsl:if>
</xsl:for-each>Thanks for your help! Cheers, Adam.
|

Cart



