Subject: Re: [xsl] Merging elements within a range using a key From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 2 May 2006 12:11:57 +0100 |
well you could modify your template like so: <xsl:key name="r" match="row" use="@r"/> <xsl:template match="category"> <xsl:variable name="row-test"> <!-- should be improved with a key --> <xsl:variable name="s" select="@s"/> <xsl:variable name="r" select="1+ @e - $s"/> <xsl:for-each select="(//*)[position()<=$r]"> <xsl:copy-of select="key('r',position()+$s - 1)" /> </xsl:for-each> </xsl:variable> . . . But if in your real case your row elements are already sorted in order and each has a unique @r attribute then each of these keys is just picking up a single row, the one after you picked up last time, so as Mike just said, it's probably better just to make a template that recursively walks along the row siblings checking the condition as you go along. I left the rest of your stylesheet the same although there seemed to be something a bit odd about <xsl:if test="string-length($row-test) > 0"> <xsl:choose> <xsl:when test="category"> which is apparently testing for category children of the current category element. If there are nested categories I'm not sure if these keys (or your original XPath) would pick up the right thing, it depends what the meaning of any such nesting is. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Merging elements within a, Michael Kay | Thread | Re: [xsl] Merging elements within a, Mike B |
RE: [xsl] XSL to output new XML doc, Michael Kay | Date | RE: [xsl] Merging elements within a, Mike B |
Month |