RE: [xsl] not standart table in stylesheet, need advise

Subject: RE: [xsl] not standart table in stylesheet, need advise
From: Americo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Fri, 28 Feb 2003 15:56:42 -0000

> -----Mensagem original-----
> De: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] Em nome de 
> Andrey Solonchuk
> Enviada: quinta-feira, 27 de Fevereiro de 2003 16:19
> Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Assunto: [xsl] not standart table in stylesheet, need advise
> 
(...)
> 
> I need table with the next columns
> 
> ------------------------------------
> | @flag = 1         |      @flag=2 |
> |code|sname|sum|date|code|sname|sum|
(...)

You could use apply-templates and modes.
This is a simple variation of your template. It creates one table for
@flag=1 and another for @flag=2. the bottom is filled with blank to
unsure that the two tables have the same number of rows.

 <!-- main template -->
 <xsl:template match="root">
 <xsl:variable name="flag1" select="list[@flag=2]"/>
 <xsl:variable name="flag2" select="list[@flag=1]"/>
 <html>
  <head></head>
  <body>
  <big>title</big>
  <table>
   <tr>
    <!-- here we create the first table -->
    <td valign="top"><table>
     <tr>
      <th>codePMT</th>
      <th>sName</th>
      <th>summa</th>
      <th>date</th>
     </tr>
     <xsl:apply-templates select="$flag1" mode="flag1"/>
     <!-- and fill what left with blanks -->
     <xsl:apply-templates select="$flag1[position() &lt; (count($flag2)
- count($flag1) + 1)]" mode="fill"/>
     <tr>
      <th></th>
      <th></th>
      <th><xsl:value-of
select="format-number(sum($flag1/sum-amt),'.00')"/></th>
      <th><xsl:value-of select="sum($flag1/days)"/></th>
     </tr>
    </table></td>
    <!-- here we create the second table -->
    <td valign="top"><table>
     <tr>
      <th>codePMT</th>
      <th>sName</th>
      <th>summa</th>
     </tr>
     <xsl:apply-templates select="$flag2" mode="flag2"/>
     <!-- and fill what left with blanks -->
     <xsl:apply-templates select="$flag2[position() &lt; (count($flag1)
- count($flag2) + 1)]" mode="fill"/>
     <tr>
      <th></th>
      <th></th>
      <th><xsl:value-of
select="format-number(sum($flag2/sum-amt),'.00')"/></th>
     </tr>
    </table></td>
   </tr>
  </table>
  </body>
 </html>
 </xsl:template>
 
 <!-- mode for the first table -->
 <xsl:template match="list" mode="flag1">
  <tr>
   <th><xsl:value-of select="code-pMT"/></th>
   <th><xsl:value-of select="sname"/></th>
   <th><xsl:value-of select="sum-amt"/></th>
   <th><xsl:value-of select="days"/></th>
  </tr>
 </xsl:template>
 
 <!-- mode for the second table -->
 <xsl:template match="list" mode="flag2">
  <tr>
   <th><xsl:value-of select="code-pMT"/></th>
   <th><xsl:value-of select="sname"/></th>
   <th><xsl:value-of select="sum-amt"/></th>
  </tr>
 </xsl:template>
 
 <!-- filling mode -->
 <xsl:template match="list" mode="fill">
  <tr>
   <th>&#160;</th>
  </tr>
 </xsl:template>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread