Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Merging elements within a range using a key

From: David Carlisle <davidc@--------->
To:
Date: 5/2/2006 11:16:00 AM
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()&lt;=$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
________________________________________________________________________


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent