steffen: server/kolab-horde-framework/kolab-horde-framework/MIME/MIME/Viewer/ooo common.xsl, NONE, 1.1 global_document.xsl, NONE, 1.1 main_html.xsl, NONE, 1.1 palm.xsl, NONE, 1.1 style_header.xsl, NONE, 1.1 style_inlined.xsl, NONE, 1.1 style_mapping.xsl, NONE, 1.1 table.xsl, NONE, 1.1 table_cells.xsl, NONE, 1.1 table_columns.xsl, NONE, 1.1 table_rows.xsl, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Fri Oct 14 16:33:09 CEST 2005


Author: steffen

Update of /kolabrepository/server/kolab-horde-framework/kolab-horde-framework/MIME/MIME/Viewer/ooo
In directory doto:/tmp/cvs-serv28903/kolab-horde-framework/kolab-horde-framework/MIME/MIME/Viewer/ooo

Added Files:
	common.xsl global_document.xsl main_html.xsl palm.xsl 
	style_header.xsl style_inlined.xsl style_mapping.xsl table.xsl 
	table_cells.xsl table_columns.xsl table_rows.xsl 
Log Message:
Separated Horde Framework from kolab-resource-handlers

--- NEW FILE: common.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

[...1126 lines suppressed...]
                    <xsl:call-template name="create-nested-format-tags">
                        <xsl:with-param name="styleProperties" select="$styleProperties"/>
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    </xsl:call-template>
                </xsl:for-each>
            </xsl:when>
        </xsl:choose>
    </xsl:template>


    <xsl:template match="text:sequence">
        <xsl:param name="collectedGlobalData"/>

        <xsl:apply-templates>
            <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
        </xsl:apply-templates>
    </xsl:template>


</xsl:stylesheet>

--- NEW FILE: global_document.xsl ---
 <!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

[...1635 lines suppressed...]

        <xsl:choose>
            <xsl:when test="$position > 1">
                <xsl:call-template name="create-cell-width">
                    <xsl:with-param name="width"    select="$width - number(substring-before($allTabStopStyles/style:tab-stop[$position]/@style:position,$unit))"/>
                    <xsl:with-param name="unit"     select="$unit"/>
                    <xsl:with-param name="position" select="$position - 1"/>
                    <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$position = 1">
                <xsl:value-of select="concat($width - number(substring-before($allTabStopStyles/style:tab-stop[$position]/@style:position,$unit)), $unit)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="concat($width, $unit)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>
--- NEW FILE: main_html.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA  02111-1307  USA


   Sun Industry Standards Source License Version 1.1
   =================================================
   The contents of this file are subject to the Sun Industry Standards
   Source License Version 1.1 (the "License"); You may not use this file
   except in compliance with the License. You may obtain a copy of the
   License at http://www.openoffice.org/license.html.

   Software provided under this License is provided on an "AS IS" basis,
   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
   See the License for the specific provisions governing your rights and
   obligations concerning the Software.

   The Initial Developer of the Original Code is: Sun Microsystems, Inc.

   Copyright © 2002 by Sun Microsystems, Inc.

   All Rights Reserved.

   Contributor(s): _______________________________________

-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:office="http://openoffice.org/2000/office"
                xmlns:style="http://openoffice.org/2000/style"
                xmlns:text="http://openoffice.org/2000/text"
                xmlns:table="http://openoffice.org/2000/table"
                xmlns:draw="http://openoffice.org/2000/drawing"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:number="http://openoffice.org/2000/datastyle"
                xmlns:svg="http://www.w3.org/2000/svg"
                xmlns:chart="http://openoffice.org/2000/chart"
                xmlns:dr3d="http://openoffice.org/2000/dr3d"
                xmlns:math="http://www.w3.org/1998/Math/MathML"
                xmlns:form="http://openoffice.org/2000/form"
                xmlns:script="http://openoffice.org/2000/script"
                office:class="text"
                office:version="1.0"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:meta="http://openoffice.org/2000/meta"
                xmlns:config="http://openoffice.org/2001/config"
                xmlns:help="http://openoffice.org/2000/help"
                xmlns:xt="http://www.jclark.com/xt"
                xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
                xmlns:urlencoder="http://www.jclark.com/xt/java/java.net.URLEncoder"
                xmlns:xalan="http://xml.apache.org/xalan"
                xmlns:java="http://xml.apache.org/xslt/java"
                exclude-result-prefixes="java">

    <xsl:output method      ="xml"
                encoding    ="UTF-8"
                indent      ="yes"/>



    <!--+++++ INCLUDED XSL MODULES +++++-->
    <!-- inherited style properties will be collected and written in a CSS header (CSS) -->
    <xsl:include href="style_header.xsl"/>

    <!-- inherited style properties will be collected and written as html properties in a temporary variable (HTML4, PALM) -->
    <xsl:include href="style_inlined.xsl"/>

    <!-- our xml style properties will be mapped to CSS and HTML4.x properties -->
    <xsl:include href="style_mapping.xsl"/>

    <!-- common element handling -->
    <xsl:include href="common.xsl"/>

    <!-- table handling -->
    <xsl:include href="table.xsl"/>

    <!-- palm handling -->
    <xsl:include href="palm.xsl"/>

    <!-- global document handling -->
    <xsl:include href="global_document.xsl"/>







    <!--+++++ PARAMETER FROM THE APPLICATION AND GLOBAL VARIABLES +++++-->

    <!-- MANDATORY: URL of meta stream -->
    <xsl:param name="metaFileURL"/>

    <!-- MANDATORY: URL of styles stream -->
    <xsl:param name="stylesFileURL"/>

    <!-- MANDATORY: for resolving relative links
        For resolving realtive links to the packed SO document, i.e. the path/URL of the jared sxw file (e.g. meta.xml, styles.xml, links to graphics in a relative directory) -->
    <xsl:param name="absoluteSourceDirRef"/>

    <!-- OPTIONAL (mandatory, when when source is compressed): Necessary for the in the packed OO document embedded files (mostly graphics from the compressed /Picture dir).
         When the OpenOffice (OO) file has been unpacked the absoluteSoureDirRef can be taken,
         Otherwise, a JAR URL could be choosen or when working with OpenOffice a so called Package-URL encoded over HTTP can be used to
         access the jared contents of the the jared document. . -->
    <xsl:param name="jaredRootURL" select="$absoluteSourceDirRef"/>

    <!-- OPTIONAL (mandatory, when used in session based environment)
         Useful for WebApplications: if a HTTP session is not cookie based, URL rewriting is beeing used (the session is appended to the URL).
         This URL session is used when creating links to graphics by XSLT. Otherwise the user havt to log again in for every graphic he would like to see. -->
    <xsl:param name="optionalURLSuffix"/>

    <!-- OPTIONAL: DPI (dots per inch) the standard solution of given pictures (necessary for the conversion of 'cm' into 'pixel')-->
    <!-- Although many pictures have the 96 dpi resolution, a higher resoltion give better results for common browsers -->
    <xsl:param name="dpi" select="96"/>

    <!-- OPTIONAL: in case of using a different processor than a JAVA XSLT, you can unable the Java functionality
         (i.e. debugging time and encoding chapter names for the content-table as href and anchors ) -->
    <xsl:param name="disableJava"    select="false"/>
    <xsl:param name="isJavaDisabled" select="boolean($disableJava)"/>

    <!-- OPTIONAL: user-agent will be differntiated by this parameter given by application (e.g. java servlet)-->
    <xsl:param name="outputType" select="'CSS_HEADER'"/>
    <!-- set of possible deviceTyps (WML is set in its own startfile main_wml.xsl):
    <xsl:param name="outputType" select="'CSS_HEADER'"/>
    <xsl:param name="outputType" select="'CSS_INLINED'"/>
    <xsl:param name="outputType" select="'PALM'"/> -->

    <!-- OPTIONAL: for activating the debug mode set the variable here to 'true()' or give any value from outside -->
    <xsl:param name="debug"         select="false"/>
    <xsl:param name="isDebugMode"   select="boolean($debug)"/>

