xsl-list
[Top] [All Lists]

Re: Creating Columnar Table format with XML data

2005-08-14 01:28:21
I think it is difficult to build the intelligence you want into the
stylesheet (probably someone could correct me).

Here is the XSLT stylesheet I wrote.

<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
 
<xsl:output method="html" indent="yes" /> 
 
<xsl:template match="/root">
   <html>
     <head>
       <title/>
     </head>
     <body>
       <table>  
         <tr>
           <xsl:apply-templates select="column" />           
         </tr>
         <xsl:call-template name="printRows">
           <xsl:with-param name="list"
select="descendant::bullet[(_at_)ID='1'] | descendant::bullet[(_at_)ID='3']" />
         </xsl:call-template>
         <xsl:call-template name="printRows">
           <xsl:with-param name="list" select="descendant::bullet[(_at_)ID='2'] 
|
descendant::bullet[(_at_)ID='4']" />
         </xsl:call-template>
       </table>
     </body>
   </html>
 </xsl:template>

 <xsl:template match="column">   
   <td>
     <xsl:value-of select="@title" />
   </td>      
</xsl:template>
 
<xsl:template name="printRows">
   <xsl:param name="list" />
   
   <tr>
     <xsl:for-each select="$list">
       <td>
         <xsl:value-of select="tip" />
       </td>
     </xsl:for-each>
   </tr>
</xsl:template>
 
</xsl:stylesheet>

Regards,
Mukul


On 8/14/05, Maria Leggett <maria(_at_)idwebworks(_dot_)com> wrote:
I have an xml file that I need to create into a columnar table format.  I
can't figure out how to group the data to display in a column when not all
the column rows cells will contain data. I am using XSL 1.0

sample xml is:

 <column title="Capital Markets">
  <bullet ID="1">
    <tip>This is the first tip for Capital Markets.</tip>
  </bullet>
  <bullet ID="2">
   <tip>This is the second tip for Capital Markets</tip>
  </bullet>
    </column>
 <column title="Environment Industry and Company Markets">
  <bullet ID="3">
  <tip>This is the first tip for Environment, Industry and Company
Markets.</tip>
  </bullet>
 </column>

The html output should look something like this:
<table>
<tr>
<td>Capital Markets</td>
<td>Environment, Industry and Company Markets</td>
</tr>
<tr>
<td>This is the first tip for Capital Markets</td>
<td>This is the first tip for Environment, Industry and Company Markets</td>
</tr>
<tr>
<td>This is the second tip for Capital Markets</td>

<td></td>
</tr>
</table>

Thank you for any help.




--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>