xsl-list
[Top] [All Lists]

[xsl] Create Table

2010-03-20 12:53:28
Hi,
 
I have an XML file that is exported from a IBM BuildForge.  I am attempting to 
display as HTML, and could use some guidance.  
 
The part of the file I am concerned with is the Source Code changes.  There are 
a series of data nodes that represent either headings or ‘diffs’ or detail to 
the headings. 
The headings are denoted by the attribute section=’changes’.  Basically,  every 
time I encounter this section I want to make a new table row and fill the cells 
with the different value of the element, or I could even create a whole new 
table.  The problem I am having is testing if a fild is missing, some entries 
don't have a field="file for example.  In that case I have to leave a blank 
cell. Here is a sample of the xml:
 
Thanks SO much for any help, I am pretty new to this stuff (probably obvious)   
I would also appreciate guidance if I am 'totally ' heading down the wrong 
road.  :)


*******************XML 
file********************************************************** 
<BOM>
<server-manifest>                    
………..
Other stuff…..
…………
            
<categoryname="Source Changes"category="Source">
<datalineId="41"section="diff"field="diff">&gt;                        if 
(reportService != null)</data>
<datalineId="42"section="diff"field="diff">&gt;                                 
   return true;</data>
<datalineId="43"section="diff"field="diff">&gt;                        return 
false;</data>
<datalineId="44"section="changes"field="file">.\payx\domain\dev\src\com\paychex\spr\domain\conversion\task\ConvertHistoryWages.java</data>
<datalineId="45"section="changes"field="version">\main\spr2010_apr_dev\2</data>
<datalineId="46"section="changes"field="date">20100310.102844</data>
<datalineId="47"section="changes"field="user">jryan</data>
<datalineId="48"section="changes"field="cr_number">602018</data>
<datalineId="49"section="changes"field="comment">fix for log 5960</data>
<datalineId="50"section="diff"field="diff">1296a1297,1298</data>
<datalineId="51"section="diff"field="diff">&gt;                                 
   } else {</data>
 
….Other stuff
 ******************************************************************************************

Here is what I have tried:  Sorry about the messy code, I have been fooling 
around with it al lot. 
The Choose statement results in one long row for all data, and doesn’t catch if 
something is missing. I had trouble forcin a <tr>.
I also tried an If statement that comes closer(it creates the correct table, 
except again it doesn’t catch the entry doesn’t have ‘date’ value for example.  
 I tried nesting an If but it didn’t seem to work.  
 
<tableborder="1">
            <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-eachselect="BOM/interface-categories/category[(_at_)category='Source']/data[(_at_)section='changes']">
      
            <xsl:choose>
                                    
<xsl:whentest="current()[(_at_)section='changes' and @field='file']">
                                                            
<td><xsl:value-ofselect="."/></td>
                        </xsl:when>
                        <xsl:whentest="current()[(_at_)section='changes' and 
@field='version']">
                                                            
<td><xsl:value-ofselect="."/></td>
                        </xsl:when>
                        <xsl:whentest="current()[(_at_)section='changes' and 
@field='date']">
                                                            
<td><xsl:value-ofselect="."/></td>
                        </xsl:when>
                        <xsl:whentest="current()[(_at_)section='changes' and 
@field='user']">
                                                            
<td><xsl:value-ofselect="."/></td>
                        </xsl:when>
                        <xsl:whentest="current()[(_at_)section='changes' and 
@field='cr_number']">
                                                            
<td><xsl:value-ofselect="."/></td>
                        </xsl:when>
                        <xsl:whentest="current()[(_at_)section='changes' and 
@field='comment']">
                                                            
<td><xsl:value-ofselect="."/></td>
                        </xsl:when>
                        <xsl:otherwise>
                                                            <td>xxxxxxFigure 
out a way to leave a blank cellxxxxxx</td>
                        </xsl:otherwise>
            
            </xsl:choose>
 
****************If statement********************
 
<xsl:iftest = "current()[(_at_)section='changes' and @field='file']">
                             <td><xsl:value-ofselect="."/></td>
                             <xsl:iftest="current()[(_at_)field!='file']">
                             <td>********Not equal to File***********</td>
                             </xsl:if>                      
             </xsl:if>
            <xsl:iftest = "current()[(_at_)section='changes' and 
@field='version']">
                             <td><xsl:value-ofselect="."/></td>
                                    </xsl:if>
            <xsl:iftest = "current()[(_at_)section='changes' and 
@field='date']">
                             <td><xsl:value-ofselect="."/></td>
             </xsl:if>
            <xsl:iftest = "current()[(_at_)section='changes' and 
@field='user']">
                             <td><xsl:value-ofselect="."/></td>
             </xsl:if>
            <xsl:iftest = "current()[(_at_)section='changes' and 
@field='cr_number']">
                             <td><xsl:value-ofselect="."/></td>
             </xsl:if>
            <xsl:iftest = "current()[(_at_)section='changes' and 
@field='comment']">
                             <td><xsl:value-ofselect="."/></td>
<tr/>     
             </xsl:if>


      

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>