|
Subject: Re: [xsl] How to calculate rowspan? From: "cking" <cking@xxxxxxxxxx> Date: Thu, 26 Aug 2004 14:39:44 +0200 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] How to calculate rowspan?, anton | Thread | RE: [xsl] How to calculate rowspan?, anton |
| Re: [xsl] XSL and infinite loops, David Carlisle | Date | Re: [xsl] How to calculate rowspan?, David Carlisle |
| Month |