home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2004 April / VPR0404.ISO / OPENOFFICE / INSTALL / f_0391 / table_columns.xsl
Text File  |  2003-04-04  |  11KB  |  216 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.     <!-- *** Create table columns style variable  *** -->
  85.     <!-- ******************************************** -->
  86.  
  87.     <xsl:template name="adding-column-styles-entries">
  88.         <xsl:param name="collectedGlobalData"/>
  89.         <xsl:param name="allTableColumns"/>
  90.  
  91.         <xsl:for-each select="$allTableColumns">
  92.  
  93.             <xsl:variable name="column-style-entry" select="$collectedGlobalData/allstyles/*[name() = translate(current()/@table:style-name, '. %()/\', '')]"/>
  94.             <xsl:choose>
  95.                 <xsl:when test="not(@table:number-columns-repeated)">
  96.                     <!-- writes an entry of a column in the columns-variable -->
  97.                     <xsl:call-template name="adding-column-style-entry">
  98.                         <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
  99.                     </xsl:call-template>
  100.                 </xsl:when>
  101.                 <!-- No higher repetition of cells greater than 4 for the last and second last column -->
  102.                 <!-- a hack for the sample document 'Waehrungsumrechner.sxc having 230 repeated columns in the second last column -->
  103.                 <!-- ??? <xsl:when test="(position() = last() or (position() = (last() - 1)) and @table:number-columns-repeated < 5)"> ???-->
  104.                 <xsl:when test="position() = last() or position() = (last() - 1)">
  105.                     <xsl:if test="@table:number-columns-repeated < 5">
  106.                         <!-- writes an entry of a column in the columns-variable -->
  107.                         <xsl:call-template name="repeat-adding-column-style-entry">
  108.                             <xsl:with-param name="column-style-entry"       select="$column-style-entry"/>
  109.                             <xsl:with-param name="number-columns-repeated"  select="1"/>
  110.                         </xsl:call-template>
  111.                     </xsl:if>
  112.                 </xsl:when>
  113.                 <xsl:otherwise>
  114.                     <!-- repeated colums will be written explicit several times in the variable-->
  115.                     <xsl:call-template name="repeat-adding-column-style-entry">
  116.                         <xsl:with-param name="column-style-entry"           select="$column-style-entry"/>
  117.                         <xsl:with-param name="number-columns-repeated"      select="@table:number-columns-repeated"/>
  118.                     </xsl:call-template>
  119.                 </xsl:otherwise>
  120.             </xsl:choose>
  121.         </xsl:for-each>
  122.      </xsl:template>
  123.  
  124.  
  125.     <!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
  126.     <xsl:template name="repeat-adding-column-style-entry">
  127.         <xsl:param name="column-style-entry"/>
  128.         <xsl:param name="number-columns-repeated"/>
  129.  
  130.         <xsl:choose>
  131.             <xsl:when test="$number-columns-repeated > 1">
  132.                 <!-- writes an entry of a column in the columns-variable -->
  133.                 <xsl:call-template name="adding-column-style-entry">
  134.                     <xsl:with-param name="column-style-entry"   select="$column-style-entry"/>
  135.                 </xsl:call-template>
  136.                 <!-- repeat calling this method until all elements written out -->
  137.                 <xsl:call-template name="repeat-adding-column-style-entry">
  138.                     <xsl:with-param name="column-style-entry"       select="$column-style-entry"/>
  139.                     <xsl:with-param name="number-columns-repeated"  select="$number-columns-repeated - 1"/>
  140.                 </xsl:call-template>
  141.             </xsl:when>
  142.             <xsl:otherwise>
  143.                 <!-- writes an entry of a column in the columns-variable -->
  144.                 <xsl:call-template name="adding-column-style-entry">
  145.                     <xsl:with-param name="column-style-entry"   select="$column-style-entry"/>
  146.                 </xsl:call-template>
  147.             </xsl:otherwise>
  148.         </xsl:choose>
  149.     </xsl:template>
  150.  
  151.  
  152.     <!-- THE COLUMN-STYLE WRITE-PATTERN FOR EACH COLUMN WRITTEN IN A VARIABLE -->
  153.     <xsl:template name="adding-column-style-entry">
  154.         <xsl:param name="column-style-entry"/>
  155.  
  156.         <xsl:element name="column-style-entry">
  157.             <xsl:choose>
  158.                 <xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter'">
  159.                     <xsl:attribute name="column-hidden-flag">true</xsl:attribute>
  160.                 </xsl:when>
  161.                 <xsl:otherwise>
  162.                     <xsl:variable  name="table:style-name"         select="translate(@table:style-name, '. %()/\', '')"/>
  163.                     <xsl:attribute name="style-name"><xsl:value-of select="$table:style-name"/></xsl:attribute>
  164.                     <xsl:value-of select="$column-style-entry"/>
  165.                 </xsl:otherwise>
  166.             </xsl:choose>
  167.         </xsl:element>
  168.     </xsl:template>
  169.  
  170.  
  171.  
  172.     <!--isDebugMode-START-->
  173.     <!-- giving out the 'allColumnStyle' variable:
  174.         For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out.
  175.         In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
  176.     <xsl:template name="table-debug-allColumnStyleEntries">
  177.         <xsl:param name="allColumnStyleEntries"/>
  178.  
  179.         <!-- debug output as table summary attribut in html -->
  180.         <xsl:attribute name="summary">
  181.             <xsl:call-template name="table-debug-column-out">
  182.                 <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
  183.             </xsl:call-template>
  184.         </xsl:attribute>
  185.         <!-- debug output to console -->
  186.         <xsl:message>
  187.             <xsl:call-template name="table-debug-column-out">
  188.                 <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
  189.             </xsl:call-template>
  190.         </xsl:message>
  191.     </xsl:template>
  192.  
  193.  
  194.     <xsl:template name="table-debug-column-out">
  195.         <xsl:param name="allColumnStyleEntries"/>
  196.             <xsl:text>
  197.             DebugInformation: For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out.
  198.                               In case of 'column-hidden-flag' attribute the text 'column is hidden' is given out.
  199.             </xsl:text>
  200.                 <xsl:for-each select="$allColumnStyleEntries/column-style-entry">
  201.                 <xsl:choose>
  202.                 <xsl:when test="@column-hidden-flag">
  203.             <xsl:text>  </xsl:text><xsl:value-of select="@style-name"/><xsl:text>column is hidden</xsl:text><xsl:text>
  204.             </xsl:text>
  205.                 </xsl:when>
  206.                 <xsl:otherwise>
  207.             <xsl:text>  </xsl:text><xsl:value-of select="@style-name"/><xsl:text> = </xsl:text><xsl:value-of select="."/><xsl:text>
  208.             </xsl:text>
  209.                 </xsl:otherwise>
  210.                 </xsl:choose>
  211.                            </xsl:for-each>
  212.     </xsl:template>
  213.     <!--isDebugMode-END-->
  214.  
  215. </xsl:stylesheet>
  216.