home *** CD-ROM | disk | FTP | other *** search
/ Freelog 52 / Freelog052.iso / Dossier / OpenOffice / f_0385 / table_rows.xsl
Text File  |  2003-04-04  |  8KB  |  178 lines

  1. <!--
  2.  
  3.    The Contents of this file are made available subject to the terms of
  4.    either of the following licenses
  5.  
  6.           - GNU Lesser General Public License Version 2.1
  7.           - Sun Industry Standards Source License Version 1.1
  8.  
  9.    Sun Microsystems Inc., October, 2000
  10.  
  11.    GNU Lesser General Public License Version 2.1
  12.    =============================================
  13.    Copyright 2000 by Sun Microsystems, Inc.
  14.    901 San Antonio Road, Palo Alto, CA 94303, USA
  15.  
  16.    This library is free software; you can redistribute it and/or
  17.    modify it under the terms of the GNU Lesser General Public
  18.    License version 2.1, as published by the Free Software Foundation.
  19.  
  20.    This library is distributed in the hope that it will be useful,
  21.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  22.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  23.    Lesser General Public License for more details.
  24.  
  25.    You should have received a copy of the GNU Lesser General Public
  26.    License along with this library; if not, write to the Free Software
  27.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28.    MA  02111-1307  USA
  29.  
  30.  
  31.    Sun Industry Standards Source License Version 1.1
  32.    =================================================
  33.    The contents of this file are subject to the Sun Industry Standards
  34.    Source License Version 1.1 (the "License"); You may not use this file
  35.    except in compliance with the License. You may obtain a copy of the
  36.    License at http://www.openoffice.org/license.html.
  37.  
  38.    Software provided under this License is provided on an "AS IS" basis,
  39.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  40.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  41.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  42.    See the License for the specific provisions governing your rights and
  43.    obligations concerning the Software.
  44.  
  45.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  46.  
  47.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  48.  
  49.    All Rights Reserved.
  50.  
  51.    Contributor(s): _______________________________________
  52.  
  53. -->
  54. <xsl:stylesheet version="1.0"
  55.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  56.                 xmlns:office="http://openoffice.org/2000/office"
  57.                 xmlns:style="http://openoffice.org/2000/style"
  58.                 xmlns:text="http://openoffice.org/2000/text"
  59.                 xmlns:table="http://openoffice.org/2000/table"
  60.                 xmlns:draw="http://openoffice.org/2000/drawing"
  61.                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
  62.                 xmlns:xlink="http://www.w3.org/1999/xlink"
  63.                 xmlns:number="http://openoffice.org/2000/datastyle"
  64.                 xmlns:svg="http://www.w3.org/2000/svg"
  65.                 xmlns:chart="http://openoffice.org/2000/chart"
  66.                 xmlns:dr3d="http://openoffice.org/2000/dr3d"
  67.                 xmlns:math="http://www.w3.org/1998/Math/MathML"
  68.                 xmlns:form="http://openoffice.org/2000/form"
  69.                 xmlns:script="http://openoffice.org/2000/script"
  70.                 office:class="text"
  71.                 office:version="1.0"
  72.                 xmlns:dc="http://purl.org/dc/elements/1.1/"
  73.                 xmlns:meta="http://openoffice.org/2000/meta"
  74.                 xmlns:config="http://openoffice.org/2001/config"
  75.                 xmlns:help="http://openoffice.org/2000/help"
  76.                 xmlns:xt="http://www.jclark.com/xt"
  77.                 xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
  78.                 xmlns:xalan="http://xml.apache.org/xalan"
  79.                 xmlns:java="http://xml.apache.org/xslt/java"
  80.                 exclude-result-prefixes="java">
  81.  
  82.  
  83.  
  84.     <!-- ********************************************* -->
  85.     <!-- *** write (explicit) repeating table rows *** -->
  86.     <!-- ********************************************* -->
  87.  
  88.     <xsl:template name="repeat-write-row">
  89.         <xsl:param name="collectedGlobalData"/>
  90.         <xsl:param name="allColumnStyleEntries"/>
  91.         <xsl:param name="number-rows-repeated" select="1"/>
  92.         <xsl:param name="maxRowLength"/>
  93.  
  94.         <xsl:choose>
  95.             <!-- write an entry of a row and repeat calling this method until all elements are written out -->
  96.             <xsl:when test="$number-rows-repeated > 1 and (table:table-cell/text() or table:table-cell/*)">
  97.                 <xsl:call-template name="write-row">
  98.                     <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
  99.                     <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
  100.                     <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
  101.                 </xsl:call-template>
  102.  
  103.                 <!-- 2DO: take variable from the output of repeated write-row and iterate giving out the variable -->
  104.                 <xsl:call-template name="repeat-write-row">
  105.                     <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
  106.                     <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
  107.                     <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
  108.                     <xsl:with-param name="number-rows-repeated"     select="$number-rows-repeated - 1"/>
  109.                 </xsl:call-template>
  110.             </xsl:when>
  111.             <!-- write a single entry of a row -->
  112.             <xsl:otherwise>
  113.                 <xsl:call-template name="write-row">
  114.                     <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
  115.                     <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
  116.                     <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
  117.                 </xsl:call-template>
  118.             </xsl:otherwise>
  119.         </xsl:choose>
  120.     </xsl:template>
  121.  
  122.  
  123.  
  124.     <xsl:template name="write-row">
  125.         <xsl:param name="collectedGlobalData"/>
  126.         <xsl:param name="allColumnStyleEntries"/>
  127.         <xsl:param name="maxRowLength"/>
  128.  
  129.  
  130.         <xsl:element name="tr">
  131.             <!-- writing the style of the row -->
  132.             <xsl:call-template name='add-style-properties'>
  133.                 <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
  134.             </xsl:call-template>
  135.  
  136.             <xsl:if test="$isDebugMode">
  137.                 <xsl:message>
  138. *************************'tr' element has been added!</xsl:message>
  139.             </xsl:if>
  140.  
  141.             <xsl:apply-templates select="table:table-cell">
  142.                 <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
  143.                 <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
  144.                 <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
  145.             </xsl:apply-templates>
  146.  
  147.         </xsl:element>
  148.     </xsl:template>
  149.  
  150.  
  151.     <!-- **************************** -->
  152.     <!-- *** HELPER: table styles *** -->
  153.     <!-- **************************** -->
  154.  
  155.     <xsl:template name="add-style-properties">
  156.         <xsl:param name="collectedGlobalData"/>
  157.         <xsl:param name="allColumnStyleEntries"/>
  158.         <xsl:param name="node-position"/>
  159.  
  160.         <xsl:choose>
  161.             <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
  162.             <xsl:when test="$outputType = 'CSS_HEADER'">
  163.                 <xsl:attribute name="class">
  164.                     <xsl:value-of select="translate(@table:style-name, '. %()/\', '')"/>
  165.                 </xsl:attribute>
  166.             </xsl:when>
  167.  
  168.             <!--+++++ HTML 4.0 INLINED WAY  +++++-->
  169.             <xsl:when test="$outputType = 'CSS_INLINED'">
  170.                 <xsl:attribute name="style">
  171.                     <xsl:value-of select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
  172.                 </xsl:attribute>
  173.             </xsl:when>
  174.         </xsl:choose>
  175.     </xsl:template>
  176.  
  177. </xsl:stylesheet>
  178.