|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Merging elements within a range using a key
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
________________________________________________________________________
|
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
|