<!-- *************************************************************************
    OPTIONAL: NEEDED IN CONNECTION WITH A GLOBAL DOCUMENT -->

    <!--SUMMARY:
         following parameter triggers a (quite time consuming) enabling of bookmarks in the table-of-content.
        IN DETAIL:
         Currently some links used in the Office XML (e.g. in the content table as '#7.Some%20Example%20Headline%7Outline')
         is not a valid URL (cmp. bug id# 102311). No file destination is specified nor exist any anchor element for these
         links in the Office XML.
         A workaround for this transformation therefore had to be made. This time-consuming mechanism is disabled by default and
         can be activated by a parameter (i.e. 'disableLinkedTableOfContent'). A creation of an anchor is made for each header element.
         All header titles gonna be encoding to be usable in a relative URL.    -->
    <xsl:param name="disableLinkedTableOfContent" select="false()"/>

    <!-- The chapter numbers of the current document (as a sequence of a global document) is dependent of the number
        of chapter of the same level in preceding documents. -->
    <xsl:param name="precedingChapterLevel1"  select="0"/>
    <xsl:param name="precedingChapterLevel2"  select="0"/>
    <xsl:param name="precedingChapterLevel3"  select="0"/>
    <xsl:param name="precedingChapterLevel4"  select="0"/>
    <xsl:param name="precedingChapterLevel5"  select="0"/>
    <xsl:param name="precedingChapterLevel6"  select="0"/>
    <xsl:param name="precedingChapterLevel7"  select="0"/>
    <xsl:param name="precedingChapterLevel8"  select="0"/>
    <xsl:param name="precedingChapterLevel9"  select="0"/>
    <xsl:param name="precedingChapterLevel10" select="0"/>

    <!-- XML documents containing a table of contents,
        gonna link for usability reason above each chapter to the preceding and following document and the content table -->
    <xsl:param name="contentTableURL"/>

    <!-- Needed for the bug workaround of missing content table links
        by this ambigous HTML references from the content table can be evoided-->
    <xsl:param name="globalDocumentRefToCurrentFile"/>

    <!-- Needed for the bug workaround of missing content table links
        by this node-set the relation between content-table link and children document header can be unambigous established -->
    <xsl:param name="contentTableHeadings"/>


<!-- END OF GLOBAL DOCUMENT SECTION
*************************************************************************-->



    <!-- works for normal separated zipped xml files as for flat filter single xml file format as well -->
    <xsl:variable name="office:meta-file"           select="document($metaFileURL)"/>
    <xsl:variable name="office:styles-file"         select="document($stylesFileURL)"/>
    <xsl:variable name="office:font-decls"          select="$office:styles-file/*/office:font-decls"/>
    <xsl:variable name="office:styles"              select="$office:styles-file/*/office:styles"/>
    <!-- office:automatic-styles may occure in two different files (i.d. content.xml and styles.xml). Furthermore the top level tag is different in a flat xml file -->
    <xsl:variable name="office:automatic-styles"    select="/*/office:automatic-styles"/>

    <!-- simple declaration of WML used to avoid parser errors -->
    <xsl:variable name="wap-paragraph-elements-without-table-row"/>
    <xsl:variable name="wap-paragraph-elements"/>
    <xsl:template name="wml-repeat-write-row"/>


    <!-- ************************************* -->
    <!-- *** build the propriate HTML file *** -->
    <!-- ************************************* -->

    <xsl:template match="/">

        <!--<xsl:message>


        Entered the styleSheets, transformation begins... </xsl:message>-->

        <xsl:choose>
            <xsl:when test="$isDebugMode">
                <xsl:call-template name="check-parameter"/>

                <xsl:if test="not($isJavaDisabled)">
                    <xsl:call-template name="debug-style-collecting-time"/>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <!-- to access the variable like a node-set it is necessary to convert it
                     from a result-tree-fragment (RTF) to a node set using the James Clark extension -->
                <xsl:variable name="collectedGlobalData-RTF">
                    <xsl:call-template name='create-all-inline-styles'/>
                </xsl:variable>

                <xsl:choose>
                    <xsl:when test="function-available('xt:node-set')">
                        <xsl:call-template name="start">
                            <xsl:with-param name="collectedGlobalData" select="xt:node-set($collectedGlobalData-RTF)"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:when test="function-available('xalan:nodeset')">
                        <xsl:call-template name="start">
                            <xsl:with-param name="collectedGlobalData" select="xalan:nodeset($collectedGlobalData-RTF)"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:element name="NodeSetFunctionNotAvailable"/>
                        <xsl:call-template name="start"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="start">
        <xsl:param name="collectedGlobalData"/>

        <xsl:choose>
            <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
            <xsl:when test="$outputType = 'CSS_HEADER'">
                <xsl:element name="html">
                    <xsl:element name="head">
                        <xsl:if test="$isDebugMode"><xsl:message>CSS helper variable will be created....</xsl:message></xsl:if>
                        <xsl:call-template name='common-header-properties'/>
                        <xsl:if test="$isDebugMode"><xsl:message>CSS variable ready, header will be created....</xsl:message></xsl:if>
                        <!-- constructing the css header simulating inheritance of style-families by style order -->
                        <xsl:call-template name='create-css-styleheader'/>
                        <xsl:if test="$isDebugMode"><xsl:message>CSS header creation finished!</xsl:message></xsl:if>
                    </xsl:element>



                    <xsl:variable name="backgroundImageURL" select="$office:automatic-styles/style:page-master/style:properties/style:background-image/@xlink:href"/>
                    <xsl:element name="body">
                        <!-- background image -->
                        <xsl:if test="$backgroundImageURL">
                            <xsl:attribute name="background">
                                <xsl:choose>
                                    <!-- for images jared in open office document -->
                                    <xsl:when test="contains($backgroundImageURL, '#Pictures/')">
                                        <!-- creating an absolute http URL to the contained/packed image file -->
                                        <xsl:value-of select="concat($jaredRootURL, '/Pictures/', substring-after($backgroundImageURL, '#Pictures/'), $optionalURLSuffix)"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:attribute name="src"><xsl:value-of select="$backgroundImageURL"/></xsl:attribute>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:attribute>
                        </xsl:if>

                        <!-- processing the content of the xml file -->
                        <xsl:apply-templates select="/*/office:body">
                            <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                        </xsl:apply-templates>
                    </xsl:element>

                </xsl:element>
            </xsl:when>

            <!--+++++ HTML 4.0 INLINING  +++++-->
            <xsl:when test="$outputType = 'CSS_INLINED'">
                <xsl:element name="html">
                    <xsl:element name="head">
                        <xsl:call-template name='common-header-properties'/>
                    </xsl:element>

                    <xsl:variable name="backgroundImageURL" select="$office:automatic-styles/style:page-master/style:properties/style:background-image/@xlink:href"/>
                    <xsl:element name="body">
                        <!-- background image -->
                        <xsl:if test="$backgroundImageURL">
                            <xsl:attribute name="background">
                                <xsl:choose>
                                    <!-- for images jared in open office document -->
                                    <xsl:when test="contains($backgroundImageURL, '#Pictures/')">
                                        <!-- creating an absolute http URL to the contained/packed image file -->
                                        <xsl:value-of select="concat($jaredRootURL, '/Pictures/', substring-after($backgroundImageURL, '#Pictures/'), $optionalURLSuffix)"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:attribute name="src"><xsl:value-of select="$backgroundImageURL"/></xsl:attribute>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:attribute>
                        </xsl:if>
                        <xsl:apply-templates select="/*/office:body">
                            <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                        </xsl:apply-templates>
                    </xsl:element>
                </xsl:element>
            </xsl:when>

            <!--+++++ PALM-VII (3.2 HTML SUBSET)  +++++-->
            <xsl:when test="$outputType = 'PALM'">
                <!-- the proxy will convert the html file later to PQA -->
                <xsl:element name="html">
                    <xsl:element name="head">
                        <xsl:call-template name='palm-header-properties'/>
                    </xsl:element>

                    <xsl:element name="body">
                        <!-- processing the content of the xml file -->
                        <xsl:apply-templates select="/*/office:body">
                            <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                        </xsl:apply-templates>
                    </xsl:element>
                </xsl:element>
            </xsl:when>
        </xsl:choose>
    </xsl:template>



    <!-- ********************************************* -->
    <!-- *** Header for CSS_INLINED and CSS_HEADER *** -->
    <!-- ********************************************* -->

    <xsl:template name='common-header-properties'>
        <xsl:apply-templates select="$office:meta-file/*/office:meta/dc:title"/>
        <xsl:apply-templates select="$office:meta-file/*/office:meta/dc:description"/>
<!--2DO add further header elements..
        <xsl:apply-templates select="$office:meta-file/*/office:meta/dc:subject"/>
        <xsl:apply-templates select="$office:meta-file/*/office:meta/meta:keywords[postition()=1]"/>-->
    </xsl:template>

    <xsl:template match="dc:title">
        <xsl:element name="title">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="dc:description">
        <xsl:element name="meta">
            <xsl:attribute name="name">
                <xsl:text>description</xsl:text>
            </xsl:attribute>
            <xsl:attribute name="content">
                <xsl:value-of select="."/>
            </xsl:attribute>
        </xsl:element>
    </xsl:template>


    <!-- ********************************************* -->
    <!-- *** Measuring the time for style creating *** -->
    <!-- ********************************************* -->


    <xsl:template name="debug-style-collecting-time">

        <xsl:variable name="startTime-RTF">
            <xsl:choose>
                <xsl:when test="function-available('system:current-time-millis')">
                    <xsl:value-of select="system:current-time-millis()"/>
                </xsl:when>
                <xsl:when test="function-available('java:java.lang.System.currentTimeMillis')">
                    <xsl:value-of select="java:java.lang.System.currentTimeMillis()"/>
                </xsl:when>
            </xsl:choose>
        </xsl:variable>



        <xsl:variable name="collectedGlobalData-RTF">
            <xsl:call-template name='create-all-inline-styles'/>
        </xsl:variable>


        <xsl:choose>
            <xsl:when test="function-available('xt:node-set')">
                <xsl:message>Creating the inline styles....</xsl:message>
                <xsl:variable name="startTime"              select="number(xt:node-set($startTime-RTF))"/>
                <xsl:variable name="collectedGlobalData"    select="xt:node-set($collectedGlobalData-RTF)"/>
                <xsl:variable name="endTime"                select="system:current-time-millis()"/>

                <xsl:message>Time for instantiating style variable: <xsl:value-of select="($endTime - $startTime)"/> ms</xsl:message>
                <xsl:call-template name="start">
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="function-available('xalan:nodeset')">
                <xsl:message>Creating the inline styles....</xsl:message>
                <xsl:variable name="startTime"              select="number(xalan:nodeset($startTime-RTF))"/>
                <xsl:variable name="endTime"                select="java:java.lang.System.currentTimeMillis()"/>
                <xsl:variable name="collectedGlobalData"    select="xalan:nodeset($collectedGlobalData-RTF)"/>

                <xsl:message>Time for instantiating style variable: <xsl:value-of select="($endTime - $startTime)"/> ms</xsl:message>
                <xsl:call-template name="start">
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                </xsl:call-template>
            </xsl:when>
        </xsl:choose>

    </xsl:template>

    <!-- DEBUG purpose only: checking the parameters of this template-->
    <xsl:template name="check-parameter">
        <xsl:message>Parameter dpi: <xsl:value-of select="$dpi"/></xsl:message>
        <xsl:message>Parameter metaFileURL: <xsl:value-of select="$metaFileURL"/></xsl:message>
        <xsl:message>Parameter stylesFileURL: <xsl:value-of select="$stylesFileURL"/></xsl:message>
        <xsl:message>Parameter absoluteSourceDirRef: <xsl:value-of select="$absoluteSourceDirRef"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel1 : <xsl:value-of select="$precedingChapterLevel1"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel2 : <xsl:value-of select="$precedingChapterLevel2"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel3 : <xsl:value-of select="$precedingChapterLevel3"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel4 : <xsl:value-of select="$precedingChapterLevel4"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel5 : <xsl:value-of select="$precedingChapterLevel5"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel6 : <xsl:value-of select="$precedingChapterLevel6"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel7 : <xsl:value-of select="$precedingChapterLevel7"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel8 : <xsl:value-of select="$precedingChapterLevel8"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel9 : <xsl:value-of select="$precedingChapterLevel9"/></xsl:message>
        <xsl:message>Parameter precedingChapterLevel10: <xsl:value-of select="$precedingChapterLevel10"/></xsl:message>
    </xsl:template>

</xsl:stylesheet>

--- NEW FILE: palm.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA  02111-1307  USA


   Sun Industry Standards Source License Version 1.1
   =================================================
   The contents of this file are subject to the Sun Industry Standards
   Source License Version 1.1 (the "License"); You may not use this file
   except in compliance with the License. You may obtain a copy of the
   License at http://www.openoffice.org/license.html.

   Software provided under this License is provided on an "AS IS" basis,
   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
   See the License for the specific provisions governing your rights and
   obligations concerning the Software.

   The Initial Developer of the Original Code is: Sun Microsystems, Inc.

   Copyright © 2002 by Sun Microsystems, Inc.

   All Rights Reserved.

   Contributor(s): _______________________________________

-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:office="http://openoffice.org/2000/office"
                xmlns:style="http://openoffice.org/2000/style"
                xmlns:text="http://openoffice.org/2000/text"
                xmlns:table="http://openoffice.org/2000/table"
                xmlns:draw="http://openoffice.org/2000/drawing"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:number="http://openoffice.org/2000/datastyle"
                xmlns:svg="http://www.w3.org/2000/svg"
                xmlns:chart="http://openoffice.org/2000/chart"
                xmlns:dr3d="http://openoffice.org/2000/dr3d"
                xmlns:math="http://www.w3.org/1998/Math/MathML"
                xmlns:form="http://openoffice.org/2000/form"
                xmlns:script="http://openoffice.org/2000/script"
                office:class="text"
                office:version="1.0"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:meta="http://openoffice.org/2000/meta"
                xmlns:config="http://openoffice.org/2001/config"
                xmlns:help="http://openoffice.org/2000/help"
                xmlns:xt="http://www.jclark.com/xt"
                xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
                xmlns:xalan="http://xml.apache.org/xalan"
                xmlns:java="http://xml.apache.org/xslt/java"
                exclude-result-prefixes="java">

    <xsl:output cdata-section-elements="meta"/>


    <!-- **************************** -->
    <!-- *** specific palm header *** -->
    <!-- **************************** -->

    <xsl:template name='palm-header-properties'>
        <xsl:element name="meta">
            <xsl:attribute name="name">PalmComputingPlatform</xsl:attribute>
            <xsl:attribute name="content">true</xsl:attribute>
        </xsl:element>
        <xsl:element name="meta">
            <xsl:attribute name="name">HandheldFriendly</xsl:attribute>
            <xsl:attribute name="content">true</xsl:attribute>
        </xsl:element>
        <xsl:element name="meta">
            <xsl:attribute name="name">HistoryListText</xsl:attribute>
            <xsl:attribute name="content">Dateimanager
: &date &time</xsl:attribute>
        </xsl:element>
        <xsl:element name="meta">
            <xsl:attribute name="name">description</xsl:attribute>
            <xsl:attribute name="content">StarPortal</xsl:attribute>
        </xsl:element>
        <xsl:element name="meta">
            <xsl:attribute name="name">keywords</xsl:attribute>
            <xsl:attribute name="content">starportal, staroffice, software</xsl:attribute>
        </xsl:element>
        <xsl:element name="meta">
            <xsl:attribute name="http-equiv">Content-Type</xsl:attribute>
            <xsl:attribute name="content">text/html; charset=iso-8859-1</xsl:attribute>
        </xsl:element>
    </xsl:template>


    <!-- ********************************* -->
    <!-- *** creating table attributes *** -->
    <!-- ********************************* -->

    <!-- table data (td) and table header (th) attributes -->
    <xsl:template name="create-attribute-ALIGN">
        <xsl:param name="styleProperties"/>

        <xsl:if test="contains($styleProperties, 'align')">
            <xsl:attribute name="align">
                 <xsl:choose>
                    <xsl:when test="contains($styleProperties, 'align:left')">
                        <xsl:text>left</xsl:text>
                    </xsl:when>
                    <xsl:when test="contains($styleProperties, 'align:right')">
                        <xsl:text>right</xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>center</xsl:text>
                    </xsl:otherwise>
                 </xsl:choose>
            </xsl:attribute>
        </xsl:if>
    </xsl:template>


    <!-- ********************************* -->
    <!-- *** creating List attributes  *** -->
    <!-- ********************************* -->
<!--
    <xsl:template name="create-list-attributes">
        <xsl:param name="styleProperties"/>


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 be implemented
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


    </xsl:template>
-->

    <!-- ************************************************ -->
    <!-- *** creating nested format tags (PALM & WML) *** -->
    <!-- ************************************************ -->

    <!-- Italic -->
    <xsl:template name="create-nested-format-tags">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="styleProperties"/>
        <xsl:choose>
            <xsl:when test="contains($styleProperties, 'italic')">
                <xsl:element name="i">
                    <xsl:call-template name="bold">
                        <xsl:with-param name="styleProperties" select="$styleProperties"/>
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    </xsl:call-template>
                </xsl:element>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="bold">
                    <xsl:with-param name="styleProperties" select="$styleProperties"/>
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- Bold -->
    <xsl:template name="bold">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="styleProperties"/>

        <xsl:choose>
            <xsl:when test="contains($styleProperties, 'bold')">
                <xsl:element name="b">
                    <xsl:call-template name="underline">
                        <xsl:with-param name="styleProperties" select="$styleProperties"/>
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    </xsl:call-template>
                </xsl:element>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="underline">
                    <xsl:with-param name="styleProperties" select="$styleProperties"/>
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- Underline : last format attribute, which is also used from WML - WML ends here! -->
    <xsl:template name="underline">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="styleProperties"/>

        <xsl:choose>
            <xsl:when test="$outputType = 'PALM'">
                <xsl:choose>
                    <xsl:when test="contains($styleProperties, 'underline')">
                        <xsl:element name="u">
                            <xsl:call-template name="strikethrough">
                                <xsl:with-param name="styleProperties" select="$styleProperties"/>
                                <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                            </xsl:call-template>
                        </xsl:element>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="strikethrough">
                            <xsl:with-param name="styleProperties" select="$styleProperties"/>
                            <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="contains($styleProperties, 'underline')">
                        <xsl:element name="u">
                            <xsl:apply-templates>
                                <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                            </xsl:apply-templates>
                        </xsl:element>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates>
                            <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                        </xsl:apply-templates>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- strikethrough -->
    <xsl:template name="strikethrough">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="styleProperties"/>

        <xsl:choose>
            <xsl:when test="contains($styleProperties, 'strike')">
                <xsl:element name="strike">
                    <xsl:call-template name="align">
                        <xsl:with-param name="styleProperties" select="$styleProperties"/>
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    </xsl:call-template>
                </xsl:element>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="align">
                    <xsl:with-param name="styleProperties" select="$styleProperties"/>
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- Alignment -->
    <xsl:template name="align">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="styleProperties"/>

        <xsl:choose>
            <xsl:when test="contains($styleProperties, 'align')">
                <xsl:element name="div">
                    <xsl:attribute name="align">
                         <xsl:choose>
                            <xsl:when test="contains($styleProperties, 'align:left')">
                                <xsl:text>left</xsl:text>
                            </xsl:when>
                            <xsl:when test="contains($styleProperties, 'align:right')">
                                <xsl:text>right</xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:text>center</xsl:text>
                            </xsl:otherwise>
                         </xsl:choose>
                    </xsl:attribute>
                    <xsl:call-template name="font_combined">
                        <xsl:with-param name="styleProperties" select="$styleProperties"/>
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    </xsl:call-template>
                </xsl:element>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="font_combined">
                    <xsl:with-param name="styleProperties" select="$styleProperties"/>
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- Both size and Color for font -->
    <xsl:template name="font_combined">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="styleProperties"/>

        <xsl:choose>
            <xsl:when test="contains($styleProperties, 'color') and contains($styleProperties, 'size')">
                <xsl:element name="font">

                    <xsl:attribute name="color">
                         <xsl:choose>
                            <xsl:when test="contains($styleProperties, 'color:#000000')">
                                <xsl:text>#000000</xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:text>#FFFFFF</xsl:text>
                            </xsl:otherwise>
                         </xsl:choose>
                    </xsl:attribute>

                    <xsl:attribute name="size">
                        <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')"/>
                    </xsl:attribute>

                    <!-- get the embedded content -->
                    <xsl:apply-templates>
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    </xsl:apply-templates>
                </xsl:element>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="font_simple">
                    <xsl:with-param name="styleProperties" select="$styleProperties"/>
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- size or Color for font -->
    <xsl:template name="font_simple">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="styleProperties"/>

        <xsl:choose>
            <xsl:when test="contains($styleProperties, 'color')">
                <xsl:element name="font">
                    <xsl:attribute name="color">
                         <xsl:choose>
                            <xsl:when test="contains($styleProperties, 'color:#000000')">
                                <xsl:text>#000000</xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:text>#FFFFFF</xsl:text>
                            </xsl:otherwise>
                         </xsl:choose>
                    </xsl:attribute>

                    <!-- get the embedded content -->
                    <xsl:apply-templates>
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    </xsl:apply-templates>
                </xsl:element>
            </xsl:when>

            <xsl:when test="contains($styleProperties, 'size')">
                <xsl:element name="font">
                    <xsl:attribute name="size">
                        <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')"/>
                    </xsl:attribute>

                    <!-- get the embedded content -->
                    <xsl:apply-templates>
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    </xsl:apply-templates>
                </xsl:element>
            </xsl:when>

            <xsl:otherwise>
                <!-- get the embedded content -->
                <xsl:apply-templates>
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                </xsl:apply-templates>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


</xsl:stylesheet>

--- NEW FILE: style_header.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA  02111-1307  USA


   Sun Industry Standards Source License Version 1.1
   =================================================
   The contents of this file are subject to the Sun Industry Standards
   Source License Version 1.1 (the "License"); You may not use this file
   except in compliance with the License. You may obtain a copy of the
   License at http://www.openoffice.org/license.html.

   Software provided under this License is provided on an "AS IS" basis,
   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
   See the License for the specific provisions governing your rights and
   obligations concerning the Software.

   The Initial Developer of the Original Code is: Sun Microsystems, Inc.

   Copyright © 2002 by Sun Microsystems, Inc.

   All Rights Reserved.

   Contributor(s): _______________________________________

-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:office="http://openoffice.org/2000/office"
                xmlns:style="http://openoffice.org/2000/style"
                xmlns:text="http://openoffice.org/2000/text"
                xmlns:table="http://openoffice.org/2000/table"
                xmlns:draw="http://openoffice.org/2000/drawing"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:number="http://openoffice.org/2000/datastyle"
                xmlns:svg="http://www.w3.org/2000/svg"
                xmlns:chart="http://openoffice.org/2000/chart"
                xmlns:dr3d="http://openoffice.org/2000/dr3d"
                xmlns:math="http://www.w3.org/1998/Math/MathML"
                xmlns:form="http://openoffice.org/2000/form"
                xmlns:script="http://openoffice.org/2000/script"
                office:class="text"
                office:version="1.0"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:meta="http://openoffice.org/2000/meta"
                xmlns:config="http://openoffice.org/2001/config"
                xmlns:help="http://openoffice.org/2000/help"
                xmlns:xt="http://www.jclark.com/xt"
                xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
                xmlns:xalan="http://xml.apache.org/xalan"
                xmlns:java="http://xml.apache.org/xslt/java"
                exclude-result-prefixes="java">



    <!-- ****************************** -->
    <!-- *** style sheet processing *** -->
    <!-- ****************************** -->


    <xsl:template name='create-css-styleheader'>
        <xsl:comment>
            <xsl:text>The CSS style header method for setting styles</xsl:text>
        </xsl:comment>
        <xsl:element name="style">
            <xsl:attribute name="type">text/css</xsl:attribute>
            <xsl:comment>
                <xsl:text>

        </xsl:text>
                <xsl:call-template name="write-default-styles"/>

                <!-- THE STYLE PROPERTIES OF THE FIRST WRITTEN STYLE (PARENT) IS GIVEN OUT -->

                <!-- 1) styles from office:styles are possible parent from all (itself or office:automatic-styles).
                     Therefore they are created first.
                     Beginning with the top-level parents (the styles without any parent). -->
                <xsl:for-each select="$office:styles/style:style[not(@style:parent-style-name)]">

                    <xsl:call-template name="write-styleproperty-line"/>
                    <xsl:call-template name="write-styleproperty-lines-for-children"/>
                </xsl:for-each>

                <xsl:text> </xsl:text>

                <!-- 2) styles from office:automatic-styles can only be parent of styles from the office:automatic-styles section.
                     Beginning with top-level styles, again, all children style will be recursivly traversed -->
                <xsl:for-each select="$office:automatic-styles/style:style[not(@style:parent-style-name)]">
                    <xsl:call-template name="write-styleproperty-line">
                        <xsl:with-param name="searchOnlyInAutomaticStyles" select="true()"/>
                    </xsl:call-template>
                    <xsl:call-template name="write-styleproperty-lines-for-children">
                        <xsl:with-param name="searchOnlyInAutomaticStyles"/>
                    </xsl:call-template>
                </xsl:for-each>
            //</xsl:comment>
        </xsl:element>
    </xsl:template>


    <xsl:template name='write-styleproperty-line'>
        <xsl:param name="searchOnlyInAutomaticStyles"/>

        <xsl:variable name="styleProperties">
            <xsl:call-template name="write-style-properties">
                <xsl:with-param name="styleAttributePath"   select="current()/style:properties/@*"/>
            </xsl:call-template>
        </xsl:variable>

        <!-- do not write styles with no css property -->
        <xsl:if test="not(string-length($styleProperties) = 0)">
            <!-- write out the name of the current (parent) style in the CSS headersection (e.g. "span.myStyle") -->
            <xsl:call-template name="write-style-name">
                <xsl:with-param name="is-parent-style" select="true()"/>
            </xsl:call-template>

            <!-- the names of all styles children will be written out(office:style AND office:automatic-style) -->
            <xsl:call-template name="write-children-style-names">
                <xsl:with-param name="parentStyleName"          select="@style:name"/>
                <xsl:with-param name="parentStyleFamily"        select="@style:family"/>
                <xsl:with-param name="searchOnlyInAutomaticStyles"/>
            </xsl:call-template>

        <!-- the style properties of the first written style (parent) is given out -->
        <xsl:text> {
                </xsl:text>
                <xsl:value-of select="$styleProperties"/>
        <xsl:text>}
        </xsl:text>

        </xsl:if>



    </xsl:template>




    <!-- RECURSION WITH ENDCONDITON: adding style classes for all existing childs -->
    <xsl:template name='write-styleproperty-lines-for-children'>
        <xsl:param name="searchOnlyInAutomaticStyles"/>

        <xsl:variable name="parentStyleName"    select="@style:name"/>
        <xsl:variable name="parentStyleFamily"  select="@style:family"/>

        <xsl:if test="not(searchOnlyInAutomaticStyles)">
            <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
                <xsl:call-template name="write-styleproperty-line"/>
                <xsl:call-template name="write-styleproperty-lines-for-children"/>
            </xsl:for-each>
        </xsl:if>
        <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
            <xsl:call-template name="write-styleproperty-line">
                <xsl:with-param name="searchOnlyInAutomaticStyles"/>
            </xsl:call-template>
            <xsl:call-template name="write-styleproperty-lines-for-children">
                <xsl:with-param name="searchOnlyInAutomaticStyles"/>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>


    <xsl:template name="write-default-styles">

        <!-- some default attributes in xml have to be explicitly set in HTML (e.g. margin-top="0") -->
        <xsl:text>*.OOo_defaults</xsl:text>

                <xsl:for-each select="$office:styles/style:style">
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
                </xsl:for-each>

                <xsl:for-each select="$office:automatic-styles/style:style">
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
                </xsl:for-each>
        <!-- 2DO: the defaults might be better collected and written in a separated (XML) file -->
