home *** CD-ROM | disk | FTP | other *** search
/ PC World 2004 January / PCWorld_2004-01_cd.bin / akce / openoffice / f_0383 / table_wml.xsl
Text File  |  2003-04-04  |  8KB  |  164 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.     <!-- *** build WML / WAP ASCII TABLE *** -->
  86.     <!-- *********************************** -->
  87.  
  88.  
  89.     <!--  templates from table.xsl has been dublicated for wml
  90.           instead a condition-check for every cell               -->
  91.  
  92.  
  93.     <!-- ********************************************* -->
  94.     <!-- *** write (explicit) repeating table rows *** -->
  95.     <!-- ********************************************* -->
  96.  
  97.     <xsl:template name="wml-repeat-write-row">
  98.         <xsl:param name="collectedGlobalData"/>
  99.         <xsl:param name="allColumnStyleEntries"/>
  100.         <xsl:param name="number-rows-repeated" select="1"/>
  101.         <xsl:param name="maxRowLength"/>
  102.  
  103.         <!-- soffice bug workaround for not showing empty cell repeated multiple times [not(child::*)]-->
  104.         <xsl:if test="not(table:table-cell[last()=1])">
  105.             <xsl:choose>
  106.                 <!-- write an entry of a row and repeat calling this method until all elements are written out -->
  107.                 <xsl:when test="$number-rows-repeated > 1 and (table:table-cell/text() or table:table-cell/*)">
  108.                     <xsl:call-template name="wml-write-row">
  109.                         <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
  110.                         <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
  111.                         <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
  112.                     </xsl:call-template>
  113.  
  114.                     <xsl:call-template name="wml-repeat-write-row">
  115.                         <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
  116.                         <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
  117.                         <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
  118.                         <xsl:with-param name="number-rows-repeated"     select="$number-rows-repeated - 1"/>
  119.                     </xsl:call-template>
  120.                 </xsl:when>
  121.                 <!-- write an entry of a row -->
  122.                 <xsl:otherwise>
  123.                     <xsl:call-template name="wml-write-row">
  124.                         <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
  125.                         <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
  126.                         <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
  127.                     </xsl:call-template>
  128.                 </xsl:otherwise>
  129.             </xsl:choose>
  130.        </xsl:if>
  131.     </xsl:template>
  132.  
  133.  
  134.  
  135.     <xsl:template name="wml-write-row">
  136.         <xsl:param name="collectedGlobalData"/>
  137.         <xsl:param name="allColumnStyleEntries"/>
  138.         <xsl:param name="maxRowLength"/>
  139.  
  140.         <xsl:choose>
  141.             <xsl:when test="ancestor::*[contains($wap-paragraph-elements-without-table-row, name())]">
  142.                 <!-- the first cell of the row, as a row has only cells <!ELEMENT table:table-row %table-cells;> -->
  143.                 <xsl:apply-templates select="table:table-cell">
  144.                     <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
  145.                     <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
  146.                     <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
  147.                 </xsl:apply-templates>
  148.             </xsl:when>
  149.             <xsl:otherwise>
  150.                 <xsl:element name="p">
  151.                     <!-- the first cell of the row, as a row has only cells <!ELEMENT table:table-row %table-cells;> -->
  152.                     <xsl:apply-templates select="table:table-cell">
  153.                         <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
  154.                         <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
  155.                         <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
  156.                     </xsl:apply-templates>
  157.                 </xsl:element>
  158.             </xsl:otherwise>
  159.         </xsl:choose>
  160.  
  161.     </xsl:template>
  162. </xsl:stylesheet>
  163.  
  164.