home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / openoffice / openofficeorg2.cab / table.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-06  |  9.9 KB  |  212 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.    $RCSfile: table.xsl,v $
  5.  
  6.    $Revision: 1.3 $
  7.  
  8.    last change: $Author: rt $ $Date: 2004/07/05 09:06:12 $
  9.  
  10.    The Contents of this file are made available subject to the terms of
  11.    either of the following licenses
  12.  
  13.           - GNU Lesser General Public License Version 2.1
  14.           - Sun Industry Standards Source License Version 1.1
  15.  
  16.    Sun Microsystems Inc., October, 2000
  17.  
  18.    GNU Lesser General Public License Version 2.1
  19.    =============================================
  20.    Copyright 2000 by Sun Microsystems, Inc.
  21.    901 San Antonio Road, Palo Alto, CA 94303, USA
  22.  
  23.    This library is free software; you can redistribute it and/or
  24.    modify it under the terms of the GNU Lesser General Public
  25.    License version 2.1, as published by the Free Software Foundation.
  26.  
  27.    This library is distributed in the hope that it will be useful,
  28.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  29.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  30.    Lesser General Public License for more details.
  31.  
  32.    You should have received a copy of the GNU Lesser General Public
  33.    License along with this library; if not, write to the Free Software
  34.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  35.    MA  02111-1307  USA
  36.  
  37.  
  38.    Sun Industry Standards Source License Version 1.1
  39.    =================================================
  40.    The contents of this file are subject to the Sun Industry Standards
  41.    Source License Version 1.1 (the "License"); You may not use this file
  42.    except in compliance with the License. You may obtain a copy of the
  43.    License at http://www.openoffice.org/license.html.
  44.  
  45.    Software provided under this License is provided on an "AS IS" basis,
  46.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  47.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  48.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  49.    See the License for the specific provisions governing your rights and
  50.    obligations concerning the Software.
  51.  
  52.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  53.  
  54.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  55.  
  56.    All Rights Reserved.
  57.  
  58.    Contributor(s): _______________________________________
  59.  
  60. -->
  61. <!--
  62.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  63. -->
  64. <xsl:stylesheet version="1.0"
  65.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  66.     xmlns:office="http://openoffice.org/2000/office"
  67.     xmlns:style="http://openoffice.org/2000/style"
  68.     xmlns:text="http://openoffice.org/2000/text"
  69.     xmlns:table="http://openoffice.org/2000/table"
  70.     xmlns:draw="http://openoffice.org/2000/drawing"
  71.     xmlns:fo="http://www.w3.org/1999/XSL/Format"
  72.     xmlns:xlink="http://www.w3.org/1999/xlink"
  73.     xmlns:number="http://openoffice.org/2000/datastyle"
  74.     xmlns:svg="http://www.w3.org/2000/svg"
  75.     xmlns:chart="http://openoffice.org/2000/chart"
  76.     xmlns:dr3d="http://openoffice.org/2000/dr3d"
  77.     xmlns:math="http://www.w3.org/1998/Math/MathML"
  78.     xmlns:form="http://openoffice.org/2000/form"
  79.     xmlns:script="http://openoffice.org/2000/script"
  80.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  81.     xmlns:meta="http://openoffice.org/2000/meta"
  82.     xmlns:config="http://openoffice.org/2001/config"
  83.     xmlns:help="http://openoffice.org/2000/help"
  84.     exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help">
  85.  
  86.  
  87.     <!-- table row handling -->
  88.     <xsl:include href="table_rows.xsl" />
  89.     <!-- table column handling -->
  90.     <xsl:include href="table_columns.xsl" />
  91.     <!-- table cell handling -->
  92.     <xsl:include href="table_cells.xsl" />
  93.  
  94.     <xsl:param name="tableElement" select="'table'" />
  95.  
  96.     <!-- ******************* -->
  97.     <!-- *** main table  *** -->
  98.     <!-- ******************* -->
  99.  
  100.  
  101.     <xsl:template match="table:table | table:sub-table" name="table:table">
  102.         <xsl:param name="globalData" />
  103.  
  104.         <!-- The table will only be created if the table:scenario is active -->
  105.         <xsl:if test="not(table:scenario) or table:scenario/@table:is-active">
  106.             <xsl:call-template name="create-table">
  107.                 <xsl:with-param name="globalData" select="$globalData" />
  108.             </xsl:call-template>
  109.         </xsl:if>
  110.     </xsl:template>
  111.  
  112.  
  113.  
  114.     <xsl:template name="create-table">
  115.         <xsl:param name="globalData" />
  116.  
  117.         <!-- collecting all visible "table:table-row" elements of the table -->
  118.         <xsl:variable name="allVisibleTableRows" select="table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')] | table:table-header-rows/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')] | table:table-row-group/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]" />
  119.         <xsl:choose>
  120.             <xsl:when test="$outputType = 'WML'">
  121.             <!-- for WML devices only ASCII table are written as tables are not implemented widley.
  122.                  Beginning from 'repeat-write-row' the templates are handled by the table_wml.xsl stylesheet -->
  123.                 <xsl:call-template name="create-column-style-variable">
  124.                     <xsl:with-param name="globalData" select="$globalData" />
  125.                     <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
  126.                 </xsl:call-template>
  127.             </xsl:when>
  128.             <xsl:otherwise>
  129.                 <!-- As the alignment of a table is by 'align' attribut is deprecated and as the CSS 'float' attribute not well displayed,
  130.                      we do a trick by encapsulating the table with a aligned 'div' element-->
  131.                 <xsl:variable name="table-alignment" select="$globalData/office:automatic-styles/style:style[@style:name = current()/@table:style-name]/style:properties/@table:align" />
  132.                 <xsl:choose>
  133.                     <xsl:when test="string-length($table-alignment) != 0">
  134.                         <xsl:element namespace="{$namespace}" name="div">
  135.                             <xsl:attribute name="style">
  136.                                 <xsl:choose>
  137.                                     <xsl:when test='$table-alignment="left" or $table-alignment="margins"'>
  138.                                         <xsl:text>text-align:left</xsl:text>
  139.                                     </xsl:when>
  140.                                     <xsl:when test='$table-alignment="right"'>
  141.                                         <xsl:text>text-align:right</xsl:text>
  142.                                     </xsl:when>
  143.                                     <xsl:when test='$table-alignment="center"'>
  144.                                         <xsl:text>text-align:center</xsl:text>
  145.                                     </xsl:when>
  146.                                 </xsl:choose>
  147.                             </xsl:attribute>
  148.                             <xsl:call-template name="create-table-element">
  149.                                 <xsl:with-param name="globalData" select="$globalData" />
  150.                                 <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
  151.                             </xsl:call-template>
  152.                         </xsl:element>
  153.                     </xsl:when>
  154.                     <xsl:otherwise>
  155.                         <xsl:call-template name="create-table-element">
  156.                             <xsl:with-param name="globalData" select="$globalData" />
  157.                             <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
  158.                         </xsl:call-template>
  159.                     </xsl:otherwise>
  160.                 </xsl:choose>
  161.             </xsl:otherwise>
  162.         </xsl:choose>
  163.     </xsl:template>
  164.  
  165.  
  166.     <xsl:template name="create-table-element">
  167.         <xsl:param name="globalData" />
  168.         <xsl:param name="allVisibleTableRows" />
  169.  
  170.         <xsl:element namespace="{$namespace}" name="{$tableElement}">
  171.             <xsl:attribute name="border">0</xsl:attribute>
  172.             <xsl:attribute name="cellspacing">0</xsl:attribute>
  173.             <xsl:attribute name="cellpadding">0</xsl:attribute>
  174.             <xsl:choose>
  175.                 <xsl:when test='name()="table:table"'>
  176.                     <xsl:variable name="value" select="$globalData/all-ooo-styles/style[@style:name = current()/@table:style-name]/style:properties/@style:rel-width" />
  177.                     <xsl:if test="$value">
  178.                         <xsl:attribute name="width">
  179.                             <xsl:value-of select="$value" />
  180.                         </xsl:attribute>
  181.                     </xsl:if>
  182.                 </xsl:when>
  183.                 <xsl:otherwise>
  184.                     <xsl:attribute name="width">100%</xsl:attribute>
  185.                 </xsl:otherwise>
  186.             </xsl:choose>
  187.  
  188.             <xsl:choose>
  189.                 <!--+++++ SPECIAL HANDLING HTML 4.0 INLINED WAY  +++++-->
  190.                 <!-- The office default value 'border-spacing:0;' have to be added to the style -->
  191.                 <xsl:when test="$outputType = 'CSS_INLINED'">
  192.                     <xsl:attribute name="style">
  193.                         <xsl:text>border-spacing:0;  empty-cells:show; </xsl:text>
  194.                         <xsl:value-of select="$globalData/all-styles/style[@style:name = current()/@table:style-name]/final-properties" />
  195.                     </xsl:attribute>
  196.                 </xsl:when>
  197.                 <xsl:otherwise>
  198.                     <xsl:apply-templates select="@table:style-name">
  199.                         <xsl:with-param name="globalData" select="$globalData" />
  200.                     </xsl:apply-templates>
  201.                 </xsl:otherwise>
  202.             </xsl:choose>
  203.  
  204.             <xsl:call-template name="create-column-style-variable">
  205.                 <xsl:with-param name="globalData" select="$globalData" />
  206.                 <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
  207.             </xsl:call-template>
  208.         </xsl:element>
  209.     </xsl:template>
  210.  
  211. </xsl:stylesheet>
  212.