<xsl:text> {
                margin-top:0cm; margin-bottom:0cm; }
        </xsl:text>

        <xsl:for-each select="$office:styles/style:default-style">
            <xsl:call-template name="write-default-style"/>
        </xsl:for-each>

        <xsl:for-each select="$office:automatic-styles/style:default-style">
            <xsl:call-template name="write-default-style"/>
        </xsl:for-each>

    </xsl:template>



    <xsl:template name="write-default-style">
        <xsl:variable name="family-style" select="@style:family"/>

        <!-- some default attributes for format families (e.g. graphics, paragraphs, etc.) written as style:default-style -->
        <xsl:value-of select="concat('*.', translate($family-style, '. %()/\', ''), '_defaults')"/>

        <xsl:for-each select="$office:styles/style:style[@style:family = $family-style]">
            <xsl:text>, </xsl:text>
            <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
        </xsl:for-each>

        <xsl:for-each select="$office:automatic-styles/style:style[@style:family = $family-style]">
            <xsl:text>, </xsl:text>
            <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
        </xsl:for-each>


        <xsl:variable name="styleProperties">
            <xsl:call-template name="write-style-properties">
                <xsl:with-param name="styleAttributePath"   select="current()/style:properties/@*"/>
            </xsl:call-template>
        </xsl:variable>

        <!-- do not write styles with no css property -->
        <xsl:if test="not(string-length($styleProperties) = 0)">
        <!-- the style properties of the first written style (parent) is given out -->
        <xsl:text> {
                </xsl:text>
                <xsl:value-of select="$styleProperties"/>
        <xsl:text>}
        </xsl:text>
        </xsl:if>

    </xsl:template>


    <!--++
          The parent style will be written out!
          For each Style:family a prefix must be added
            <!ENTITY % styleFamily
            "(paragraph|text|section|table|table-column|table-row|table-cell|table-page|chart|graphics|default|drawing-page|presentation|control)">
        ++-->
    <xsl:template name="write-style-name">
        <xsl:param name="is-parent-style"/>

        <!-- This construct is for list elements. Whenever a paragraph element is being used as child of a list element the name paragraph style is been used for
            the list item. This can be switched as the paragaph style-name and the list-style-name are in the same element.
            Otherwise there would be formatting errors (e.g. margin-left will be used for the content in the list elment and not for the list element itself). -->
        <xsl:variable name="style-name">
            <xsl:choose>
                <xsl:when test="@style:list-style-name">
                    <xsl:value-of select="@style:list-style-name"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="@style:name"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:if test="not($is-parent-style)">
            <xsl:text>, </xsl:text>
        </xsl:if>

        <xsl:choose>
            <!-- normally 'p.' would be used as CSS element,
                 but header (h1, h2,...) are also from the style:family paragraph -->
            <xsl:when test="@style:family='paragraph'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='text'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='section'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='table'">
                <xsl:value-of select="concat('table.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='table-column'">
            <!-- as column styles have to be included as span styles AFTER the table (no two class attributes in TD allowed -->
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='table-row'">
                <xsl:value-of select="concat('tr.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='table-cell'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='table-page'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='chart'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='graphics'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='default'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='drawing-page'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='presentation'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
            <xsl:when test="@style:family='control'">
                <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
            </xsl:when>
        </xsl:choose>
    </xsl:template>


    <!-- finding all style child of a section and give their styleIdentifier to the output -->
    <xsl:template name='write-children-style-names'>
        <xsl:param name="parentStyleName" select="@style:name"/>
        <xsl:param name="parentStyleFamily" select="@style:family"/>
        <xsl:param name="searchOnlyInAutomaticStyles"/>


        <!--** the names of all office:styles children will be written out
            ** (a automatic style can only have children in the office:automatic-style section) -->

        <!-- if NOT called from a office:automatic-style parent -->
        <xsl:if test="not(searchOnlyInAutomaticStyles)">
            <!-- for all children in the office:style section -->
            <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
                <!-- write the style name in the css header -->
                <xsl:call-template name="write-style-name"/>

                <!-- search for child styles -->
                <xsl:call-template name="write-children-style-names">
                    <xsl:with-param name="parentStyleName" select="@style:name"/>
                    <xsl:with-param name="parentStyleFamily" select="@style:family"/>
                </xsl:call-template>

            </xsl:for-each>
        </xsl:if>

        <!--** the names of all office:automatic-styles children will be written out -->

        <!-- for all children in the office:automatic-style section -->
        <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
            <!-- write the style name in the css header -->
            <xsl:call-template name="write-style-name"/>

            <!-- search for child styles -->
            <xsl:call-template name="write-children-style-names">
                <xsl:with-param name="parentStyleName" select="@style:name"/>
                <xsl:with-param name="parentStyleFamily" select="@style:family"/>
                <xsl:with-param name="searchOnlyInAutomaticStyles"/>
            </xsl:call-template>

        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>

--- NEW FILE: style_inlined.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA  02111-1307  USA


   Sun Industry Standards Source License Version 1.1
   =================================================
   The contents of this file are subject to the Sun Industry Standards
   Source License Version 1.1 (the "License"); You may not use this file
   except in compliance with the License. You may obtain a copy of the
   License at http://www.openoffice.org/license.html.

   Software provided under this License is provided on an "AS IS" basis,
   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
   See the License for the specific provisions governing your rights and
   obligations concerning the Software.

   The Initial Developer of the Original Code is: Sun Microsystems, Inc.

   Copyright © 2002 by Sun Microsystems, Inc.

   All Rights Reserved.

   Contributor(s): _______________________________________

-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:office="http://openoffice.org/2000/office"
                xmlns:style="http://openoffice.org/2000/style"
                xmlns:text="http://openoffice.org/2000/text"
                xmlns:table="http://openoffice.org/2000/table"
                xmlns:draw="http://openoffice.org/2000/drawing"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:number="http://openoffice.org/2000/datastyle"
                xmlns:svg="http://www.w3.org/2000/svg"
                xmlns:chart="http://openoffice.org/2000/chart"
                xmlns:dr3d="http://openoffice.org/2000/dr3d"
                xmlns:math="http://www.w3.org/1998/Math/MathML"
                xmlns:form="http://openoffice.org/2000/form"
                xmlns:script="http://openoffice.org/2000/script"
                office:class="text"
                office:version="1.0"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:meta="http://openoffice.org/2000/meta"
                xmlns:config="http://openoffice.org/2001/config"
                xmlns:help="http://openoffice.org/2000/help"
                xmlns:xt="http://www.jclark.com/xt"
                xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
                xmlns:xalan="http://xml.apache.org/xalan"
                xmlns:java="http://xml.apache.org/xslt/java"
                exclude-result-prefixes="java">



    <!-- ********************************************* -->
    <!-- *** hard attributed (inlined) properties  *** -->
    <!-- ********************************************* -->


    <!-- RESTRICTIONS:
            1)  As the styles-node-variables are NOT global, the style variables are not global, either!!
            2)  As a list of elements can only be added to a variable as a result tree fragment the
                extension is neccessary!!
    -->

    <!-- 2DO: Inline styles do not inherit from XML office defaults nor font:family defaults as the style header does
              (cp. stylesheet 'style_header.xsl' and the 'write-default-styles' template) -->

    <xsl:template name='create-all-inline-styles'>

        <!--** traversee all style trees and their branches collecting style properties **-->
        <xsl:element name="allstyles">
        <!--** traversee all office:styles trees beginning with the top-level styles**-->
            <xsl:for-each select="$office:styles/style:style[not(@style:parent-style-name)]">

                <!--** give out the style properties of the parent node **-->
                <xsl:call-template name='write-current-and-inherited-style-properties'>
                    <xsl:with-param name="styles-node"                  select="$office:styles"/>
                    <xsl:with-param name="style-family"                 select="@style:family"/>
                    <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
                </xsl:call-template>

                <!--** all office:styles children of the current top-level office:styles **-->
                <xsl:call-template name='for-all-templates-child-styles'>
                    <xsl:with-param name="parentStyleName"              select="@style:name"/>
                    <xsl:with-param name="parentStyleFamily"            select="@style:family"/>
                    <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
                </xsl:call-template>

                <!--** all office:automatic-styles children of the current top-level style **-->
                <xsl:call-template name='for-all-automatic-child-styles'>
                    <xsl:with-param name="parentStyleName"              select="@style:name"/>
                    <xsl:with-param name="parentStyleFamily"            select="@style:family"/>
                    <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
                </xsl:call-template>
            </xsl:for-each>

        <!--** traversee all office:automatic-styles trees beginning with the top-level styles **-->
            <xsl:for-each select="$office:automatic-styles/style:style[not(@style:parent-style-name)]">
                <!--** give out the style properties of the parent node **-->
                <xsl:call-template name='write-current-and-inherited-style-properties'>
                    <xsl:with-param name="styles-node"                  select="$office:automatic-styles"/>
                    <xsl:with-param name="style-family"                 select="@style:family"/>
                    <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
                </xsl:call-template>

                <!--** all children of the top-level office:automatic-styless  **-->
                <xsl:call-template name='for-all-automatic-child-styles'>
                    <xsl:with-param name="parentStyleName"              select="@style:name"/>
                    <xsl:with-param name="parentStyleFamily"            select="@style:family"/>
                    <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
                </xsl:call-template>
            </xsl:for-each>
        </xsl:element>
    </xsl:template>



    <xsl:template name='for-all-templates-child-styles'>
        <xsl:param name="parentStyleName"/>
        <xsl:param name="parentStyleFamily"/>
        <xsl:param name="style-name-tokenized"/>

        <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
            <!--** give out the style properties of the current node **-->
            <xsl:element name="{$style-name-tokenized}">
                <xsl:call-template name='write-current-and-inherited-style-properties'>
                    <xsl:with-param name="styles-node"                  select="$office:styles"/>
                    <xsl:with-param name="style-family"                 select="@style:family"/>
                    <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
                </xsl:call-template>
            </xsl:element>

            <!--** for all template-children of the current office:styles  **-->
            <xsl:call-template name='for-all-templates-child-styles'>
                <xsl:with-param name="styles-node"                  select="$office:styles"/>
                <xsl:with-param name="parentStyleName"              select="@style:name"/>
                <xsl:with-param name="parentStyleFamily"            select="@style:family"/>
                <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
            </xsl:call-template>

            <!--** for all automatic-children of the current office:styles  **-->
            <xsl:call-template name='for-all-automatic-child-styles'>
                <xsl:with-param name="styles-node"                  select="$office:automatic-styles"/>
                <xsl:with-param name="parentStyleName"              select="@style:name"/>
                <xsl:with-param name="parentStyleFamily"            select="@style:family"/>
                <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
            </xsl:call-template>

        </xsl:for-each>
    </xsl:template>



    <xsl:template name='for-all-automatic-child-styles'>
        <xsl:param name="styles-node"/>
        <xsl:param name="parentStyleName"/>
        <xsl:param name="parentStyleFamily"/>
        <xsl:param name="style-name-tokenized"/>

        <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
            <!--** give out the style properties of the current node **-->
            <xsl:element name="{$style-name-tokenized}">
                <xsl:call-template name='write-current-and-inherited-style-properties'>
                    <xsl:with-param name="styles-node"                  select="$office:automatic-styles"/>
                    <xsl:with-param name="style-family"                 select="@style:family"/>
                    <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
                </xsl:call-template>
            </xsl:element>

            <!--** for all automatic-children of the current office:automatic-styles  **-->
            <xsl:call-template name='for-all-automatic-child-styles'>
                <xsl:with-param name="styles-node"                  select="$office:automatic-styles"/>
                <xsl:with-param name="parentStyleName"              select="@style:name"/>
                <xsl:with-param name="parentStyleFamily"            select="@style:family"/>
                <xsl:with-param name="style-name-tokenized"         select="translate(@style:name, '. %()/\', '')"/>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>


    <xsl:template name='write-current-and-inherited-style-properties'>
        <xsl:param name="style-family"/>
        <xsl:param name="styles-node"/>
        <xsl:param name="style-name-tokenized"/>

        <xsl:element name="{$style-name-tokenized}">
            <xsl:variable name="current-style-name" select="@style:name"/>
            <xsl:variable name="parent-style-name" select="@style:parent-style-name"/>

            <xsl:variable name="new-property-list">
                <!--*** COLLECT STYLE ATTRIBUTES (only toplevel) ***-->
                <xsl:call-template name="write-style-properties">
                    <xsl:with-param name="styleAttributePath"   select="$styles-node/style:style[@style:family=$style-family and @style:name=$current-style-name]/style:properties/@*"/>
                </xsl:call-template>
            </xsl:variable>
            <xsl:choose>
                <!--*** @End: GIVE OUT All COLLECTED STYLE ATTRIBUTES (only toplevel) ***-->
                <xsl:when test="string-length($parent-style-name)=0">
                <!--** if no styleParent is given, the properties are given out at once **-->
                    <xsl:value-of select="normalize-space($new-property-list)"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:variable name="new-property-names">
                        <xsl:for-each select="$styles-node/style:style[@style:family=$style-family and @style:name=$current-style-name]/style:properties/@*">
                            <xsl:value-of select="name()"/>
                        </xsl:for-each>
                    </xsl:variable>
                    <!--** further attributes of the parent style must be collected **-->
                    <xsl:call-template name="add-parent-style-attributes">
                        <xsl:with-param name="property-name-list"       select="$new-property-names"/>
                        <xsl:with-param name="complete-property-list"   select="normalize-space($new-property-list)"/>
                        <xsl:with-param name="current-style-name"       select="$current-style-name"/>
                        <xsl:with-param name="parent-style-name"        select="$parent-style-name"/>
                        <xsl:with-param name="style-family"             select="$style-family"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:element>
    </xsl:template>



    <xsl:template name="add-parent-style-attributes">
        <xsl:param name="property-name-list"/>
        <xsl:param name="complete-property-list"/>
        <xsl:param name="current-style-name"/>
        <xsl:param name="parent-style-name"/>
        <xsl:param name="style-family"/>

        <!--*** New two be added property names will be collected (only one variable per template) ***-->
        <xsl:variable name="new-property-names">
            <xsl:call-template name="get-new-style-names">
                <xsl:with-param name="property-name-list"       select="$property-name-list"/>
                <xsl:with-param name="parent-style-name"        select="$parent-style-name"/>
                <xsl:with-param name="current-style-name"       select="$current-style-name"/>
            </xsl:call-template>
        </xsl:variable>

        <xsl:choose>
            <!--*** check if the new parent style exist in the office:automatic-styles section (defined by name and family) ***-->
            <xsl:when test="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$current-style-name]">
                <!--*** RECURSION: adding new parent style attributes to the current style ***-->
                <xsl:variable name="new-property-attributes">
                    <xsl:call-template name="get-new-style-attributes">
                        <xsl:with-param name="new-property-names"           select="$new-property-names"/>
                        <xsl:with-param name="current-style-name"           select="$current-style-name"/>
                        <xsl:with-param name="parent-style-name"            select="$parent-style-name"/>
                    </xsl:call-template>
                </xsl:variable>
                <!--*** End CONDITION: the last style parent has already been executed ***-->
                <xsl:variable name="new-parent-style-name"  select="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/@style:parent-style-name"/>
                <xsl:choose>
                    <xsl:when test="string-length($new-parent-style-name)=0">
                    <!--** no further parent is found, the given parameter property-node is the final style -->
                        <xsl:value-of select="concat($complete-property-list,$new-property-attributes)"/>
                    </xsl:when>
                    <xsl:otherwise>
                    <!--** further attributes of the parent style must be collected **-->
                        <xsl:call-template name="add-parent-style-attributes">
                            <xsl:with-param name="property-name-list"       select="concat($property-name-list, $new-property-names)"/>
                            <xsl:with-param name="complete-property-list"   select="concat($complete-property-list,$new-property-attributes)"/>
                            <xsl:with-param name="current-style-name"       select="$parent-style-name"/>
                            <xsl:with-param name="parent-style-name"        select="$new-parent-style-name"/>
                            <xsl:with-param name="style-family"             select="$style-family"/>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>

            <!--** the specific style (defined by name and family) must be found in the office:styles section -->
            <xsl:otherwise>
                <!--*** RECURSION: adding new parent style attributes to the current style ***-->
                <!--*** adding new parent style attributes to the current style ***-->
                <xsl:variable name="new-property-attributes">
                    <xsl:call-template name="get-new-style-attributes">
                        <xsl:with-param name="new-property-names"           select="$new-property-names"/>
                        <xsl:with-param name="current-style-name"           select="$current-style-name"/>
                        <xsl:with-param name="parent-style-name"            select="$parent-style-name"/>
                    </xsl:call-template>
                </xsl:variable>
                <!--*** End CONDITION: the last style parent has already been executed ***-->
                <xsl:variable name="new-parent-style-name"  select="$office:styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/@style:parent-style-name"/>
                <xsl:choose>
                    <xsl:when test="string-length($new-parent-style-name)=0">
                    <!--** no further parent is found, the given parameter property-node is the final style -->
                        <xsl:value-of select="concat($complete-property-list,$new-property-attributes)"/>
                    </xsl:when>
                    <xsl:otherwise>
                    <!--** further attributes of the parent style must be collected **  -->
                        <xsl:call-template name="add-parent-style-attributes">
                            <xsl:with-param name="property-name-list"       select="concat($property-name-list, $new-property-names)"/>
                            <xsl:with-param name="complete-property-list"   select="concat($complete-property-list,$new-property-attributes)"/>
                            <xsl:with-param name="current-style-name"       select="$parent-style-name"/>
                            <xsl:with-param name="parent-style-name"        select="$new-parent-style-name"/>
                            <xsl:with-param name="style-family"             select="$style-family"/>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



    <xsl:template name="get-new-style-names">
        <xsl:param name="property-name-list"/>
        <xsl:param name="parent-style-name"/>
        <xsl:param name="current-style-name"/>
        <!--** where to find the specific style (defined by name and family) wheter in office:automatic-styles or office:styles section -->
        <xsl:choose>
            <!--** if the specific style (defined by name and family) can be found in the office:automatic-styles section -->
            <xsl:when test="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]">
                <xsl:variable name="parent-property-node" select="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>

                <xsl:variable name="new-property-name-list">
                    <xsl:for-each select="$parent-property-node/@*[not(contains($property-name-list, name()))]">
                        <xsl:value-of select="name()"/>
                    </xsl:for-each>
                </xsl:variable>
                <xsl:value-of select="$new-property-name-list"/>
            </xsl:when>
            <!--** the specific style (defined by name and family) should be found in the office:styles section -->
            <xsl:otherwise>
                <xsl:variable name="parent-property-node" select="$office:styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
                <xsl:variable name="new-property-name-list">
                    <xsl:for-each select="$parent-property-node/@*[not(contains($property-name-list, name()))]">
                        <xsl:value-of select="name()"/>
                    </xsl:for-each>
                </xsl:variable>
                <xsl:value-of select="$new-property-name-list"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



    <xsl:template name="get-new-style-attributes">
        <xsl:param name="new-property-names"/>
        <xsl:param name="current-style-name"/>
        <xsl:param name="parent-style-name"/>

        <!--** where to find the specific style (defined by name and family) whether in office:automatic-styles or office:styles section -->
        <xsl:choose>
            <!--** if the specific style (defined by name and family) can be found in the office:automatic-styles section -->
            <xsl:when test="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]">
                <xsl:variable name="parent-property-node" select="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
                <xsl:variable name="new-property-name-list">
                    <xsl:call-template name="write-style-properties">
                        <xsl:with-param name="styleAttributePath"   select="$parent-property-node/@*[contains($new-property-names, name())]"/>
                    </xsl:call-template>
                </xsl:variable>
                <xsl:value-of select="normalize-space($new-property-name-list)"/>
            </xsl:when>
            <!--** otherwise the specific style (defined by name and family) should be found in the office:styles section -->
            <xsl:otherwise>
                <xsl:variable name="parent-property-node" select="$office:styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
                <xsl:variable name="new-property-name-list">
                    <xsl:call-template name="write-style-properties">
                        <xsl:with-param name="styleAttributePath"   select="$parent-property-node/@*[contains($new-property-names, name())]"/>
                    </xsl:call-template>
                </xsl:variable>
                <xsl:value-of select="normalize-space($new-property-name-list)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


</xsl:stylesheet>

--- NEW FILE: style_mapping.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA  02111-1307  USA


   Sun Industry Standards Source License Version 1.1
   =================================================
   The contents of this file are subject to the Sun Industry Standards
   Source License Version 1.1 (the "License"); You may not use this file
   except in compliance with the License. You may obtain a copy of the
   License at http://www.openoffice.org/license.html.

   Software provided under this License is provided on an "AS IS" basis,
   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
   See the License for the specific provisions governing your rights and
   obligations concerning the Software.

   The Initial Developer of the Original Code is: Sun Microsystems, Inc.

   Copyright © 2002 by Sun Microsystems, Inc.

   All Rights Reserved.

   Contributor(s): _______________________________________

-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:office="http://openoffice.org/2000/office"
                xmlns:style="http://openoffice.org/2000/style"
                xmlns:text="http://openoffice.org/2000/text"
                xmlns:table="http://openoffice.org/2000/table"
                xmlns:draw="http://openoffice.org/2000/drawing"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:number="http://openoffice.org/2000/datastyle"
                xmlns:svg="http://www.w3.org/2000/svg"
                xmlns:chart="http://openoffice.org/2000/chart"
                xmlns:dr3d="http://openoffice.org/2000/dr3d"
                xmlns:math="http://www.w3.org/1998/Math/MathML"
                xmlns:form="http://openoffice.org/2000/form"
                xmlns:script="http://openoffice.org/2000/script"
                office:class="text"
                office:version="1.0"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:meta="http://openoffice.org/2000/meta"
                xmlns:config="http://openoffice.org/2001/config"
                xmlns:help="http://openoffice.org/2000/help"
                xmlns:xt="http://www.jclark.com/xt"
                xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
                xmlns:xalan="http://xml.apache.org/xalan"
                xmlns:java="http://xml.apache.org/xslt/java"
                exclude-result-prefixes="java">


    <xsl:template name="write-style-properties">
        <xsl:param name="styleAttributePath"/>

        <xsl:choose>
            <!--+++++ CSS PROPERTIES  +++++-->
            <xsl:when test="$outputType = 'CSS_HEADER' or $outputType = 'CSS_INLINED'">

                <xsl:for-each select="$styleAttributePath">
                <!-- isDebugModeMESSAGE:
                    <xsl:message> Name:<xsl:value-of select="name()"/> Value:<xsl:value-of select="."/></xsl:message>      -->


                    <!-- <!ATTLIST style:properties style:horizontal-pos (from-left|left|center|right|from-inside|inside|outside)#IMPLIED>-->
                    <!-- 2DO: is inside/from-inside also better showable ? -->
                    <!-- !!!! 2DO: Still there have to be placed a <br clear='all'/> to disable the flow!!!!-->
                    <!--           The OOo attribute 'style:number-wrapped-paragraphs' is currently ignored -->
                    <xsl:choose>
                        <xsl:when test='name(.)="style:wrap"'>
                            <xsl:choose>
                                <xsl:when test='.="left"'>
                                    <xsl:text>float: right; </xsl:text>
                                </xsl:when>
                                <xsl:when test='.="right"'>
                                    <xsl:text>float: left; </xsl:text>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:when>

                        <xsl:when test='name(.) = "style:horizontal-pos"'>
                            <xsl:choose>
                                <xsl:when test='.="left"'>
                                    <xsl:text>align: left; </xsl:text>
                                </xsl:when>
                                <xsl:when test='.="right"'>
                                    <xsl:text>align: right; </xsl:text>
                                </xsl:when>
                                <xsl:when test='.="center"'>
                                    <xsl:text>align: center; </xsl:text>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:when>
