[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Create Table
bernie bonn wrote: > > HI eric, > > Thanks a ton, I too am developing for a browser, so the > For-each-group although attractive would not work. > > I am experimenting a little more and had another question. I am > trying to work with an attribute called lineId, which has a value of > a line number. I have tried to use a param called 'i' and set it too > the value of the attribute. This works. Wher I am having trouble is > getting the value of the node <data> that has an attribute with a > value of the param + 1. Actually I can't even get the attribute to > evaluate against the attribute = to the param. > > I have something like : > > <xsl:param name='i' select='./@lineId' ></xsl:param> > > --then something like > select='data[@lineId=$x]'/> > xsl:value-of > --This 'seems like it should work, and then I could also evalute to $ > +1, but I can't get results. > > Any ideas, Thanks again. BTW this is the same file... > OK, I've added @lineId back into the source and updated my example to include a solution to the following problem: We want each row's <th> to contain the @lineId of the first <data section='changes'/> in each group. IOW, we need the @lineId of the next <data/> element following the node selected by <xsl:apply-templates/> (@lineId+1), because it's the same problem as before. So this answer extends the example already given, by adding the number() function. Since this value will always exist, it's a logical choice for row headings, because it allows the use of the Basic algorithm for <table> markup -- which is always the most desirable solution to any table design, if possible. So this is an improvement to the example, using an existing source-file attribute. Always happy to help, let me know if this goes far enough. -Eric <?xml version='1.0' encoding='utf-8'?> <server-manifest> <interface-categories> <data lineId='1' section='diff'>if (reportService != null)</data> <data lineId='2' section='diff'>return false;</data> <data lineId='3' section='diff'>return true;</data> <data lineId='4' section='changes' field='version'>\main\spr2010_apr_dev\2</data> <data lineId='5' section='changes' field='date'>20100310.102844</data> <data lineId='6' section='changes' field='user'>jryan</data> <data lineId='7' section='changes' field='cr_number'>602018</data> <data lineId='8' section='changes' field='comment'>fix for log 5960</data> <data lineId='9' section='diff'>1296a1297,1298</data> <data lineId='10' section='diff'></data> <data lineId='11' section='diff'>if (reportService != null)</data> <data lineId='12' section='diff'>return true;</data> <data lineId='13' section='diff'>return false;</data> <data lineId='14' section='changes' field='file'>HistoryWages.java</data> <data lineId='15' section='changes' field='version'>\main\spr2009_apr_dev\2</data> <data lineId='16' section='changes' field='date'>20090310.102844</data> <data lineId='17' section='changes' field='cr_number'>602118</data> <data lineId='18' section='changes' field='comment'>fix for log 6950</data> <data lineId='19' section='diff'>1296a1297,1298</data> <data lineId='20' section='diff'></data> <data lineId='21' section='diff'>if (reportService != null)</data> <data lineId='22' section='diff'>return bar;</data> <data lineId='23' section='diff'>return foo;</data> <data lineId='24' section='changes' field='file'>Wages.java</data> <data lineId='25' section='changes' field='date'>20080310.102844</data> <data lineId='26' section='changes' field='user'>ryanj</data> <data lineId='27' section='changes' field='cr_number'>602218</data> <data lineId='28' section='diff'>1296a1297,1298</data> <data lineId='29' 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>Line #</th> <th>File</th> <th>Version</th> <th>Date</th> <th>User</th> <th>CR Number</th> <th>Comment</th> </tr> </thead> <tfoot><!-- optional --> <tr> <th>Line #</th> <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> <th><xsl:value-of select='number(./attribute::lineId)+1'/></th> <td><xsl:value-of select="following-sibling::data[@field='file' and count(preceding-sibling::data[@section='diff']/following-sibling::data[@secti on='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[@secti on='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[@secti on='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[@secti on='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[@secti on='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[@secti on='changes'][1])=$i][1]"/> </td> </tr> </xsl:template> </xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|