[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Create Table
Subject: Re: [xsl] Create Table From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx> Date: Tue, 23 Mar 2010 18:40:04 +0100 |
The solution given below uses grouping (XSLT 2.0). It assumes that there is some <data section="diff"> (or some value other than "changes") between each group with <data section="changes". ..>. Otherwise, there is a problem to discern the groups since any field may be absent. <tbody> <tr> <!--****Static Table Headings***--> <th>File</th> <th>Version</th> <th>Date</th> <th>User</th> <th>CR Number</th> <th>Comment</th> </tr> <xsl:for-each-group select="BOM/interface-categories/data" group-adjacent="@section"> <xsl:if test="current-grouping-key() = 'changes'"> <tr> <xsl:for-each select="for $x in ('file','version','date','user', 'cr_number','comment') return ((current-group()[@field=$x],' ')[1])"> <td><xsl:value-of select="."/></td> </xsl:for-each> </tr> </xsl:if> </xsl:for-each-group> </tbody> On Tue, Mar 23, 2010 at 4:55 PM, bernie bonn <moochambo@xxxxxxxxx> wrote: > > Eric, as always thanks for your help. I really appreciate it. I wish your assumption was true, unfortunatley it isn't, the @field='file' is not a mandatory field . I wonder if a bunch of 'ors' would work? Anyway, I'll have to dig deeper or attack this problem at the source, the export of the XML, (I have been told we have no control over it. ) > > Thanks again, I am going to look over the code to better understand what you did. > > Bernie > > > > ----- Original Message ---- > From: Eric J. Bowman <eric@xxxxxxxxxxxxxxxx> > To: bernie bonn <moochambo@xxxxxxxxx> > Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Sent: Tue, March 23, 2010 1:21:57 AM > Subject: Re: [xsl] Create Table > > My solution assumes @field='file' is a mandatory field, i.e. won't be > missing. The gist of it is, the number of @field='file' <data> elements > above a given <data section='changes'> must equal the position() of the > //data[@field='file'] that triggered the xsl:apply-templates. > > -Eric > > <?xml version='1.0' encoding='utf-8'?> > <server-manifest> > <category-source> > <interface-categories> > <data section='diff'>if (reportService != null)</data> > <data section='diff'>return true;</data> > <data section='diff'>return false;</data> > <data section='changes' field='file'>ConvertHistoryWages.java</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 true;</data> > <data section='diff'>return false;</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> > </category-source> > </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> > <td> </td> > <th>Version</th> > <th>Date</th> > <th>User</th> > <th>CR Number</th> > <th>Comment</th> > </tr> > </thead> > <tfoot><!-- optional --> > <tr> > <td> </td> > <th>Version</th> > <th>Date</th> > <th>User</th> > <th>CR Number</th> > <th>Comment</th> > </tr> > </tfoot> > <tbody><xsl:apply-templates select="//data[@field='file']"/></tbody> > </table> > </body> > </html> > </xsl:template> > <xsl:template match='data'> > <xsl:param name='i' select='position()'/> > <tr> > <th><xsl:value-of select='.'/></th> > <td><xsl:value-of select="following-sibling::data[@field='version' and count(preceding-sibling::data[@field='file'])=$i]"/> </td> > <td><xsl:value-of select="following-sibling::data[@field='date' and count(preceding-sibling::data[@field='file'])=$i]"/> </td> > <td><xsl:value-of select="following-sibling::data[@field='user' and count(preceding-sibling::data[@field='file'])=$i]"/> </td> > <td><xsl:value-of select="following-sibling::data[@field='cr_number' and count(preceding-sibling::data[@field='file'])=$i]"/> </td> > <td><xsl:value-of select="following-sibling::data[@field='comment' and count(preceding-sibling::data[@field='file'])=$i]"/> </td> > </tr> > </xsl:template> > </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Create Table, bernie bonn | Thread | Re: [xsl] Create Table, Eric J. Bowman |
RE: [xsl] Merging structure and con, Michael Kay | Date | Re: [xsl] Merging structure and con, Jacobus Reyneke |
Month |
Keywords