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

Re: Output rowspan on multiple columns

Subject: Re: Output rowspan on multiple columns
From: George Cristian Bina <george@xxxxxxxxxxxxx>
Date: Thu, 17 May 2007 18:45:57 +0300
Re:  Output rowspan on multiple columns
Hi Clifton,

Match only on partition elements and check if you are on the first partition or on the first drive and in each case generate the corresponding columns with rowspan:

<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes"/>
    <xsl:template match="summary">
        <table border="1">
            <xsl:apply-templates/>
        </table>
    </xsl:template>

    <xsl:template match="partition">
        <tr>
            <xsl:if test="not(preceding-sibling::partition) and
                not(../preceding-sibling::drive)">
                <td rowspan="{count(../..//partition)}">
                    <xsl:value-of select="../@name"/>
                </td>
            </xsl:if>

            <xsl:if test="not(preceding-sibling::partition)">
                <td rowspan="{count(../partition)}">
                    <xsl:value-of select="../@name"/>
                </td>
            </xsl:if>
            <td>
                <xsl:value-of select="@name"/>
            </td>
        </tr>
    </xsl:template>
    <xsl:template match="text()"/>
</xsl:stylesheet>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina - http://aboutxml.blogspot.com/
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Clifton Mullen wrote:
I'm trying to build a table with three columns.  The first two may have
a rowspan attribute.  Something like this...

<table border=1>
	<tr>
		<td rowspan=5>Comp1</td>
		<td rowspan=3>Drive1</td>
		<td>Partition1</td>
	</tr>
	<tr>
		<td>Partition2</td>
	</tr>
	<tr>
		<td>Partition3</td>
	</tr>
	<tr>
		<td rowspan=2>Drive2</td>
		<td>Partition4</td>
	</tr>
	<tr>
		<td>Partition5</td>
	</tr>
</table>

... from data like this...

<summary>
	<comp name="Comp1">
		<drive name="Drive1">
			<partition name="Partition1" />
			<partition name="Partition2" />
			<partition name="Partition3" />
		</drive>
		<drive name="Drive2">
			<partition name="Partition4" />
			<partition name="Partition5" />
		</drive>
	</comp>
	...  more comp  ...
</summary>

I've tried nested for-each and template matches and just can't figure
it out.  Any help is appreciated.

Regards,
Cliff

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.