<!-- results into a bad view (overlapped) in Mozilla 1.0
                        <xsl:when test='name(.) = "table:align"'>
                            <xsl:choose>
                                <xsl:when test='.="left"'>
                                    <xsl:text>float: right; </xsl:text>
                                </xsl:when>
                                <xsl:when test='.="right"'>
                                    <xsl:text>float: left; </xsl:text>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:when>
-->

                        <!-- PADDING for all variations: fo:padding, fo:padding-top, fo:padding-bottom, fo:padding-left, fo:padding-right -->
                        <xsl:when test='contains(name(.),"fo:padding")'>
                            <xsl:text>padding: </xsl:text>
                            <xsl:value-of select="."/>
                            <xsl:text>; </xsl:text>
                        </xsl:when>
                        <!--
                        fo:border
                        fo:border-top
                        fo:border-bottom
                        fo:border-left
                        fo:border-right

                            At present, all four borders must be set simultaneously by using either
                            the fo:border property or by attaching all four of the other border
                            properties to an item set element. In the latter case, if one or more
                            of the properties is missing their values are assumed to be none. The
                            only border styles supported are none or hidden, solid, and double. Any
                            other border style specified is displayed as solid. Transparent borders
                            are not supported and the border widths thin, medium, and thick are
                            mapped to lengths. In addition, only some distinct border widths are
                            supported. Unsupported widths are rounded up to the next supported
                            width.
                            If there are no padding properties specified within the same
                            item set element, a default padding is used for sides that have a
                            border. A value of 0cm is used for sides without a border.
                            (cp. wd-so-xml-text.sdw)
                        -->

<!--2DO START: change measurement equally -->
                        <xsl:when test='name(.)="fo:border"'>
                            <xsl:choose>
                                <!-- changing the distance measure: inch to in -->
                                <xsl:when test="contains(., 'ch')">
                                    <xsl:text>border-width:</xsl:text><xsl:value-of select="substring-before(.,'ch ')"/><xsl:text>; </xsl:text>
                                    <xsl:text>border-style:</xsl:text><xsl:value-of select="substring-before(substring-after(.,'ch '), ' ')"/><xsl:text>; </xsl:text>
                                    <xsl:text>border-color:</xsl:text><xsl:value-of select="substring-after(substring-after(.,'ch '), ' ')"/><xsl:text>; </xsl:text>
                                </xsl:when>
                                <xsl:when test="contains(., 'cm')">
                                    <xsl:text>border-width:</xsl:text><xsl:value-of select="substring-before(.,' ')"/><xsl:text>; </xsl:text>
                                    <xsl:text>border-style:</xsl:text><xsl:value-of select="substring-before(substring-after(.,'cm '), ' ')"/><xsl:text>; </xsl:text>
                                    <xsl:text>border-color:</xsl:text><xsl:value-of select="substring-after(substring-after(.,'cm '), ' ')"/><xsl:text>; </xsl:text>
                                </xsl:when>
                                <xsl:when test="contains(., 'pt')">
                                    <xsl:text>border-width:</xsl:text><xsl:value-of select="substring-before(.,' ')"/><xsl:text>; </xsl:text>
                                    <xsl:text>border-style:</xsl:text><xsl:value-of select="substring-before(substring-after(.,'pt '), ' ')"/><xsl:text>; </xsl:text>
                                    <xsl:text>border-color:</xsl:text><xsl:value-of select="substring-after(substring-after(.,'pt '), ' ')"/><xsl:text>; </xsl:text>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:border-top"'>
                            <xsl:text>border-top: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:border-bottom"'>
                            <xsl:text>border-bottom: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:border-left"'>
                            <xsl:text>border-left: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:border-right"'>
                            <xsl:text>border-right: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="style:column-width"'>
                            <xsl:choose>
                                <!-- changing the distance measure: inch to in -->
                                <xsl:when test="contains(., 'ch')">
                                    <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>; </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:when test='name(.)="style:row-height"'>
                            <xsl:choose>
                                <!-- changing the distance measure: inch to in -->
                                <xsl:when test="contains(., 'ch')">
                                    <xsl:text>height:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>; </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>height:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:width"'>
                            <xsl:choose>
                                <!-- changing the distance measure: inch to in -->
                                <xsl:when test="contains(., 'ch')">
                                    <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>; </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
