[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to calculate rowspan?

Subject: Re: How to calculate rowspan?
From: "cking" <cking@xxxxxxxxxx>
Date: Thu, 26 Aug 2004 14:39:44 +0200
rowspan infinite
Hi Anton,

  <xsl:choose>
   <xsl:when test="@Type='Dimesion'">
    <xsl:variable name="pos" select="position()"/>
    <xsl:variable name="val" select="."/>
    <xsl:if test="not(../preceding-sibling::*[1]/*[$pos and .=$val])">
     <xsl:variable name="rowspan" select="count(../following-sibling::*/*[$pos and .=$val])+1"/>
     <td rowspan="{$rowspan}">
      <xsl:value-of select="."/>
     </td>
    </xsl:if>
   </xsl:when>
   <xsl:otherwise>
    <td>
     <xsl:value-of select="."/>
    </td>
   </xsl:otherwise>
  </xsl:choose>

This will give you the output you want, for your sample input
but... it only works if your "Dimesion" values are unique.
Consider your first column (the "COL0" elements): A-A-A-B-B-C
This is OK. But if you would replace the last 'C' with an 'A'
(A-A-A-B-B-A) it doesn't work anymore because you would get
a rowspan="4" instead of 3.

I hope this solution is sufficient for you, because if you really
need to calculate only consecutive equal values, I'm stuck...

Best regards
Anton Triest

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.