Subject: Re: [xsl] Create Table From: "Eric J. Bowman" <eric@xxxxxxxxxxxxxxxx> Date: Tue, 23 Mar 2010 23:40:38 -0600 |
Since my primary interest in XSLT is Web browsers, I have no intention of learning XSLT 2 anytime soon. XSLT 1 forces one to be clever, I'm actually quite comfortable giving up traditional data structures and conditional logic, so I'll stubbornly cling to it. Stylewise, I look to avoid for-each in favor of apply-templates whenever possible. IOW, no, I don't think a bunch of "or's" is the answer. ;-) All I've done is change the Xpath expressions, the gist of the solution is the same as before, no conditional logic, just some "and's" for node selection. Yeah, each time the goalposts move (due to my misunderstanding), my solution gets a bit uglier... but I like it. Wolfgang's solution is prettier, of course. But, we're both making the same assumption that there is always at least one @section='diff' separating the groups of @section='changes'. -Eric <?xml version='1.0' encoding='utf-8'?> <server-manifest> <interface-categories> <data section='diff'>if (reportService != null)</data> <data section='diff'>return false;</data> <data section='diff'>return true;</data> <data section='changes' field='version'>\main\spr2010_apr_dev\2</data> <data section='changes' field='date'>20100310.102844</data> <data section='changes' field='user'>jryan</data> <data section='changes' field='cr_number'>602018</data> <data section='changes' field='comment'>fix for log 5960</data> <data section='diff'>1296a1297,1298</data> <data section='diff'></data> <data section='diff'>if (reportService != null)</data> <data section='diff'>return true;</data> <data section='diff'>return false;</data> <data section='changes' field='file'>HistoryWages.java</data> <data section='changes' field='version'>\main\spr2009_apr_dev\2</data> <data section='changes' field='date'>20090310.102844</data> <data section='changes' field='cr_number'>602118</data> <data section='changes' field='comment'>fix for log 6950</data> <data section='diff'>1296a1297,1298</data> <data section='diff'></data> <data section='diff'>if (reportService != null)</data> <data section='diff'>return bar;</data> <data section='diff'>return foo;</data> <data section='changes' field='file'>Wages.java</data> <data section='changes' field='date'>20080310.102844</data> <data section='changes' field='user'>ryanj</data> <data section='changes' field='cr_number'>602218</data> <data section='diff'>1296a1297,1298</data> <data section='diff'></data> </interface-categories> </server-manifest> <?xml version='1.0' encoding='utf-8'?> <xsl:stylesheet version='1.0' xmlns='http://www.w3.org/1999/xhtml' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:output omit-xml-declaration='no' method='xml' indent='yes' xml:space='default' encoding='utf-8'/> <xsl:template match='/'> <html xml:lang='en'> <head> <title>table example</title> <style type='text/css'>table{table-layout:fixed;width:auto}</style> </head> <body> <table width='0' summary='summary goes here for accessibility'> <caption>caption goes here for accessibility</caption> <thead> <tr> <th scope='col'>File</th> <th scope='col'>Version</th> <th scope='col'>Date</th> <th scope='col'>User</th> <th scope='col'>CR Number</th> <th scope='col'>Comment</th> </tr> </thead> <tfoot><!-- optional --> <tr> <th>File</th> <th>Version</th> <th>Date</th> <th>User</th> <th>CR Number</th> <th>Comment</th> </tr> </tfoot> <tbody><xsl:apply-templates select="//data[@section='diff']/following-sibling::data[@section='changes'][1]/preceding-sibling::data[1]"/></tbody> </table> </body> </html> </xsl:template> <xsl:template match='data'> <xsl:param name='i' select='position()'/> <tr> <td scope='row'><xsl:value-of select="following-sibling::data[@field='file' and count(preceding-sibling::data[@section='diff']/following-sibling::data[@section='changes'][1])=$i][1]"/> </td> <td><xsl:value-of select="following-sibling::data[@field='version' and count(preceding-sibling::data[@section='diff']/following-sibling::data[@section='changes'][1])=$i][1]"/> </td> <td><xsl:value-of select="following-sibling::data[@field='date' and count(preceding-sibling::data[@section='diff']/following-sibling::data[@section='changes'][1])=$i][1]"/> </td> <td><xsl:value-of select="following-sibling::data[@field='user' and count(preceding-sibling::data[@section='diff']/following-sibling::data[@section='changes'][1])=$i][1]"/> </td> <td><xsl:value-of select="following-sibling::data[@field='cr_number' and count(preceding-sibling::data[@section='diff']/following-sibling::data[@section='changes'][1])=$i][1]"/> </td> <td><xsl:value-of select="following-sibling::data[@field='comment' and count(preceding-sibling::data[@section='diff']/following-sibling::data[@section='changes'][1])=$i][1]"/> </td> </tr> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Create Table, Eric J. Bowman | Thread | Re: [xsl] Create Table, Eric J. Bowman |
Re: [xsl] FO checkbox from 2 inline, Kevin Brown | Date | Re: [xsl] FO checkbox from 2 inline, Jacobus Reyneke |
Month |