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

Using XSL to Translate Repetitive-Node XML to Table wi

Subject: Using XSL to Translate Repetitive-Node XML to Table with COLSPANs
From: "Hart, Leo" <Leo.Hart@xxxxxxx>
Date: Thu, 12 Feb 2004 15:49:56 -0500
leo translate
Hello,

I have the following xml file:

	<column_header>
		<header rowid="0">
			<data columnid="01" name="2003"/>
			<data columnid="11" name="2003"/>
			<data columnid="21" name="2003"/>
			<data columnid="31" name="2003"/>
			<data columnid="41" name="2003"/>
			<data columnid="51" name="2003"/>
			<data columnid="61" name="2003"/>
			<data columnid="71" name="2003"/>
		</header>
		<header rowid="1">
			<data columnid="01" name="Feb"/>
			<data columnid="11" name="Feb"/>
			<data columnid="21" name="Feb"/>
			<data columnid="31" name="Feb"/>
			<data columnid="41" name="Y-T-D(Feb)"/>
			<data columnid="51" name="Y-T-D(Feb)"/>
			<data columnid="61" name="Y-T-D(Feb)"/>
			<data columnid="71" name="Y-T-D(Feb)"/>
		</header>
		<header rowid="2">
			<data columnid="01" name="Actual"/>
			<data columnid="11" name="Budget"/>
			<data columnid="21" name="Fav/(Unfav) $"/>
			<data columnid="31" name="Fav/(Unfav) %"/>
			<data columnid="41" name="Actual"/>
			<data columnid="51" name="Budget"/>
			<data columnid="61" name="Fav/(Unfav) $"/>
			<data columnid="71" name="Fav/(Unfav) %"/>
		</header>
	</column_header>

And I'm trying to get the results to look like this:

	<table border="1" cellpadding="0" cellspacing="0"
bordercolor="#111111">
		<tr>		
			<td colspan="8">2003</td>
		</tr>
		<tr>
			<td colspan="4">Feb</td>
			<td colspan="4">Y-T-D(Feb)</td>
		</tr>
		<tr>
			<td>Actual</td>
			<td>Budget</td>
			<td>Fav/(Unfav) $</td>
			<td>Fav/(Unfav) %</td>
			<td>Actual</td>
			<td>Budget</td>
			<td>Fav/(Unfav) $</td>
			<td>Fav/(Unfav) %</td>
		</tr>
	</table>

Basically I'm doing grouping, which I have seen numerous postings for, but
couldn't find anything that dealt with actual colspans and the such.  My
first idea was to use the "following-sibling::data[1]/@name = @name" test to
keep track of how many columns to span.  If the above test was false, I
would draw the table cell using the current colspan counter.  Otherwise, if
the above test was true, then I would skip drawing the table cell and
increment the colspan counter.

Therein lies my problem as XSLT doesn't have counters and, according to
everything I've read, if I wise in the ways of XSLT (which I'm not, but I'm
trying!) then I'd know how to do this without one!

But I really can't get my procedural-coding mind to figure this out in XSLT!

Any suggestions? I'm sure this is a simple one for the gurus...

Thanks a lot,
Leo Hart



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.