Re: [xsl] Displaying 10 Records at a time

Subject: Re: [xsl] Displaying 10 Records at a time
From: Jarkko.Moilanen@xxxxxx
Date: Mon, 3 Nov 2003 13:36:27 +0200
Hi!

This is not exactly what you asked, but it can be adjusted to do 
what you want. The thing you are looking for is modulating.

Some months ago I got this stylesheet from this list:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html"/>
<!-- Root template of my stylesheet -->
  <xsl:template match="/">
     <html>
       <head>
          <title>Color rows</title>
        <style type="text/css">
        .r0 {background-color: white}
        .r1 {background-color: blue}
        </style>
       </head>
       <body>
        <table border="1">
          <xsl:apply-templates select="Report/Row"/>
        </table>
       y/body>
     </html>
   </xsl:template>

   <xsl:template match="Row">
     <tr class="r{floor((position() - 1) div 10) mod 2}">
       <xsl:apply-templates/>
     </tr>
   </xsl:template>
</xsl:stylesheet>


Now if the sourcetree would be for example like this:

<?xml version="1.0" encoding="UTF-8"?>
<Report>

  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row> <!-- 10 -->

  <Row>blue</Row>
  <Row>blue</Row>
  <Row>blue</Row>
  <Row>blue</Row>
  <Row>blue</Row>
  <Row>blue</Row>
  <Row>blue</Row>
  <Row>blue</Row>
  <Row>blue</Row>
  <Row>blue</Row> <!-- 20 -->
  
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row>
  <Row>white</Row> <!-- 30 -->
</Report>


The result would be:
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Color rows</title>
<style type="text/css">
        .r0 {background-color: white}
        .r1 {background-color: blue}
        </style>
</head>
<body>
<table border="1">
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r1">blue</tr>
<tr class="r1">blue</tr>
<tr class="r1">blue</tr>
<tr class="r1">blue</tr>
<tr class="r1">blue</tr>
<tr class="r1">blue</tr>
<tr class="r1">blue</tr>
<tr class="r1">blue</tr>
<tr class="r1">blue</tr>
<tr class="r1">blue</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
<tr class="r0">white</tr>
</table>
</body>
</html>

Cheers, 
Jarkko


Lainaus "karthikeyan.balasubramanian"
<karthikeyan.balasubramanian@xxxxxxxxxxxxx>:

<!-- Hi,
<!-- 
<!--   I am not sure if I have put correct subject.
<!-- 
<!--   I want to display 10 records in a table
<!-- after this I want to show horizontal line and
<!-- display another 10 and this sequence 
<!-- continues.  How do I keep track of this 
<!-- information?
<!-- 
<!-- 
<!-- Output
<!-- =====
<!-- 
<!-- heading : data1
<!-- data1, data2, data3, data4, data5
<!-- data6, data7, data8, data9, data10
<!-- 
<!-- ============================
<!-- heading: data11
<!-- data11, data12, data13, data14, data15
<!-- data16, data17, data18, data19, data20
<!-- ============================
<!-- 
<!-- heres my xsl
<!-- ============
<!-- 
<!--  <xsl:template match="NI">
<!--   <h1>heading : ?</h1>
<!--   <table>
<!--    <tr>
<!--     <td>sub-title1</td>
<!--     <td>sub-title2</td>    
<!--    </tr>   
<!--    <xsl:for-each select="TABLE/TBODY/ROW">   
<!--    <tr>
<!--     <td>
<!--      <xsl:value-of select="ENTRY[1]/PARA[1]"/>
<!--     </td>
<!--     <td>
<!--      <xsl:value-of select="ENTRY[2]/PARA[2]"/>
<!--     </td>    
<!--    </tr>   
<!--    </xsl:for-each>  
<!--   </table>
<!--  </xsl:template>
<!-- 
<!-- sample xml
<!-- ===========
<!-- 
<!-- <NI PUBLISH="DEC31">
<!--  <TABLE>
<!--   <TBODY>
<!--    <ROW>
<!--     <ENTRY>
<!--      <PARA>MS9557-09</PARA>
<!--      <PARA LEVEL="2">73 34 15  01  010</PARA>
<!--     </ENTRY>
<!--     <ENTRY>
<!--      <PARA/>
<!--      <PARA>3</PARA>
<!--     </ENTRY>
<!--    </ROW>
<!--    <ROW>
<!--     <ENTRY>
<!--      <PARA>MS9557-09</PARA>
<!--      <PARA LEVEL="2">73 34 15  01  010</PARA>
<!--     </ENTRY>
<!--     <ENTRY>
<!--      <PARA/>
<!--      <PARA>3</PARA>
<!--     </ENTRY>
<!--    </ROW>
<!--   </TBODY>
<!--  </TABLE>
<!-- </NI>
<!-- 
<!-- Have a great day.
<!-- 
<!-- Karthikeyan B
<!-- 
<!-- 
<!-- 
<!--  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
<!-- 
<!-- 


***************************************************
* Jarkko Moilanen                                 *
* Project Manager, ITCM (www.itcm.org)            *
* Profound XML technology Expert                  *
* University of Tampere                           *
* Hypermedia Laboratory                           *
***************************************************

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


Current Thread