<!--2DO END: change measurement equally -->
                        <xsl:when test='name(.)="fo:font-style"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="style:font-name"'>
                            <xsl:text>font-family:</xsl:text>
                                <xsl:variable name="content" select="."/>
                                <xsl:value-of select="$office:font-decls/style:font-decl[@style:name=$content]/@fo:font-family"/>
                            <xsl:text>; </xsl:text>
                            <xsl:if test="contains($office:font-decls/style:font-decl[@style:name=$content]/@style:font-style-name, 'Italic')">
                                <xsl:text>font-style:italic; </xsl:text>
                            </xsl:if>
                            <xsl:if test="contains($office:font-decls/style:font-decl[@style:name=$content]/@style:font-style-name, 'Bold')">
                                <xsl:text>font-weight:bold; </xsl:text>
                            </xsl:if>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:font-weight"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:font-size"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:font-family"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:color"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:margin-left"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:margin-right"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:margin-top"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:margin-bottom"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:line-height"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:text-align"'>
                            <!-- IMPORTANT is necessary as table cell value alignment is decided by runtime over the valuetype
                                 Otherwise a table cell style-class will ALWAYS be overwritten by the run-time value -->
                             <xsl:choose>
                                <xsl:when test="contains(., 'start')">
                                    <xsl:text>text-align:left ! important; </xsl:text>
                                </xsl:when>
                                <xsl:when test="contains(., 'end')">
                                    <xsl:text>text-align:right ! important; </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>text-align:</xsl:text><xsl:value-of select='.'/><xsl:text> ! important; </xsl:text>
                                </xsl:otherwise>
                             </xsl:choose>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:text-indent"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="style:text-background-color"'>
                            <xsl:text>background-color:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="fo:background-color"'>
                            <xsl:text>background-color:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="style:background-image"'>
                            <xsl:text>background-image:url(</xsl:text><xsl:value-of select="@xlink:href"/><xsl:text>); </xsl:text>
                            <xsl:choose>
                                <xsl:when test="@style:repeat = 'repeat'">
                                    <xsl:text>background-repeat:repeat; </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>background-repeat:no-repeat; </xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- text-shadow is a CSS2 feature and yet not common used in user-agents -->
                        <xsl:when test='name(.)="fo:text-shadow"'>
                            <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="style:text-crossing-out"'>
                            <xsl:if test='not(.="none")'>
                                <xsl:text>text-decoration:line-through; </xsl:text>
                            </xsl:if>
                        </xsl:when>
                        <xsl:when test='name(.)="style:text-underline"'>
                            <xsl:if test='not(.="none")'>
                                <xsl:text>text-decoration:underline; </xsl:text>
                            </xsl:if>
                        </xsl:when>
                        <xsl:when test='name(.)="style:text-position"'>
                            <xsl:if test='contains(., "sub")'>
                                <xsl:text>vertical-align:sub; </xsl:text>
                            </xsl:if>
                            <xsl:if test='contains(., "sup")'>
                                <xsl:text>vertical-align:sup; </xsl:text>
                            </xsl:if>
                        </xsl:when>
                        <!-- isDebugModeMESSAGE:
                        <xsl:otherwise>
                                <xsl:message>No transformation implemented for attribute-typ <xsl:value-of select="name(.)"/></xsl:message>
                        </xsl:otherwise>-->
                    </xsl:choose>
                </xsl:for-each>
            </xsl:when>
            <!--+++++ PALM 3.2 SUBSET AND WAP PROPERTIES  +++++-->
            <xsl:otherwise>
                <xsl:for-each select="$styleAttributePath">
                    <!-- isDebugModeMESSAGE:
                    <xsl:message> Name:<xsl:value-of select="name()"/> Value:<xsl:value-of select="."/></xsl:message>      -->

                    <!-- BUG WORK AROUND:
                    Due to a bug in the XT Processor, it is not possible to create serveral elements in variable and search over them,
                    after explicit conversion to nodeset
                    This generated sting identifier shall be later changed back to a set of elements
                    -->
                    <xsl:choose>
                        <!--*** FORMAT ATTRIBUTES ***-->

                        <!-- Italic -->
                        <xsl:when test='name(.)="fo:font-style"'>
                            <xsl:if test="contains(., 'italic') or contains(., 'oblique')">
                                <xsl:text>italic, </xsl:text>
                            </xsl:if>
                        </xsl:when>

                        <!-- Boldface -->
                        <xsl:when test='name(.)="fo:font-weight"'>
                            <xsl:if test="contains(., 'bold') or contains(., 'bolder')">
                                <xsl:text>bold, </xsl:text>
                            </xsl:if>
                        </xsl:when>

                        <!-- Underline -->
                        <xsl:when test='name(.)="style:text-underline"'>
                            <xsl:text>underline, </xsl:text>
                        </xsl:when>

                        <!-- Alignment -->
                        <xsl:when test='name(.)="fo:text-align"'>
                             <xsl:choose>
                                <xsl:when test="contains(., 'start')">
                                    <xsl:text>align:left, </xsl:text>
                                </xsl:when>
                                <xsl:when test="contains(., 'end')">
                                    <xsl:text>align:right, </xsl:text>
                                </xsl:when>
                                <xsl:when test="contains(., 'center')">
                                    <xsl:text>align:center, </xsl:text>
                                </xsl:when>
                             </xsl:choose>
                        </xsl:when>

                        <!-- strikethrough -->
                        <xsl:when test='name(.)="style:text-crossing-out"'>
                            <xsl:text>strike, </xsl:text>
                        </xsl:when>

                        <!-- Font - size (Palm: emulator transformed sizes to available set (e.g. 30 to (probably) 9)-->
                        <xsl:when test='name(.)="fo:font-size"'>
                            <xsl:text>size:</xsl:text><xsl:value-of select="."/><xsl:text>:size, </xsl:text>
                        </xsl:when>

                        <!-- Font - Color (PALM: but mostly only 2 available)
                            black (#000000)
                            gray (#808080)(rendered as dark gray)
                            silver (#C0C0C0)(rendered as light gray)
                            white (#FFFFFF)-->
                        <xsl:when test='name(.)="fo:color"'>
                            <xsl:choose>
                                <xsl:when test="contains(. , '#FFFFFF') or contains(. , '#ffffff') or contains(. , 'white') or contains(. , 'WHITE')">
                                    <xsl:text>color:#FFFFFF, </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>color:#000000, </xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>


                        <!--*** TABLE ATTRIBUTES ***-->
                        <xsl:when test='name(.)="fo:font-size"'>
                            <xsl:text>size:</xsl:text><xsl:value-of select="."/><xsl:text>:size, </xsl:text>
                        </xsl:when>
                        <xsl:when test='name(.)="style:column-width"'>
                            <xsl:choose>
                                <!-- changing the distance measure: inch to in -->
                                <xsl:when test="contains(., 'ch')">
                                    <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>:width, </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>:width; </xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:when test='name(.)="style:row-height"'>
                            <xsl:choose>
                                <!-- changing the distance measure: inch to in -->
                                <xsl:when test="contains(., 'ch')">
                                    <xsl:text>height:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>:height; </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>height:</xsl:text><xsl:value-of select="."/><xsl:text>:height; </xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:when test='name(.)="style:width"'> <!--earlier fo:width-->
                            <xsl:choose>
                                <!-- changing the distance measure: inch to in -->
                                <xsl:when test="contains(., 'ch')">
                                    <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>:width; </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>:width; </xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                    </xsl:choose>
                </xsl:for-each>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



<!-- 2DO: NAMING CONVENTION variable are written with '-' instead of case-sensitive writing -->



    <!-- ***** MEASUREMENT CONVERSIONS *****

     * 1 centimeter = 10 mm

     * 1 inch = 25.4 mm
        While the English have already seen the light (read: the metric system), the US
        remains loyal to this medieval system.

     * 1 didot point = 0.376065 mm
            The didot system originated in France but was used in most of Europe

     * 1 pica point = 0.35146 mm
            The Pica points system was developed in England and is used in Great-Britain and the US.

     * 1 PostScript point = 0.35277138 mm
            When Adobe created PostScript, they added their own system of points.
            There are exactly 72 PostScript points in 1 inch.

     * 1 pixel = 0.26458333.. mm   (by 96 dpi)
            Most pictures have the 96 dpi resolution, but the dpi variable may vary by stylesheet parameter
    -->


    <!-- changing measure to mm -->
    <xsl:template name="convert2mm">
        <xsl:param name="value"/>

        <xsl:param name="centimeter-in-mm"          select="10"/>
        <xsl:param name="inch-in-mm"                select="25.4"/>
        <xsl:param name="didot-point-in-mm"         select="0.376065"/>
        <xsl:param name="pica-point-in-mm"          select="0.35146"/>

        <xsl:choose>
            <xsl:when test="contains($value, 'cm')">
                <xsl:value-of select="round(number(substring-before($value,'cm' )) * $centimeter-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'in')">
                <xsl:value-of select="round(number(substring-before($value,'in' )) * $inch-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'dpt')">
                <xsl:value-of select="round(number(substring-before($value,'dpt')) * $didot-point-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'ppt')">
                <xsl:value-of select="round(number(substring-before($value,'ppt')) * $pica-point-in-mm)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$value"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- changing measure to cm -->
    <xsl:template name="convert2cm">
        <xsl:param name="value"/>

        <xsl:param name="centimeter-in-mm"          select="10"/>
        <xsl:param name="inch-in-mm"                select="25.4"/>
        <xsl:param name="didot-point-in-mm"         select="0.376065"/>
        <xsl:param name="pica-point-in-mm"          select="0.35146"/>

        <xsl:choose>
            <xsl:when test="contains($value, 'mm')">
                <xsl:value-of select="round(number(substring-before($value, 'mm')) div $centimeter-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'in')">
                <xsl:value-of select="round(number(substring-before($value, 'in')) div $centimeter-in-mm * $inch-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'dpt')">
                <xsl:value-of select="round(number(substring-before($value,'dpt')) div $centimeter-in-mm * $didot-point-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'ppt')">
                <xsl:value-of select="round(number(substring-before($value,'ppt')) div $centimeter-in-mm * $pica-point-in-mm)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$value"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- changing measure to inch (cp. section comment) -->
    <xsl:template name="convert2inch">
        <xsl:param name="value"/>

        <xsl:param name="centimeter-in-mm"          select="10"/>
        <xsl:param name="inch-in-mm"                select="25.4"/>
        <xsl:param name="didot-point-in-mm"         select="0.376065"/>
        <xsl:param name="pica-point-in-mm"          select="0.35146"/>

        <xsl:choose>
            <xsl:when test="contains($value, 'mm')">
                <xsl:value-of select="round(number(substring-before($value, 'mm')) div $inch-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'cm')">
                <xsl:value-of select="round(number(substring-before($value, 'cm')) div $inch-in-mm * $centimeter-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'dpt')">
                <xsl:value-of select="round(number(substring-before($value,'dpt')) div $inch-in-mm * $didot-point-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'ppt')">
                <xsl:value-of select="round(number(substring-before($value,'ppt')) div $inch-in-mm * $pica-point-in-mm)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$value"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- changing measure to dpt (cp. section comment) -->
    <xsl:template name="convert2dpt">
        <xsl:param name="value"/>

        <xsl:param name="centimeter-in-mm"          select="10"/>
        <xsl:param name="inch-in-mm"                select="25.4"/>
        <xsl:param name="didot-point-in-mm"         select="0.376065"/>
        <xsl:param name="pica-point-in-mm"          select="0.35146"/>

        <xsl:choose>
            <xsl:when test="contains($value, 'mm')">
                <xsl:value-of select="round(number(substring-before($value, 'mm')) div $didot-point-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'cm')">
                <xsl:value-of select="round(number(substring-before($value, 'cm')) div $didot-point-in-mm * $centimeter-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'in')">
                <xsl:value-of select="round(number(substring-before($value, 'in')) div $didot-point-in-mm * $inch-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'ppt')">
                <xsl:value-of select="round(number(substring-before($value,'ppt')) div $didot-point-in-mm * $pica-point-in-mm)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$value"/>
            </xsl:otherwise>
        </xsl:choose>

    </xsl:template>


    <!-- changing measure to ppt (cp. section comment) -->
    <xsl:template name="convert2ppt">
        <xsl:param name="value"/>

        <xsl:param name="centimeter-in-mm"          select="10"/>
        <xsl:param name="inch-in-mm"                select="25.4"/>
        <xsl:param name="didot-point-in-mm"         select="0.376065"/>
        <xsl:param name="pica-point-in-mm"          select="0.35146"/>

        <xsl:choose>
            <xsl:when test="contains($value, 'mm')">
                <xsl:value-of select="round(number(substring-before($value, 'mm')) div $pica-point-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'cm')">
                <xsl:value-of select="round(number(substring-before($value, 'cm')) div $pica-point-in-mm * $centimeter-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'in')">
                <xsl:value-of select="round(number(substring-before($value, 'in')) div $pica-point-in-mm * $inch-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'dpt')">
                <xsl:value-of select="round(number(substring-before($value,'dpt')) div $pica-point-in-mm * $didot-point-in-mm)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$value"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- changing measure to pixel by via parameter provided dpi (dots per inch) standard factor (cp. section comment) -->
    <xsl:template name="convert2pixel">
        <xsl:param name="value"/>

        <xsl:param name="centimeter-in-mm"          select="10"/>
        <xsl:param name="inch-in-mm"                select="25.4"/>
        <xsl:param name="didot-point-in-mm"         select="0.376065"/>
        <xsl:param name="pica-point-in-mm"          select="0.35146"/>
        <xsl:param name="pixel-in-mm"               select="$inch-in-mm div $dpi"/>

        <xsl:choose>
            <xsl:when test="contains($value, 'mm')">
                <xsl:value-of select="round(number(substring-before($value, 'mm')) div $pixel-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'cm')">
                <xsl:value-of select="round(number(substring-before($value, 'cm')) div $pixel-in-mm * $centimeter-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'in')">
                <xsl:value-of select="round(number(substring-before($value, 'in')) div $pixel-in-mm * $inch-in-mm)"/>
            </xsl:when>
            <xsl:when test="contains($value, 'dpt')">
                <xsl:value-of select="round(number(substring-before($value,'dpt')) div $pixel-in-mm * $didot-point-in-mm)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$value"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>

--- NEW FILE: table.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA  02111-1307  USA


   Sun Industry Standards Source License Version 1.1
   =================================================
   The contents of this file are subject to the Sun Industry Standards
   Source License Version 1.1 (the "License"); You may not use this file
   except in compliance with the License. You may obtain a copy of the
   License at http://www.openoffice.org/license.html.

   Software provided under this License is provided on an "AS IS" basis,
   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
   See the License for the specific provisions governing your rights and
   obligations concerning the Software.

   The Initial Developer of the Original Code is: Sun Microsystems, Inc.

   Copyright © 2002 by Sun Microsystems, Inc.

   All Rights Reserved.

   Contributor(s): _______________________________________

-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:office="http://openoffice.org/2000/office"
                xmlns:style="http://openoffice.org/2000/style"
                xmlns:text="http://openoffice.org/2000/text"
                xmlns:table="http://openoffice.org/2000/table"
                xmlns:draw="http://openoffice.org/2000/drawing"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:number="http://openoffice.org/2000/datastyle"
                xmlns:svg="http://www.w3.org/2000/svg"
                xmlns:chart="http://openoffice.org/2000/chart"
                xmlns:dr3d="http://openoffice.org/2000/dr3d"
                xmlns:math="http://www.w3.org/1998/Math/MathML"
                xmlns:form="http://openoffice.org/2000/form"
                xmlns:script="http://openoffice.org/2000/script"
                office:class="text"
                office:version="1.0"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:meta="http://openoffice.org/2000/meta"
                xmlns:config="http://openoffice.org/2001/config"
                xmlns:help="http://openoffice.org/2000/help"
                xmlns:xt="http://www.jclark.com/xt"
                xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
                xmlns:xalan="http://xml.apache.org/xalan"
                xmlns:java="http://xml.apache.org/xslt/java"
                exclude-result-prefixes="java">


    <!-- table row handling -->
    <xsl:include href="table_rows.xsl"/>
    <!-- table column handling -->
    <xsl:include href="table_columns.xsl"/>
    <!-- table cell handling -->
    <xsl:include href="table_cells.xsl"/>



    <!-- ******************* -->
    <!-- *** main table  *** -->
    <!-- ******************* -->

    <xsl:template match="table:table | table:sub-table">
        <xsl:param name="collectedGlobalData"/>

        <!-- a table will only be created if the "scenario" is active -->
        <xsl:if test="string-length(table:scenario/@table:is-active) = 0">
            <!-- collecting all visible "table:table-row" elements of the table -->
            <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')]"/>
            <xsl:choose>
                <!-- for all but WAP/WML devices a table border check is done (cp. "check-for-table-border") -->
                <xsl:when test="not($outputType = 'WML')">

                    <!-- As the alignment of a table is by 'align' attribut is deprecated and as the CSS 'float' attribute not well displayed,
                         we do a little trick by encapsulating the table with a aligned 'div' element-->
                    <xsl:variable name="table-alignment" select="$office:automatic-styles/style:style[@style:name = current()/@table:style-name]/style:properties/@table:align"/>

                    <xsl:choose>
                        <xsl:when test="string-length($table-alignment) != 0">
                            <xsl:element name="div">
                                <xsl:attribute name="align">
                                    <xsl:choose>
                                        <xsl:when test='$table-alignment="left" or $table-alignment="margins"'>
                                                <xsl:text>left</xsl:text>
                                        </xsl:when>
                                        <xsl:when test='$table-alignment="right"'>
                                            <xsl:text>right</xsl:text>
                                        </xsl:when>
                                        <xsl:when test='$table-alignment="center"'>
                                            <xsl:text>center</xsl:text>
                                        </xsl:when>
                                    </xsl:choose>
                                </xsl:attribute>
                                <xsl:element name="table">

                                    <xsl:apply-templates select="@table:style-name">
                                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                                    </xsl:apply-templates>

                                    <!-- workaround, set table border attribut if any cell-border exists
                                    <xsl:call-template name="check-for-table-border">
                                        <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
                                    </xsl:call-template> -->
                                    <xsl:call-template name="create-column-style-variable">
                                        <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
                                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                                    </xsl:call-template>
                                </xsl:element>
                            </xsl:element>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:element name="table">
                                <xsl:apply-templates select="@table:style-name">
                                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                                </xsl:apply-templates>

                                <!-- workaround, set table border attribut if any cell-border exists
                                <xsl:call-template name="check-for-table-border">
                                    <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
                                </xsl:call-template>  -->
                                <xsl:call-template name="create-column-style-variable">
                                    <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
                                     <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                                </xsl:call-template>
                            </xsl:element>
                        </xsl:otherwise>
                    </xsl:choose>

                </xsl:when>
                <xsl:otherwise>
                <!-- for WML devices only ASCII table are written as tables are not implemented widley.
                     Beginning from 'repeat-write-row' the templates are handled by the table_wml.xsl stylesheet -->
                    <xsl:call-template name="create-column-style-variable">
                        <xsl:with-param name="collectedGlobalData"   select="$collectedGlobalData"/>
                        <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:template>



    <xsl:template name="create-column-style-variable">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="allVisibleTableRows"/>

        <!-- all columns of the table -->
        <xsl:variable name="allTableColumns" select="table:table-column |
                                                     table:table-column-group/descendant::table:table-column |
                                                     table:table-header-columns/descendant::table:table-column"/>
        <!-- allColumnStyleEntries: Containing all columns of the table, hidden and viewed.
            - if a column is hidden, it contains the hidden attribute, otherwise the style-properties will be stored
            - if a column is being repeated, each repeated column is explicitly written as entry in this variable.
              Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
              the position() of the column entry and comparing it with the iterating cell number. -->
        <xsl:variable name="allColumnStyleEntries-RTF">
            <xsl:call-template name="adding-column-styles-entries">
                <xsl:with-param name="collectedGlobalData"   select="$collectedGlobalData"/>
                <xsl:with-param name="allTableColumns"      select="$allTableColumns"/>
            </xsl:call-template>
        </xsl:variable>

        <xsl:choose>
            <xsl:when test="function-available('xt:node-set')">
                <xsl:call-template name="create-table">
                    <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
                    <xsl:with-param name="allVisibleTableRows"      select="$allVisibleTableRows"/>
                    <xsl:with-param name="allColumnStyleEntries"    select="xt:node-set($allColumnStyleEntries-RTF)"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="function-available('xalan:nodeset')">
                <xsl:call-template name="create-table">
                    <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
                    <xsl:with-param name="allVisibleTableRows"      select="$allVisibleTableRows"/>
                    <xsl:with-param name="allColumnStyleEntries"    select="xalan:nodeset($allColumnStyleEntries-RTF)"/>
                </xsl:call-template>
            </xsl:when>
        </xsl:choose>

    </xsl:template>



    <xsl:template name="create-table">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="allVisibleTableRows"/>
        <xsl:param name="allColumnStyleEntries"/>


        <!-- Some Office Calc documents simulate a background by repeating the last cell until end of space
             (The value of "table:number-columns-repeated" is enourmous). Writing out all these cells would be fatal.
             Therefore, this global variable shows us the longest row with content.

        Earlier only the viewable columns were listed, but it is easier to handle with all columns:
        <xsl:variable name="maxRowLength" select="count($allColumnStyleEntries/column-style-entry[not(@column-hidden-flag)])"/> -->
        <xsl:variable name="maxRowLength" select="count($allColumnStyleEntries/column-style-entry)"/>


        <!--isDebugMode-START-->
        <xsl:if test="$isDebugMode">
            <xsl:message>maxRowLength: <xsl:value-of select="$maxRowLength"/></xsl:message>
            <xsl:variable name="numberOfHiddenColumns" select="count($allColumnStyleEntries/column-style-entry[@column-hidden-flag])"/>
            <xsl:message>numberOfHiddenColumns: <xsl:value-of select="$numberOfHiddenColumns"/></xsl:message>
            <xsl:call-template name="table-debug-allColumnStyleEntries">
                <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
            </xsl:call-template>
        </xsl:if>
        <!--isDebugMode-END-->
        <xsl:choose>
            <xsl:when test="$outputType = 'WML'">
                <!-- matching all rows - we can not use xsl:apply-template with a node-set parameter as by a bug in XT (James Clark)
                     (here: allColumnStyleEntries) will be interpreted as a result tree fragment, where no search expression (XPath) can be used
                     2DO:CHECK WITH XALAN-->
                <xsl:for-each select="$allVisibleTableRows">
                    <xsl:call-template name="wml-repeat-write-row">
                        <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
                        <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                        <xsl:with-param name="number-rows-repeated"     select="@table:number-rows-repeated"/>
                        <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                    </xsl:call-template>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
                <!-- matching all rows - we can not use xsl:apply-template with a node-set parameter as by a bug in XT (James Clark)
                     (here: allColumnStyleEntries) will be interpreted as a result tree fragment, where no search expression (XPath) can be used
                     2DO:CHECK WITH XALAN -->
                <xsl:for-each select="$allVisibleTableRows">
                    <xsl:call-template name="repeat-write-row">
                        <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
                        <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                        <xsl:with-param name="number-rows-repeated"     select="@table:number-rows-repeated"/>
                        <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                    </xsl:call-template>
                </xsl:for-each>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>





    <!-- **************************** -->
    <!-- *** HELPER: table border *** -->
    <!-- **************************** -->

    <!-- only one table border for HTML4 or CSS devices which contain one or more 'fo:border-top' attributes (pars pro toto, if one exist the other usually exist, too) -->
    <!-- this was a work-around for the netscape 4.xx but not longer necessary for Mozilla -->
    <xsl:template name="check-for-table-border">
        <xsl:param name="allVisibleTableRows"/>

        <xsl:variable name="startTime">
            <xsl:if test="$isDebugMode and not($isJavaDisabled)">
                <xsl:choose>
                    <xsl:when test="function-available('system:current-time-millis')">
                        <xsl:value-of select="system:current-time-millis()"/>
                    </xsl:when>
                    <xsl:when test="function-available('java:java.lang.System.currentTimeMillis')">
                        <xsl:value-of select="java:java.lang.System.currentTimeMillis()"/>
                    </xsl:when>
                </xsl:choose>
            </xsl:if>
        </xsl:variable>

        <!-- checks if one cell (table:table-cell) of the rows of this table (allVisibleTableRows) contains a border style (i.e. fo:border-top)
             If only one single border element exist, the whole table will gets pre-defined borders (simple heuristic for better browser display) -->
        <xsl:if test="$allVisibleTableRows/table:table-cell[@table:style-name=/*/*/style:style[style:properties/@fo:border-top]/@style:name]">
            <xsl:attribute name="border">1</xsl:attribute>
            <xsl:attribute name="bordercolor">#000000</xsl:attribute>
            <xsl:attribute name="cellpadding">2</xsl:attribute>
            <xsl:attribute name="cellspacing">0</xsl:attribute>
            <xsl:attribute name="page-break-inside">page-break-inside:avoid</xsl:attribute>
        </xsl:if>


        <!-- check the time for borderchecking (debug)-->
        <xsl:if test="$isDebugMode and not($isJavaDisabled)">
            <xsl:variable name="endTime">
                <xsl:choose>
                    <xsl:when test="function-available('system:current-time-millis')">
                        <xsl:value-of select="system:current-time-millis()"/>
                    </xsl:when>
                    <xsl:when test="function-available('java:java.lang.System.currentTimeMillis')">
                        <xsl:value-of select="java:java.lang.System.currentTimeMillis()"/>
                    </xsl:when>
                </xsl:choose>
            </xsl:variable>
            <xsl:message>Time for checking BorderStyle: <xsl:value-of select="($endTime - $startTime)"/> ms</xsl:message>
        </xsl:if>
    </xsl:template>

</xsl:stylesheet>

--- NEW FILE: table_cells.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA  02111-1307  USA


   Sun Industry Standards Source License Version 1.1
   =================================================
   The contents of this file are subject to the Sun Industry Standards
   Source License Version 1.1 (the "License"); You may not use this file
   except in compliance with the License. You may obtain a copy of the
   License at http://www.openoffice.org/license.html.

   Software provided under this License is provided on an "AS IS" basis,
   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
   See the License for the specific provisions governing your rights and
   obligations concerning the Software.

   The Initial Developer of the Original Code is: Sun Microsystems, Inc.

   Copyright © 2002 by Sun Microsystems, Inc.

   All Rights Reserved.

   Contributor(s): _______________________________________

-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:office="http://openoffice.org/2000/office"
                xmlns:style="http://openoffice.org/2000/style"
                xmlns:text="http://openoffice.org/2000/text"
                xmlns:table="http://openoffice.org/2000/table"
                xmlns:draw="http://openoffice.org/2000/drawing"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:number="http://openoffice.org/2000/datastyle"
                xmlns:svg="http://www.w3.org/2000/svg"
                xmlns:chart="http://openoffice.org/2000/chart"
                xmlns:dr3d="http://openoffice.org/2000/dr3d"
                xmlns:math="http://www.w3.org/1998/Math/MathML"
                xmlns:form="http://openoffice.org/2000/form"
                xmlns:script="http://openoffice.org/2000/script"
                office:class="text"
                office:version="1.0"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:meta="http://openoffice.org/2000/meta"
                xmlns:config="http://openoffice.org/2001/config"
                xmlns:help="http://openoffice.org/2000/help"
                xmlns:xt="http://www.jclark.com/xt"
                xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
                xmlns:xalan="http://xml.apache.org/xalan"
                xmlns:java="http://xml.apache.org/xslt/java"
                exclude-result-prefixes="java">


    <!-- *********************************** -->
    <!-- *** write repeating table cells *** -->
    <!-- *********************************** -->


    <!-- matching cells to give out -> covered table cells are not written out -->
    <xsl:template match="table:table-cell">
        <xsl:param name="collectedGlobalData"/>
        <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
        <xsl:param name="allColumnStyleEntries"/>
        <xsl:param name="maxRowLength"/>

        <xsl:if test="$isDebugMode">
            <xsl:message>
--------------> table:table-cell has been entered with node value: <xsl:value-of select="."/></xsl:message>
            <xsl:message>table:number-columns-repeated: -<xsl:value-of select="@table:number-columns-repeated"/>-</xsl:message>
        </xsl:if>

        <xsl:call-template name="create-column-position-variable">
            <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
            <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
            <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
            <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
        </xsl:call-template>

    </xsl:template>



    <xsl:template name="create-column-position-variable">
        <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
        <xsl:param name="allColumnStyleEntries"/>
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="maxRowLength"/>

        <!-- column position needed for styles, esp. for column-hidden-flag -->
        <xsl:variable name="preceding-columns">
            <xsl:for-each select="preceding-sibling::*">
                <xsl:element name="quantity">
                    <xsl:choose>
                        <xsl:when test="string-length(@table:number-columns-repeated) = 0">1</xsl:when>
                        <xsl:otherwise><xsl:value-of select="@table:number-columns-repeated"/></xsl:otherwise>
                    </xsl:choose>
                </xsl:element>
            </xsl:for-each>
        </xsl:variable>

        <xsl:choose>
            <xsl:when test="function-available('xt:node-set')">
                <xsl:call-template name="create-table-cell">
                    <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
                    <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                    <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                    <xsl:with-param name="column-position"          select="sum(xt:node-set($preceding-columns)/quantity) + 1"/>
                    <xsl:with-param name="collectedGlobalData"      select="$collectedGlobalData"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="function-available('xalan:nodeset')">
                <xsl:call-template name="create-table-cell">
                    <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
                    <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                    <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                    <xsl:with-param name="column-position"          select="sum(xalan:nodeset($preceding-columns)/quantity) + 1"/>
                    <xsl:with-param name="collectedGlobalData"      select="$collectedGlobalData"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:element name="NodeSetFunctionNotAvailable"/>
                <xsl:call-template name="create-table-cell"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



    <xsl:template name="create-table-cell">
        <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
        <xsl:param name="allColumnStyleEntries"/>
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="maxRowLength"/>
        <xsl:param name="column-position"/>


        <xsl:if test="$isDebugMode">
            <xsl:message>NEW VALUE: column-position: -<xsl:value-of select="$column-position"/>-</xsl:message>
        </xsl:if>


        <!-- a hidden column will give out nothing -->
        <xsl:if test="not($allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag)">
            <xsl:choose>
                <!-- when the columns are not repeated the next column-positions raises up to 1, otherwise up to the amount of repeated columns -->
                <xsl:when test="@table:number-columns-repeated">
                    <!-- writes multiple entries of a cell -->
                    <xsl:call-template name="repeat-write-cell">
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                        <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                        <xsl:with-param name="column-position"          select="$column-position"/>
                        <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                        <xsl:with-param name="number-columns-repeated"  select="@table:number-columns-repeated"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <!-- writes an entry of a cell -->
                    <xsl:call-template name="write-cell">
                        <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                        <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                        <xsl:with-param name="column-position"          select="$column-position"/>
                        <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>

    </xsl:template>



    <xsl:template name="repeat-write-cell">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="allColumnStyleEntries"/>
        <xsl:param name="column-position"/>
        <xsl:param name="maxRowLength"/>
        <xsl:param name="number-columns-repeated"/>

        <xsl:choose>
            <!-- 2DO: This is the current workaround against the background simulation by an 'endless' repeating cell -->
            <xsl:when test="$number-columns-repeated > 1 and $maxRowLength > $column-position">

                <xsl:if test="$isDebugMode">
                    <xsl:message>+++++++++ starting cell writing +++++++++</xsl:message>
                    <xsl:message>number-columns-repeated: -<xsl:value-of select="$number-columns-repeated"/>-</xsl:message>
                    <xsl:message>maxRowLength: -<xsl:value-of select="$maxRowLength"/>-</xsl:message>
                    <xsl:message>column-position: -<xsl:value-of select="$column-position"/>-</xsl:message>
                </xsl:if>

                <!-- writes an entry of a cell -->
                <xsl:call-template name="write-cell">
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                    <xsl:with-param name="column-position"          select="$column-position"/>
                    <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                </xsl:call-template>
                <!-- repeat calling this method until all elements written out -->
                <xsl:if test="$isDebugMode">
                    <xsl:message>+++++++++ cell repetition +++++++++</xsl:message>
                </xsl:if>
                <xsl:call-template name="repeat-write-cell">
                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                    <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                    <xsl:with-param name="column-position"          select="$column-position + 1"/>
                    <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                    <xsl:with-param name="number-columns-repeated"  select="$number-columns-repeated - 1"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <!-- 2DO: This is the current workaround against the background simulation by an 'endless' repeating cell -->
                <!--      When the maxRowLength is reached a last entry of a cell is written -->
                <xsl:call-template name="write-cell">
                    <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
                    <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                    <xsl:with-param name="column-position"          select="$column-position"/>
                    <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



    <xsl:template name="write-cell">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="allColumnStyleEntries"/>
        <xsl:param name="column-position"/>
        <xsl:param name="maxRowLength"/>


        <xsl:if test="$isDebugMode">
            <xsl:message>WriteTest -> If nothing between '-' write cell -<xsl:value-of select="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag"/>-</xsl:message>
        </xsl:if>

            <xsl:if test="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag">
                <xsl:if test="$isDebugMode">
                    <xsl:message>TABLE COLUMN is hidden!</xsl:message>
                </xsl:if>
            </xsl:if>

        <xsl:choose>
            <!-- a hidden column will give out nothing -->
            <xsl:when test="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag">
                <xsl:if test="$isDebugMode">
                    <xsl:message>TABLE COLUMN is hidden!</xsl:message>
                </xsl:if>
            </xsl:when>

            <!-- NOT a hidden column -->
            <xsl:otherwise>

                <!-- a table is a table header, when it has a "table:table-header-rows" ancestor -->
                <xsl:variable name="tableDataType">
                    <xsl:choose>
                        <xsl:when test="ancestor::table:table-header-rows">
                            <xsl:text>th</xsl:text>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text>td</xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <xsl:choose>
                    <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
                    <xsl:when test="$outputType = 'CSS_HEADER'">
                        <xsl:element name="{$tableDataType}">

                            <xsl:if test="$isDebugMode">
                                <xsl:message>
*****************************************'<xsl:value-of select="$tableDataType"/>' element has been added!</xsl:message>
                            </xsl:if>

                            <xsl:if test="@table:number-columns-spanned">
                                <xsl:attribute name="colspan">
                                    <xsl:value-of select="@table:number-columns-spanned"/>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:if test="@table:number-rows-spanned">
                                <xsl:attribute name="rowspan">
                                    <xsl:value-of select="@table:number-rows-spanned"/>
                                </xsl:attribute>
                            </xsl:if>



                            <!-- *** the cell-style *** -->
                            <!-- The cell style has no conclusion with the column style, so we switch the order/priorities due to browser issues

                                The cell-style depends on two attributes:

                                1) table:style-name - the style properties of cell. When they exist, a default alignement (cp. below) will be added for the
                                                      case of no alignment in the style exist.

                                2) table:value-type - the value type of the table-cell giving the default alignments.
                                                      By default a string value is left aligned, all other are aligned:right.
                            -->
                            <xsl:choose>
                                <xsl:when test="@table:style-name">
                                    <xsl:attribute name="style">

                                        <!-- CELL-STYLE: alignment by table:value-type (without existing table:style-name)-->
                                        <xsl:variable name="cellStyle" select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
                                        <xsl:choose>
                                            <xsl:when test="string-length($cellStyle) > 0 and not(contains($cellStyle, 'text-align'))">
                                                <!-- CELL-STYLE: alignment by table:value-type -->
                                                <!-- no alignment in the cell style, the alignment based on the table:value-type will be added -->
                                                <xsl:choose>
                                                    <xsl:when test="@table:value-type and not(@table:value-type = 'string')">
                                                        <xsl:value-of select="concat($collectedGlobalData/allstyles/*[name()=current()/@table:style-name], 'text-align:right; ')"/>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:value-of select="concat($collectedGlobalData/allstyles/*[name()=current()/@table:style-name], 'text-align:left; ')"/>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <!-- CELL-STYLE: alignment by table:value-type -->
                                                <!-- no CSS style properties exist, only alignment from the table:value-type will be used -->
                                                <xsl:choose>
                                                    <xsl:when test="@table:value-type and not(@table:value-type = 'string')">text-align:right; </xsl:when>
                                                    <xsl:otherwise>text-align:left; </xsl:otherwise>
                                                </xsl:choose>
                                            </xsl:otherwise>
                                        </xsl:choose>

                                         <!-- column-style (disjunct of cell style -->
                                         <!-- 2DO: only absolut styles are supported, relative styles (i.e. 'style:rel-column-width' e.g. with value "8933*" are ignored.
                                              Issue: browsers (not sure if CSS) does not support the '*' relationship, only the '%', where the sum is always '100'!
                                              For this, it is easier to work on with the absolute values, instead of calculating the values for 100% -->
                                         <xsl:value-of select="$allColumnStyleEntries/column-style-entry[position()=$column-position]"/>
                                    </xsl:attribute>
                                    <!-- CELL-STYLE: table:style-name -->
                                    <xsl:attribute name="class">
                                        <xsl:value-of select="translate(@table:style-name, '. %()/\', '')"/>
                                    </xsl:attribute>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:attribute name="style">
                                        <!-- CELL-STYLE: alignment by table:value-type (without existing table:style-name)-->
                                        <!-- no table:style-name exist, only alignment from the table:value-type will be used -->
                                        <xsl:choose>
                                            <xsl:when test="@table:value-type and not(@table:value-type = 'string')">
                                                text-align:right;
                                            </xsl:when>
                                            <xsl:otherwise>
                                                text-align:left;
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:attribute>
                                </xsl:otherwise>
                            </xsl:choose>

                            <xsl:choose>
                                <!-- In case of no cell content a non-breakable space will be inserted
                                     to make the browser show the table-cell grid -->
                                <xsl:when test="not(child::text()) and not(child::*)">
                                    <xsl:text>  </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <!-- *** the column-style *** -->
                                    <!--  the column style has no conclusion with the cell style, so we switch the order/priorities due to browser issues-->
                                    <xsl:element name="span">
                                        <xsl:attribute name="class">
                                            <xsl:value-of select="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@style-name"/>
                                        </xsl:attribute>
                                        <xsl:apply-templates>
                                            <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                                        </xsl:apply-templates>
                                    </xsl:element>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:element>
                    </xsl:when>

                    <!--+++++ HTML 4.0 INLINED WAY  +++++-->
                    <xsl:when test="$outputType = 'CSS_INLINED'">
                        <xsl:element name="{$tableDataType}">

                            <xsl:if test="@table:number-columns-spanned">
                                <xsl:attribute name="colspan">
                                    <xsl:value-of select="@table:number-columns-spanned"/>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:if test="@table:number-rows-spanned">
                                <xsl:attribute name="rowspan">
                                    <xsl:value-of select="@table:number-rows-spanned"/>
                                </xsl:attribute>
                            </xsl:if>

                            <xsl:attribute name="style">
                                <!-- cell-style -->
                                <xsl:value-of select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
                                <!-- column-style -->
                                <xsl:value-of select="$allColumnStyleEntries/column-style-entry[position()=$column-position]"/>
                                <!-- TABLE:VALUE-TYPE - the value of a table-cell will be aligned left by default only exlicit non-string is aligned:right-->
                                <xsl:choose>
                                    <xsl:when test="@table:value-type and not(@table:value-type = 'string')">
                                        <xsl:text>text-align:right;</xsl:text>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:text>text-align:left;</xsl:text>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:attribute>

                            <!-- &#160 is a non-breakable space, necessary to make to the browser show the table-cell grid -->
                            <xsl:if test="not(child::text()) and not(child::*)">  </xsl:if>
                            <xsl:apply-templates>
                                <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                            </xsl:apply-templates>
                        </xsl:element>
                    </xsl:when>
                    <!--+++++ PALM INLINED WAY  +++++-->
                    <xsl:when test="$outputType = 'PALM'">
                        <xsl:element name="{$tableDataType}">
                            <xsl:if test="@table:number-columns-spanned">
                                <xsl:attribute name="colspan">
                                    <xsl:value-of select="@table:number-columns-spanned"/>
                                </xsl:attribute>
                            </xsl:if>

                            <xsl:if test="@table:number-rows-spanned">
                                <xsl:attribute name="rowspan">
                                    <xsl:value-of select="@table:number-rows-spanned"/>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:apply-templates>
                                <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                            </xsl:apply-templates>
                        </xsl:element>
                    </xsl:when>
                    <!--+++++ WML WAY  +++++-->
                    <xsl:when test="$outputType = 'WML'">
                        <xsl:choose>
                            <xsl:when test="not($allColumnStyleEntries/column-style-entry[last() = $column-position])">
                                <xsl:apply-templates>
                                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                                </xsl:apply-templates>
                                <xsl:text>, </xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:apply-templates>
                                    <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
                                </xsl:apply-templates>
                                <xsl:text>; </xsl:text>
                                <xsl:element name="br"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

--- NEW FILE: table_columns.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA  02111-1307  USA


   Sun Industry Standards Source License Version 1.1
   =================================================
   The contents of this file are subject to the Sun Industry Standards
   Source License Version 1.1 (the "License"); You may not use this file
   except in compliance with the License. You may obtain a copy of the
   License at http://www.openoffice.org/license.html.

   Software provided under this License is provided on an "AS IS" basis,
   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
   See the License for the specific provisions governing your rights and
   obligations concerning the Software.

   The Initial Developer of the Original Code is: Sun Microsystems, Inc.

   Copyright © 2002 by Sun Microsystems, Inc.

   All Rights Reserved.

   Contributor(s): _______________________________________

-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:office="http://openoffice.org/2000/office"
                xmlns:style="http://openoffice.org/2000/style"
                xmlns:text="http://openoffice.org/2000/text"
                xmlns:table="http://openoffice.org/2000/table"
                xmlns:draw="http://openoffice.org/2000/drawing"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:number="http://openoffice.org/2000/datastyle"
                xmlns:svg="http://www.w3.org/2000/svg"
                xmlns:chart="http://openoffice.org/2000/chart"
                xmlns:dr3d="http://openoffice.org/2000/dr3d"
                xmlns:math="http://www.w3.org/1998/Math/MathML"
                xmlns:form="http://openoffice.org/2000/form"
                xmlns:script="http://openoffice.org/2000/script"
                office:class="text"
                office:version="1.0"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:meta="http://openoffice.org/2000/meta"
                xmlns:config="http://openoffice.org/2001/config"
                xmlns:help="http://openoffice.org/2000/help"
                xmlns:xt="http://www.jclark.com/xt"
                xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
                xmlns:xalan="http://xml.apache.org/xalan"
                xmlns:java="http://xml.apache.org/xslt/java"
                exclude-result-prefixes="java">


    <!-- ******************************************** -->
    <!-- *** Create table columns style variable  *** -->
    <!-- ******************************************** -->

    <xsl:template name="adding-column-styles-entries">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="allTableColumns"/>

        <xsl:for-each select="$allTableColumns">

            <xsl:variable name="column-style-entry" select="$collectedGlobalData/allstyles/*[name() = translate(current()/@table:style-name, '. %()/\', '')]"/>
            <xsl:choose>
                <xsl:when test="not(@table:number-columns-repeated)">
                    <!-- writes an entry of a column in the columns-variable -->
                    <xsl:call-template name="adding-column-style-entry">
                        <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
                    </xsl:call-template>
                </xsl:when>
                <!-- No higher repetition of cells greater than 4 for the last and second last column -->
                <!-- a hack for the sample document 'Waehrungsumrechner.sxc having 230 repeated columns in the second last column -->
                <!-- ??? <xsl:when test="(position() = last() or (position() = (last() - 1)) and @table:number-columns-repeated < 5)"> ???-->
                <xsl:when test="position() = last() or position() = (last() - 1)">
                    <xsl:if test="@table:number-columns-repeated < 5">
                        <!-- writes an entry of a column in the columns-variable -->
                        <xsl:call-template name="repeat-adding-column-style-entry">
                            <xsl:with-param name="column-style-entry"       select="$column-style-entry"/>
                            <xsl:with-param name="number-columns-repeated"  select="1"/>
                        </xsl:call-template>
                    </xsl:if>
                </xsl:when>
                <xsl:otherwise>
                    <!-- repeated colums will be written explicit several times in the variable-->
                    <xsl:call-template name="repeat-adding-column-style-entry">
                        <xsl:with-param name="column-style-entry"           select="$column-style-entry"/>
                        <xsl:with-param name="number-columns-repeated"      select="@table:number-columns-repeated"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
     </xsl:template>


    <!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
    <xsl:template name="repeat-adding-column-style-entry">
        <xsl:param name="column-style-entry"/>
        <xsl:param name="number-columns-repeated"/>

        <xsl:choose>
            <xsl:when test="$number-columns-repeated > 1">
                <!-- writes an entry of a column in the columns-variable -->
                <xsl:call-template name="adding-column-style-entry">
                    <xsl:with-param name="column-style-entry"   select="$column-style-entry"/>
                </xsl:call-template>
                <!-- repeat calling this method until all elements written out -->
                <xsl:call-template name="repeat-adding-column-style-entry">
                    <xsl:with-param name="column-style-entry"       select="$column-style-entry"/>
                    <xsl:with-param name="number-columns-repeated"  select="$number-columns-repeated - 1"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <!-- writes an entry of a column in the columns-variable -->
                <xsl:call-template name="adding-column-style-entry">
                    <xsl:with-param name="column-style-entry"   select="$column-style-entry"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- THE COLUMN-STYLE WRITE-PATTERN FOR EACH COLUMN WRITTEN IN A VARIABLE -->
    <xsl:template name="adding-column-style-entry">
        <xsl:param name="column-style-entry"/>

        <xsl:element name="column-style-entry">
            <xsl:choose>
                <xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter'">
                    <xsl:attribute name="column-hidden-flag">true</xsl:attribute>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:variable  name="table:style-name"         select="translate(@table:style-name, '. %()/\', '')"/>
                    <xsl:attribute name="style-name"><xsl:value-of select="$table:style-name"/></xsl:attribute>
                    <xsl:value-of select="$column-style-entry"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:element>
    </xsl:template>



    <!--isDebugMode-START-->
    <!-- giving out the 'allColumnStyle' variable:
        For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out.
        In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
    <xsl:template name="table-debug-allColumnStyleEntries">
        <xsl:param name="allColumnStyleEntries"/>

        <!-- debug output as table summary attribut in html -->
        <xsl:attribute name="summary">
            <xsl:call-template name="table-debug-column-out">
                <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
            </xsl:call-template>
        </xsl:attribute>
        <!-- debug output to console -->
        <xsl:message>
            <xsl:call-template name="table-debug-column-out">
                <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
            </xsl:call-template>
        </xsl:message>
    </xsl:template>


    <xsl:template name="table-debug-column-out">
        <xsl:param name="allColumnStyleEntries"/>
            <xsl:text>
            DebugInformation: For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out.
                              In case of 'column-hidden-flag' attribute the text 'column is hidden' is given out.
            </xsl:text>
                <xsl:for-each select="$allColumnStyleEntries/column-style-entry">
                <xsl:choose>
                <xsl:when test="@column-hidden-flag">
            <xsl:text>  </xsl:text><xsl:value-of select="@style-name"/><xsl:text>column is hidden</xsl:text><xsl:text>
            </xsl:text>
                </xsl:when>
                <xsl:otherwise>
            <xsl:text>  </xsl:text><xsl:value-of select="@style-name"/><xsl:text> = </xsl:text><xsl:value-of select="."/><xsl:text>
            </xsl:text>
                </xsl:otherwise>
                </xsl:choose>
                           </xsl:for-each>
    </xsl:template>
    <!--isDebugMode-END-->

</xsl:stylesheet>

--- NEW FILE: table_rows.xsl ---
<!--

   The Contents of this file are made available subject to the terms of
   either of the following licenses

          - GNU Lesser General Public License Version 2.1
          - Sun Industry Standards Source License Version 1.1

   Sun Microsystems Inc., October, 2000

   GNU Lesser General Public License Version 2.1
   =============================================
   Copyright 2000 by Sun Microsystems, Inc.
   901 San Antonio Road, Palo Alto, CA 94303, USA

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License version 2.1, as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA  02111-1307  USA


   Sun Industry Standards Source License Version 1.1
   =================================================
   The contents of this file are subject to the Sun Industry Standards
   Source License Version 1.1 (the "License"); You may not use this file
   except in compliance with the License. You may obtain a copy of the
   License at http://www.openoffice.org/license.html.

   Software provided under this License is provided on an "AS IS" basis,
   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
   See the License for the specific provisions governing your rights and
   obligations concerning the Software.

   The Initial Developer of the Original Code is: Sun Microsystems, Inc.

   Copyright © 2002 by Sun Microsystems, Inc.

   All Rights Reserved.

   Contributor(s): _______________________________________

-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:office="http://openoffice.org/2000/office"
                xmlns:style="http://openoffice.org/2000/style"
                xmlns:text="http://openoffice.org/2000/text"
                xmlns:table="http://openoffice.org/2000/table"
                xmlns:draw="http://openoffice.org/2000/drawing"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:number="http://openoffice.org/2000/datastyle"
                xmlns:svg="http://www.w3.org/2000/svg"
                xmlns:chart="http://openoffice.org/2000/chart"
                xmlns:dr3d="http://openoffice.org/2000/dr3d"
                xmlns:math="http://www.w3.org/1998/Math/MathML"
                xmlns:form="http://openoffice.org/2000/form"
                xmlns:script="http://openoffice.org/2000/script"
                office:class="text"
                office:version="1.0"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:meta="http://openoffice.org/2000/meta"
                xmlns:config="http://openoffice.org/2001/config"
                xmlns:help="http://openoffice.org/2000/help"
                xmlns:xt="http://www.jclark.com/xt"
                xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
                xmlns:xalan="http://xml.apache.org/xalan"
                xmlns:java="http://xml.apache.org/xslt/java"
                exclude-result-prefixes="java">



    <!-- ********************************************* -->
    <!-- *** write (explicit) repeating table rows *** -->
    <!-- ********************************************* -->

    <xsl:template name="repeat-write-row">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="allColumnStyleEntries"/>
        <xsl:param name="number-rows-repeated" select="1"/>
        <xsl:param name="maxRowLength"/>

        <xsl:choose>
            <!-- write an entry of a row and repeat calling this method until all elements are written out -->
            <xsl:when test="$number-rows-repeated > 1 and (table:table-cell/text() or table:table-cell/*)">
                <xsl:call-template name="write-row">
                    <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
                    <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                    <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                </xsl:call-template>

                <!-- 2DO: take variable from the output of repeated write-row and iterate giving out the variable -->
                <xsl:call-template name="repeat-write-row">
                    <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
                    <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                    <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                    <xsl:with-param name="number-rows-repeated"     select="$number-rows-repeated - 1"/>
                </xsl:call-template>
            </xsl:when>
            <!-- write a single entry of a row -->
            <xsl:otherwise>
                <xsl:call-template name="write-row">
                    <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
                    <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                    <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



    <xsl:template name="write-row">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="allColumnStyleEntries"/>
        <xsl:param name="maxRowLength"/>


        <xsl:element name="tr">
            <!-- writing the style of the row -->
            <xsl:call-template name='add-style-properties'>
                <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
            </xsl:call-template>

            <xsl:if test="$isDebugMode">
                <xsl:message>
*************************'tr' element has been added!</xsl:message>
            </xsl:if>

            <xsl:apply-templates select="table:table-cell">
                <xsl:with-param name="collectedGlobalData"       select="$collectedGlobalData"/>
                <xsl:with-param name="allColumnStyleEntries"    select="$allColumnStyleEntries"/>
                <xsl:with-param name="maxRowLength"             select="$maxRowLength"/>
            </xsl:apply-templates>

        </xsl:element>
    </xsl:template>


    <!-- **************************** -->
    <!-- *** HELPER: table styles *** -->
    <!-- **************************** -->

    <xsl:template name="add-style-properties">
        <xsl:param name="collectedGlobalData"/>
        <xsl:param name="allColumnStyleEntries"/>
        <xsl:param name="node-position"/>

        <xsl:choose>
            <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
            <xsl:when test="$outputType = 'CSS_HEADER'">
                <xsl:attribute name="class">
                    <xsl:value-of select="translate(@table:style-name, '. %()/\', '')"/>
                </xsl:attribute>
            </xsl:when>

            <!--+++++ HTML 4.0 INLINED WAY  +++++-->
            <xsl:when test="$outputType = 'CSS_INLINED'">
                <xsl:attribute name="style">
                    <xsl:value-of select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
                </xsl:attribute>
            </xsl:when>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>





More information about the commits mailing list