Subject: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] IBM releases free 2004 Middle, Frank Carlos | Thread | Re: [xsl] Using XSL to Translate Re, Wendell Piez |
Re: [xsl] Mixed Contents, J.Pietschmann | Date | Re: [xsl] Using XSL to Translate Re, Wendell Piez |
Month |