xsl-list
[Top] [All Lists]

Re: formatting of lists

2005-09-06 10:12:59
Hi Dieter,
  Please try this stylesheet

<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
 
<xsl:output method="xml" indent="yes" /> 
 
<xsl:template match="/people">
   <html>
     <head>
       <title/>
     </head>
     <body>
       <table>
         <tbody>
           <xsl:call-template name="generateTRs">             
             <xsl:with-param name="nodeset" select="person" />             
           </xsl:call-template>
         </tbody>
       </table>
     </body>
   </html>
</xsl:template>
 
<xsl:template name="generateTRs">
   <xsl:param name="nodeset" />
      
   <xsl:if test="$nodeset">   
     <tr>
       <td><xsl:value-of select="$nodeset[1]/@name" /></td>
       <td><xsl:value-of select="$nodeset[2]/@name" /></td>
       <td><xsl:value-of select="$nodeset[3]/@name" /></td>
     </tr>  
     <xsl:call-template name="generateTRs">             
       <xsl:with-param name="nodeset" select="$nodeset[position() &gt;
3]" />
     </xsl:call-template>
   </xsl:if>
 </xsl:template>
 
</xsl:stylesheet>

Regards,
Mukul

On 9/6/05, Dieter Böll <dieter(_dot_)boell(_at_)web(_dot_)de> wrote:

Dear community

I have following problem.

It is a list of elements given e.g.

 <people>
   <person id="id1" name="John"/>
   <person id="id2" name="Peter"/>
   <person id="id3" name="Anne"/>
   <person id="id4" name="Joan"/>
   <person id="id5" name="Pit"/>
   <person id="id6" name="Jeff"/>
   <person id="id7" name="Chris"/>
   <person id="id8" name="Elke"/>
   <person id="id9" name="Mark"/>
   <person id="id10" name="Frank"/>
   <person id="id11" name="Tom"/>
   <person id="id.." name=".."/>
 </people>

The aim is to generate a table in HTML with 3 or 4 columns but so many rows 
as necessary.
Like that:
   <table>
     <tbody>
       <tr>
         <td>John</td>
         <td>Peter</td>
         <td>Anne</td>
       </tr>
       <tr>
         <td>Joan</td>
         <td>Pit</td>
         <td>Jeff</td>
       </tr>
       <tr>
         <td>Chris</td>
         <td>Elke</td>
         <td>Mark</td>
       </tr>
       <tr>
         <td>Frank</td>
         <td>Tom</td>
       </tr>
     </tbody>
   </table>

Sorry but I have no idea how to do that with xslt :(
I am thankful for every help.

Many thanks in advance

 Dieter

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