home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Bureautique / OpenOffice / Apache_OpenOffice_4.1.1_Win_x86_install_fr.exe / openoffice1.cab / body1.xsl < prev    next >
Extensible Markup Language  |  2014-02-25  |  133KB  |  2,960 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--***********************************************************
  3.  * 
  4.  * Licensed to the Apache Software Foundation (ASF) under one
  5.  * or more contributor license agreements.  See the NOTICE file
  6.  * distributed with this work for additional information
  7.  * regarding copyright ownership.  The ASF licenses this file
  8.  * to you under the Apache License, Version 2.0 (the
  9.  * "License"); you may not use this file except in compliance
  10.  * with the License.  You may obtain a copy of the License at
  11.  * 
  12.  *   http://www.apache.org/licenses/LICENSE-2.0
  13.  * 
  14.  * Unless required by applicable law or agreed to in writing,
  15.  * software distributed under the License is distributed on an
  16.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17.  * KIND, either express or implied.  See the License for the
  18.  * specific language governing permissions and limitations
  19.  * under the License.
  20.  * 
  21.  ***********************************************************-->
  22.  
  23.  
  24. <!--
  25.     For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
  26. -->
  27. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xt="http://www.jclark.com/xt" xmlns:common="http://exslt.org/common" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xforms xlink xsd xsi xt common xalan" xmlns="http://www.w3.org/1999/xhtml">
  28.  
  29.  
  30.     <!--+++++ INCLUDED XSL MODULES +++++-->
  31.  
  32.     <!-- helper collection, to convert measures (e.g. inch to pixel using DPI (dots per inch) parameter)-->
  33.     <xsl:import href="../../common/measure_conversion.xsl"/>
  34.  
  35.     <!-- common office body element handling -->
  36.     <xsl:import href="../common/body.xsl"/>
  37.  
  38.     <!-- common table handling -->
  39.     <xsl:import href="../common/table/table.xsl"/>
  40.  
  41.     <!-- xhtml table handling -->
  42.     <xsl:include href="table.xsl"/>
  43.  
  44.     <!-- Useful in case of 'style:map', conditional formatting, where a style references to another -->
  45.     <xsl:key name="styles" match="/*/office:styles/style:style | /*/office:automatic-styles/style:style" use="@style:name"/>
  46.  
  47.  
  48.     <!-- ************ -->
  49.     <!-- *** body *** -->
  50.     <!-- ************ -->
  51.  
  52.     <xsl:key match="style:style/@style:master-page-name" name="masterPage" use="'count'"/>
  53.     <xsl:key match="style:master-page" name="masterPageElements" use="@style:name"/>
  54.     <xsl:key match="style:page-layout" name="pageLayoutElements" use="@style:name"/>
  55.     <xsl:key name="writingModeStyles" match="/*/office:styles/style:style/style:paragraph-properties/@style:writing-mode | /*/office:automatic-styles/style:style/style:paragraph-properties/@style:writing-mode" use="'test'"/>
  56.     <xsl:template name="create-body">
  57.         <xsl:param name="globalData"/>
  58.         <xsl:call-template name="create-body.collect-page-properties">
  59.             <xsl:with-param name="globalData" select="$globalData"/>
  60.         </xsl:call-template>
  61.     </xsl:template>
  62.  
  63.     <xsl:template name="create-body.collect-page-properties">
  64.         <xsl:param name="globalData"/>
  65.  
  66.         <!-- approximation to find the correct master page style (with page dimensions) -->
  67.         <xsl:variable name="masterPageNames">
  68.             <!-- Loop over every style:style containing a @style:master-page-name attribute -->
  69.             <xsl:for-each select="key('masterPage','count')">
  70.                 <!-- Check if this style is being used in the body -->
  71.                 <xsl:if test="key('elementUsingStyle', ../@style:name)">
  72.                     <!-- Check every master-page-name if it is not emtpy and return as ';' separated list  -->
  73.                     <xsl:if test="string-length(../@style:master-page-name) > 0">
  74.                         <xsl:value-of select="../@style:master-page-name"/>;
  75.                     </xsl:if>
  76.                 </xsl:if>
  77.             </xsl:for-each>
  78.         </xsl:variable>
  79.  
  80.         <!-- Take the first of the masterpage list and get the according style:master-page element and find the @style:page-layout-name  -->
  81.         <xsl:variable name="pageLayoutName" select="key('masterPageElements', substring-before($masterPageNames,';'))/@style:page-layout-name"/>
  82.         <xsl:variable name="pagePropertiesRTF">
  83.             <xsl:choose>
  84.                 <xsl:when test="not($pageLayoutName) or $pageLayoutName = ''">
  85.                     <xsl:copy-of select="$globalData/styles-file/*/office:automatic-styles/style:page-layout[1]/style:page-layout-properties"/>
  86.                 </xsl:when>
  87.                 <xsl:otherwise>
  88.                     <!-- Find the according style:page-layout and store the properties in a variable  -->
  89.                     <xsl:copy-of select="key('pageLayoutElements', $pageLayoutName)/style:page-layout-properties"/>
  90.                 </xsl:otherwise>
  91.             </xsl:choose>
  92.         </xsl:variable>
  93.  
  94.         <xsl:choose>
  95.             <xsl:when test="function-available('common:node-set')">
  96.                 <xsl:call-template name="create-body.create">
  97.                     <xsl:with-param name="globalData" select="common:node-set($globalData)"/>
  98.                     <xsl:with-param name="pageProperties" select="common:node-set($pagePropertiesRTF)"/>
  99.                 </xsl:call-template>
  100.             </xsl:when>
  101.             <xsl:when test="function-available('xalan:nodeset')">
  102.                 <xsl:call-template name="create-body.create">
  103.                     <xsl:with-param name="globalData" select="xalan:nodeset($globalData)"/>
  104.                     <xsl:with-param name="pageProperties" select="xalan:nodeset($pagePropertiesRTF)"/>
  105.                 </xsl:call-template>
  106.             </xsl:when>
  107.             <xsl:when test="function-available('xt:node-set')">
  108.                 <xsl:call-template name="create-body.create">
  109.                     <xsl:with-param name="globalData" select="xt:node-set($globalData)"/>
  110.                     <xsl:with-param name="pageProperties" select="xt:node-set($pagePropertiesRTF)"/>
  111.                 </xsl:call-template>
  112.             </xsl:when>
  113.             <xsl:otherwise>
  114.                 <xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
  115.             </xsl:otherwise>
  116.         </xsl:choose>
  117.     </xsl:template>
  118.  
  119.     <xsl:template name="create-body.create">
  120.         <xsl:param name="globalData"/>
  121.         <xsl:param name="pageProperties"/>
  122.  
  123.         <xsl:element name="body">
  124.             <!-- direction of text flow -->
  125.             <xsl:variable name="writingMode" select="$pageProperties/style:page-layout-properties/@style:writing-mode"/>
  126.             <xsl:choose>
  127.                 <xsl:when test="$writingMode">
  128.                     <xsl:choose>
  129.                         <xsl:when test="contains($writingMode, 'lr')">
  130.                             <xsl:attribute name="dir">ltr</xsl:attribute>
  131.                         </xsl:when>
  132.                         <xsl:when test="contains($writingMode, 'rl')">
  133.                             <xsl:attribute name="dir">rtl</xsl:attribute>
  134.                         </xsl:when>
  135.                     </xsl:choose>
  136.                 </xsl:when>
  137.                 <xsl:otherwise>
  138.                     <!-- As CSS writing-mode is not implemented by all browsers, a heuristic is done -->
  139.                     <xsl:variable name="writingModeTest" select="key('writingModeStyles', 'test')"/>
  140.                     <xsl:if test="contains($writingModeTest, 'rl')">
  141.                         <xsl:attribute name="dir">rtl</xsl:attribute>
  142.                     </xsl:if>
  143.                 </xsl:otherwise>
  144.             </xsl:choose>
  145.             <!-- adapt page size -->
  146.             <xsl:variable name="pageWidth" select="$pageProperties/style:page-layout-properties/@fo:page-width"/>
  147.  
  148.             <!-- multiple backgroundimages for different page styles (never used in html) -->
  149.             <xsl:variable name="backgroundImage" select="$pageProperties/style:page-layout-properties/style:background-image"/>
  150.             <!-- page margins & background image  -->
  151.             <xsl:if test="$pageWidth or $pageProperties/style:page-layout-properties/@fo:* or $backgroundImage/@xlink:href">
  152.                 <xsl:attribute name="style">
  153.                     <xsl:if test="$pageWidth">
  154.                         <xsl:text>max-width:</xsl:text>
  155.                         <xsl:value-of select="$pageWidth"/>
  156.                         <xsl:text>;</xsl:text>
  157.                     </xsl:if>
  158.                     <xsl:if test="$pageProperties/style:page-layout-properties/@fo:* or $backgroundImage/@xlink:href">
  159.                         <xsl:apply-templates select="$pageProperties/style:page-layout-properties/@fo:*"/>
  160.                         <xsl:if test="$backgroundImage/@xlink:href">
  161.                             <xsl:text>background-image:url(</xsl:text>
  162.                             <xsl:call-template name="create-href">
  163.                                 <xsl:with-param name="href" select="$backgroundImage/@xlink:href"/>
  164.                             </xsl:call-template>
  165.                             <xsl:text>);</xsl:text>
  166.  
  167.                             <xsl:if test="$backgroundImage/@style:repeat">
  168.                                 <xsl:choose>
  169.                                     <xsl:when test="$backgroundImage/@style:repeat = 'no-repeat'">
  170.                                         <xsl:text>background-repeat:no-repeat;</xsl:text>
  171.                                     </xsl:when>
  172.                                     <xsl:otherwise>
  173.                                         <xsl:text>background-repeat:repeat;</xsl:text>
  174.                                     </xsl:otherwise>
  175.                                 </xsl:choose>
  176.                             </xsl:if>
  177.                             <xsl:if test="$backgroundImage/@style:position">
  178.                                 <xsl:text>background-position:</xsl:text>
  179.                                 <xsl:value-of select="$backgroundImage/@style:position"/>
  180.                                 <xsl:text>;</xsl:text>
  181.                             </xsl:if>
  182.                         </xsl:if>
  183.                     </xsl:if>
  184.                 </xsl:attribute>
  185.             </xsl:if>
  186.             <!-- processing the content of the OpenDocument content file -->
  187.             <xsl:apply-templates select="/*/office:body/*">
  188.                 <xsl:with-param name="globalData" select="$globalData"/>
  189.             </xsl:apply-templates>
  190.  
  191.         </xsl:element>
  192.     </xsl:template>
  193.  
  194.     <!-- processing the content of the OpenDocument content file -->
  195.     <xsl:template match="office:body/*">
  196.         <xsl:param name="globalData"/>
  197.  
  198.         <!-- not using of 'apply-styles-and-content' as the content table information migth have been added to 'globalData' variable -->
  199.         <xsl:apply-templates select="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name -->
  200.             <xsl:with-param name="globalData" select="$globalData"/>
  201.         </xsl:apply-templates>
  202.  
  203.         <xsl:apply-templates>
  204.             <xsl:with-param name="globalData" select="$globalData"/>
  205.         </xsl:apply-templates>
  206.  
  207.         <!-- writing the footer- and endnotes beyond the body -->
  208.         <xsl:call-template name="write-text-nodes">
  209.             <xsl:with-param name="globalData" select="$globalData"/>
  210.         </xsl:call-template>
  211.     </xsl:template>
  212.  
  213.     <!-- ******************************* -->
  214.     <!-- *** User Field Declarations *** -->
  215.     <!-- ******************************* -->
  216.  
  217.     <xsl:template match="text:user-field-get | text:user-field-input">
  218.         <xsl:param name="globalData"/>
  219.  
  220.         <xsl:value-of select="."/>
  221.     </xsl:template>
  222.  
  223.     <xsl:template match="text:conditional-text">
  224.         <xsl:param name="globalData"/>
  225.  
  226.         <xsl:value-of select="."/>
  227.     </xsl:template>
  228.  
  229.     <!-- ODF text fields -->
  230.     <xsl:template match="text:author-initials | text:author-name | text:chapter | text:character-count | text:creation-date | text:creation-time | text:creator | text:date | text:description | text:editing-cycles | text:editing-duration | text:file-name | text:image-count | text:initial-creator | text:keywords | text:modification-date | text:modification-time | text:object-count | text:page-continuation | text:page-count | text:page-number | text:paragraph-count | text:print-date | text:print-time | text:printed-by | text:sender-city | text:sender-company | text:sender-country | text:sender-email | text:sender-fax | text:sender-firstname | text:sender-initials | text:sender-lastname | text:sender-phone-private | text:sender-phone-work | text:sender-position | text:sender-postal-code | text:sender-state-or-province | text:sender-street | text:sender-title | text:sheet-name | text:subject | text:table-count | text:time | text:title | text:user-defined | text:word-count">
  231.         <xsl:param name="globalData"/>
  232.  
  233.         <xsl:element name="span">
  234.             <xsl:attribute name="title">
  235.                 <xsl:value-of select="local-name()"/>
  236.             </xsl:attribute>
  237.             <xsl:apply-templates>
  238.                 <xsl:with-param name="globalData" select="$globalData"/>
  239.             </xsl:apply-templates>
  240.         </xsl:element>
  241.     </xsl:template>
  242.  
  243.  
  244.  
  245.     <!-- *************** -->
  246.     <!-- *** Textbox *** -->
  247.     <!-- *************** -->
  248.  
  249.     <xsl:template match="draw:text-box">
  250.         <xsl:param name="globalData"/>
  251.  
  252.         <xsl:comment>Next 'div' was a 'draw:text-box'.</xsl:comment>
  253.         <xsl:element name="div">
  254.             <xsl:variable name="dimension">
  255.                 <xsl:apply-templates select="@fo:min-width"/>
  256.                 <xsl:apply-templates select="@fo:max-width"/>
  257.                 <xsl:apply-templates select="@fo:min-height"/>
  258.                 <xsl:apply-templates select="@fo:max-height"/>
  259.             </xsl:variable>
  260.             <xsl:if test="$dimension">
  261.                 <xsl:attribute name="style">
  262.                     <xsl:value-of select="$dimension"/>
  263.                 </xsl:attribute>
  264.             </xsl:if>
  265.             <xsl:apply-templates select="@draw:name">
  266.                 <xsl:with-param name="globalData" select="$globalData"/>
  267.             </xsl:apply-templates>
  268.  
  269.             <xsl:apply-templates select="node()">
  270.                 <xsl:with-param name="globalData" select="$globalData"/>
  271.             </xsl:apply-templates>
  272.         </xsl:element>
  273.     </xsl:template>
  274.  
  275.     <xsl:template match="@fo:min-width">
  276.         <xsl:text>min-width:</xsl:text>
  277.         <xsl:value-of select="."/>
  278.         <xsl:text>;</xsl:text>
  279.     </xsl:template>
  280.     <xsl:template match="@fo:max-width">
  281.         <xsl:text>max-width:</xsl:text>
  282.         <xsl:value-of select="."/>
  283.         <xsl:text>;</xsl:text>
  284.     </xsl:template>
  285.     <xsl:template match="@fo:min-height">
  286.         <xsl:text>min-height:</xsl:text>
  287.         <xsl:value-of select="."/>
  288.         <xsl:text>;</xsl:text>
  289.     </xsl:template>
  290.     <xsl:template match="@fo:max-height">
  291.         <xsl:text>max-height:</xsl:text>
  292.         <xsl:value-of select="."/>
  293.         <xsl:text>;</xsl:text>
  294.     </xsl:template>
  295.  
  296.  
  297.     <!-- inline style helper for the 'div' boxes -->
  298.     <xsl:template name="svg:height">
  299.         <xsl:text>height:</xsl:text>
  300.         <xsl:choose>
  301.             <!-- changing the distance measure: inch to in -->
  302.             <xsl:when test="contains(@svg:height, 'inch')">
  303.                 <xsl:value-of select="substring-before(@svg:height, 'ch')"/>
  304.             </xsl:when>
  305.             <xsl:otherwise>
  306.                 <xsl:value-of select="@svg:height"/>
  307.             </xsl:otherwise>
  308.         </xsl:choose>
  309.         <xsl:text>;</xsl:text>
  310.     </xsl:template>
  311.  
  312.     <!-- inline style helper for the 'div' boxes -->
  313.     <xsl:template name="svg:width">
  314.         <xsl:text>width:</xsl:text>
  315.         <xsl:choose>
  316.             <!-- changing the distance measure: inch to in -->
  317.             <xsl:when test="contains(@svg:width, 'inch')">
  318.                 <xsl:value-of select="substring-before(@svg:width, 'ch')"/>
  319.             </xsl:when>
  320.             <xsl:otherwise>
  321.                 <xsl:value-of select="@svg:width"/>
  322.             </xsl:otherwise>
  323.         </xsl:choose>
  324.         <xsl:text>;</xsl:text>
  325.     </xsl:template>
  326.  
  327.  
  328.  
  329.     <!-- ****************** -->
  330.     <!-- *** Paragraphs *** -->
  331.     <!-- ****************** -->
  332.  
  333.     <xsl:template match="text:p | draw:page">
  334.         <xsl:param name="globalData"/>
  335.         <!-- The footnote symbol is the prefix for a footnote in the footer -->
  336.         <xsl:param name="footnotePrefix"/>
  337.         <!-- 1) In ODF sometimes the followig children are nested
  338.                 <text:p>
  339.                     <draw:frame>
  340.                         <draw:text-box>
  341.                             <text:p>
  342.                 Which results in a paragraphs (the last text:p) having a paragraph as its anchestor.
  343.                 In HTML a 'p' can only have inline documents (no other 'p' as children'),
  344.                 a 'div' will be given for the ancestors instead.
  345.              2) ODF images are embedded in a paragraph, but CSS is not able to express a horizontal alignment for an HTML image (text:align is only valid for block elements).
  346.                 A surrounding 'div' element taking over the image style solves that problem, but the div is invalid as child of a paragraph
  347.                 Therefore the paragraph has to be exchanged with a HTML div element
  348.         -->
  349.         <!-- 2DO page alignment fix - PART1 -->
  350.         <xsl:variable name="childText"><xsl:apply-templates mode="getAllTextChildren"/></xsl:variable>
  351.         <xsl:choose>
  352.             <xsl:when test="name() = 'text:p' and not(*) and (normalize-space($childText) = '')">
  353.                 <!-- WorkAround: Test if the empty paragraph was added after an image, which OOO often does -->
  354.                 <xsl:variable name="isFollowingImage">
  355.                     <xsl:call-template name="follows-empty-paragraphs-and-image">
  356.                         <xsl:with-param name="precedingElement" select="preceding-sibling::node()[1]"/>
  357.                     </xsl:call-template>
  358.                 </xsl:variable>
  359.                 <xsl:if test="$isFollowingImage = 'no'">
  360.                     <xsl:call-template name="create-paragraph">
  361.                         <xsl:with-param name="globalData" select="$globalData" />
  362.                         <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
  363.                     </xsl:call-template>
  364.                 </xsl:if>
  365.  
  366.             </xsl:when>
  367.             <xsl:when test="draw:frame and ((normalize-space($childText) != '')  or (((count(*) - count(text:soft-page-break)) > 1)))">
  368.                 <!-- If there is a 'draw:frame' child with text (not being whitespace alone) and more than the draw:frame alone and
  369.                     not the draw:frame and a soft-page-break alone (which is quite often) -->
  370.  
  371.                 <!-- If there is a frame within the text:p or draw:page, its siblings are surrounded as well by a div and are floating (CSS float) -->
  372.                 <!-- But it makes no sense to create floating if the frame is alone or only together with a soft-page-break not usable for HTML -->
  373.                 <!-- The paragraph is written as DIV as there might be nested paragraphs (see above choose block) -->
  374.                 <xsl:choose>
  375.                     <xsl:when test="name() = 'text:p'">
  376.                         <xsl:comment>Next 'div' was a 'text:p'.</xsl:comment>
  377.                     </xsl:when>
  378.                     <xsl:otherwise>
  379.                         <xsl:comment>Next 'div' was a 'draw:page'.</xsl:comment>
  380.                     </xsl:otherwise>
  381.                 </xsl:choose>
  382.                 <xsl:element name="div">
  383.                     <xsl:apply-templates select="@*">
  384.                         <xsl:with-param name="globalData" select="$globalData"/>
  385.                     </xsl:apply-templates>
  386.                     <!-- the footnote symbol is the prefix for a footnote in the footer -->
  387.                     <xsl:copy-of select="$footnotePrefix"/>
  388.                     <!-- start floating of frame (and siblings) -->
  389.                     <xsl:apply-templates select="node()[1]" mode="frameFloating">
  390.                         <xsl:with-param name="globalData" select="$globalData" />
  391.                         <xsl:with-param name="previousFrameWidths" select="0"/>
  392.                         <xsl:with-param name="previousFrameHeights" select="0"/>
  393.                         <!-- 2DO for me (Svante) - Not used, uncertain 4now..
  394.                         <xsl:with-param name="pageMarginLeft">
  395.                             <xsl:call-template name="getPageMarginLeft"/>
  396.                          </xsl:with-param>-->
  397.                     </xsl:apply-templates>
  398.                 </xsl:element>
  399.                 <!-- after the last draw:frame sibling the CSS float is disabled
  400.                       is an unbreakable whitespace to give conent to the element and force a browser not to ignore the element -->
  401.                 <div style="clear:both; line-height:0; width:0; height:0; margin:0; padding:0;"> </div>
  402.             </xsl:when>
  403.             <xsl:when test="text:tab and not(ancestor::text:index-body)">
  404.                 <!-- If there is a tabulator (ie. text:tab) within a paragraph, a heuristic for ODF tabulators creates a
  405.                     span for every text:tab embracing the following text nodes aligning them according to the tabulator.
  406.                     A line break or another text:tab starts a new text:span, line break even the tab counter for the line.
  407.                 -->
  408.                 <xsl:element name="p">
  409.                     <xsl:apply-templates select="@*">
  410.                         <xsl:with-param name="globalData" select="$globalData" />
  411.                     </xsl:apply-templates>
  412.                     <!-- start with first child of the paragraph -->
  413.                     <xsl:variable name="firstChildNode" select="node()[1]" />
  414.                     <xsl:apply-templates select="$firstChildNode" mode="tabHandling">
  415.                         <xsl:with-param name="globalData" select="$globalData" />
  416.                         <xsl:with-param name="tabStops" select="$globalData/all-doc-styles/style[@style:name = current()/@text:style-name]/*/style:tab-stops"/>
  417.                         <xsl:with-param name="parentMarginLeft">
  418.                             <!-- Styles of first paragraph in list item, including ancestor styles (inheritance) -->
  419.                             <xsl:variable name="paragraphName" select="@text:style-name" />
  420.                             <xsl:variable name="imageParagraphStyle" select="$globalData/all-styles/style[@style:name = $paragraphName]/final-properties"/>
  421.                             <!-- Only the left margin of the first paragraph of a list item will be added to the margin of the complete list (all levels)-->
  422. <!-- 2DO: left-margin in order with bidirectional -->
  423.                             <xsl:choose>
  424.                                 <xsl:when test="contains($imageParagraphStyle, 'margin-left:')">
  425.                                     <xsl:call-template name="convert2cm">
  426.                                         <xsl:with-param name="value" select="normalize-space(substring-before(substring-after($imageParagraphStyle, 'margin-left:'), ';'))"/>
  427.                                     </xsl:call-template>
  428.                                 </xsl:when>
  429.                                 <xsl:otherwise>0</xsl:otherwise>
  430.                             </xsl:choose>
  431.                         </xsl:with-param>
  432.                         <xsl:with-param name="pageMarginLeft">
  433.                             <xsl:call-template name="getPageMarginLeft"/>
  434.                         </xsl:with-param>
  435.                     </xsl:apply-templates>
  436.                 </xsl:element>
  437.             </xsl:when>
  438.             <xsl:otherwise>
  439.                 <xsl:choose>
  440.                     <!-- !!Check if paragraph is empty!!
  441.                         OOo writes out empty paragraphs layouted behind an image (= draw:image within draw:frame)
  442.                         those have to be neglected in HTML -->
  443.                     <xsl:when test="name() = 'text:p' and not($childText) and not(*)">
  444.                         <xsl:variable name="isFollowingImage">
  445.                             <xsl:call-template name="follows-empty-paragraphs-and-image">
  446.                                 <xsl:with-param name="precedingElement" select="preceding-sibling::node()[1]"/>
  447.                             </xsl:call-template>
  448.                         </xsl:variable>
  449.                         <xsl:if test="$isFollowingImage = 'no'">
  450.                             <xsl:call-template name="create-paragraph">
  451.                                 <xsl:with-param name="globalData" select="$globalData" />
  452.                                 <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
  453.                             </xsl:call-template>
  454.                         </xsl:if>
  455.                     </xsl:when>
  456.                     <xsl:otherwise>
  457.                         <xsl:call-template name="create-paragraph">
  458.                             <xsl:with-param name="globalData" select="$globalData" />
  459.                             <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
  460.                         </xsl:call-template>
  461.                     </xsl:otherwise>
  462.                 </xsl:choose>
  463.             </xsl:otherwise>
  464.         </xsl:choose>
  465.     </xsl:template>
  466.  
  467.     <!-- Return the text  -->
  468.     <xsl:template match="text()" mode="getAllTextChildren">
  469.         <xsl:value-of select="."/>
  470.     </xsl:template>
  471.  
  472.     <!-- A span will be created for every text:tab embracing the following text nodes.
  473.         A line break or another text:tab starts a new text:span -->
  474.     <xsl:template match="* | text()" mode="tabHandling">
  475.         <xsl:param name="globalData"/>
  476.         <xsl:param name="tabStops"/>
  477.         <!-- there can be multiple tabs in one line, tabNo guesses the one to apply. By default the first i.e. "1" -->
  478.         <xsl:param name="tabCount" select="0"/>
  479.         <xsl:param name="parentMarginLeft" />
  480.         <xsl:param name="pageMarginLeft" />
  481.  
  482. <!-- 2DO: EXCHANGE FOLLOING SIBLING BY VARIABLE -->
  483.         <xsl:variable name="followingSiblingNode" select="following-sibling::node()[1]"/>
  484.  
  485.  
  486.         <!--
  487.             Every tabulator indents its following content, encapuslated in a span
  488.             element.
  489.  
  490.             This template have two modes:
  491.  
  492.             1) Before the first tabulator it will match as usually paragraph content
  493.             to HTML.
  494.             2) After the first paragraph it will always triggers two recursions.
  495.             One embraces the following content of a paragraph element into a span.
  496.             (tabContentHandling)
  497.             The other calls this template and will now ignore anything else than
  498.             TAB and LINE-BREAK.
  499.  
  500.  
  501.             The tabulators and linebreaks are being iterated, one by one to keep track of the tab number
  502.         -->
  503.  
  504.  
  505.         <xsl:choose>
  506.             <xsl:when test="name() = 'text:tab'">
  507.                 <!-- every frame sibling have to be incapuslated within a div with left indent  -->
  508.                 <xsl:element name="span">
  509.                     <xsl:choose>
  510.                         <xsl:when test="count($tabStops/style:tab-stop) > 0 and count($tabStops/style:tab-stop) < 3">
  511.                             <!-- only allow the heuristic when the style has less than 3 TABS -->
  512.                             <!-- ignore heuristics if no TABS are defined -->
  513.                             <xsl:attribute name="style">
  514.                                 <xsl:call-template name="createTabIndent">
  515.                                     <xsl:with-param name="globalData" select="$globalData"/>
  516.                                     <xsl:with-param name="tabStops" select="$tabStops"/>
  517.                                     <xsl:with-param name="tabCount" select="$tabCount + 1"/>
  518.                                     <xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
  519.                                     <xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
  520.                                 </xsl:call-template>
  521.                             </xsl:attribute>
  522.                         </xsl:when>
  523.                         <xsl:otherwise>
  524.                             <!-- if there are more than 3 TABS in the style, create a none-breakable-space as whitespace -->
  525.                             <xsl:text> </xsl:text>
  526.                         </xsl:otherwise>
  527.                     </xsl:choose>
  528.                     <xsl:apply-templates select="following-sibling::node()[1]" mode="tabContentHandling">
  529.                         <xsl:with-param name="globalData" select="$globalData"/>
  530.                     </xsl:apply-templates>
  531.                 </xsl:element>
  532.                 <xsl:apply-templates select="following-sibling::node()[1]" mode="tabHandling">
  533.                     <xsl:with-param name="globalData" select="$globalData"/>
  534.                     <xsl:with-param name="tabStops" select="$tabStops"/>
  535.                     <xsl:with-param name="tabCount" select="$tabCount + 1"/>
  536.                     <xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
  537.                     <xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
  538.                 </xsl:apply-templates>
  539.             </xsl:when>
  540.             <xsl:when test="name() = 'text:line-break'">
  541.                 <!-- A line-break resets the tabCount to '0' -->
  542.                 <br/>
  543.                 <xsl:apply-templates select="following-sibling::node()[1]" mode="tabHandling">
  544.                     <xsl:with-param name="globalData" select="$globalData"/>
  545.                     <xsl:with-param name="tabStops" select="$tabStops"/>
  546.                     <xsl:with-param name="tabCount" select="0"/>
  547.                     <xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
  548.                     <xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
  549.                 </xsl:apply-templates>
  550.             </xsl:when>
  551.             <xsl:otherwise>
  552.                 <!-- only before the first tab all content is written out -->
  553.                 <xsl:if test="$tabCount = 0">
  554.                     <xsl:apply-templates select=".">
  555.                         <xsl:with-param name="globalData" select="$globalData"/>
  556.                     </xsl:apply-templates>
  557.                 </xsl:if>
  558.                 <xsl:apply-templates select="following-sibling::node()[1]" mode="tabHandling">
  559.                     <xsl:with-param name="globalData" select="$globalData"/>
  560.                     <xsl:with-param name="tabStops" select="$tabStops"/>
  561.                     <xsl:with-param name="tabCount" select="$tabCount"/>
  562.                     <xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
  563.                     <xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
  564.                 </xsl:apply-templates>
  565.             </xsl:otherwise>
  566.         </xsl:choose>
  567.     </xsl:template>
  568.  
  569.     <!--
  570.         This recursion creates the content of a tab (i.e. following siblings
  571.         till next TAB or LINE BREAK) and ends with the next
  572.         TAB, LINE-BREAK or with the end of the paragraph.
  573.      -->
  574.     <xsl:template match="* | text()" mode="tabContentHandling">
  575.         <xsl:param name="globalData"/>
  576.  
  577.         <xsl:if test="(name() != 'text:tab') and (name() != 'text:line-break')">
  578.             <!-- Write out content -->
  579.             <xsl:apply-templates select=".">
  580.                 <xsl:with-param name="globalData" select="$globalData"/>
  581.             </xsl:apply-templates>
  582.             <!-- Apply for the next node -->
  583.             <xsl:apply-templates select="following-sibling::node()[1]" mode="tabContentHandling">
  584.                 <xsl:with-param name="globalData" select="$globalData"/>
  585.             </xsl:apply-templates>
  586.         </xsl:if>
  587.     </xsl:template>
  588.  
  589.     <xsl:template name="createTabIndent">
  590.         <xsl:param name="globalData"/>
  591.         <xsl:param name="tabStops"/>
  592.         <xsl:param name="tabCount"/>
  593.         <xsl:param name="parentMarginLeft" />
  594.         <xsl:param name="pageMarginLeft" />
  595.  
  596.         <xsl:text>position:absolute;left:</xsl:text>
  597.         <xsl:variable name="tabPosition">
  598.             <xsl:call-template name="convert2cm">
  599.                 <xsl:with-param name="value" select="$tabStops/style:tab-stop[$tabCount]/@style:position"/>
  600.             </xsl:call-template>
  601.         </xsl:variable>
  602.         <xsl:variable name="tabIndent">
  603.             <xsl:choose>
  604.                 <xsl:when test="$tabStops/style:tab-stop[$tabCount]/@style:type = 'center'">
  605.                     <!-- in case of style:type 'center' the text is even before the tab stop,
  606.                       centered around the beginning. As I see currently no way in mapping this,
  607.                       therefore I do some HEURISTIC (minus -2.5cm) -->
  608.                     <xsl:value-of select="$tabPosition + $parentMarginLeft + $pageMarginLeft - 2.5"/>
  609.                 </xsl:when>
  610.                 <xsl:otherwise>
  611.                     <xsl:value-of select="$tabPosition + $parentMarginLeft + $pageMarginLeft"/>
  612.                 </xsl:otherwise>
  613.             </xsl:choose>
  614.         </xsl:variable>
  615.         <!--<xsl:message>TAB: tabCount=
  616.             <xsl:value-of select="$tabCount"/>, tabPosition=
  617.             <xsl:value-of select="$tabPosition"/>, tabIndent=
  618.             <xsl:value-of select="$tabIndent"/>
  619.         </xsl:message>-->
  620.         <xsl:choose>
  621.             <xsl:when test="$tabIndent='NaN'">
  622.                 <xsl:variable name="tabPositionTmp">
  623.                     <xsl:call-template name="convert2cm">
  624.                         <xsl:with-param name="value" select="$tabStops/style:tab-stop[last()]/@style:position"/>
  625.                     </xsl:call-template>
  626.                 </xsl:variable>
  627.                     <!-- Heuristic: for every tab that is more than specified give a further 1 cm -->
  628.                 <xsl:value-of select="$parentMarginLeft + $tabPositionTmp + count($tabStops/style:tab-stop) - $tabCount"/>
  629.             </xsl:when>
  630.             <xsl:otherwise>
  631.                 <xsl:value-of select="$tabIndent"/>
  632.             </xsl:otherwise>
  633.         </xsl:choose>
  634.         <xsl:text>cm;</xsl:text>
  635.         <xsl:apply-templates select="$tabStops/style:tab-stop[$tabCount]/@style:type"/>
  636.     </xsl:template>
  637.  
  638.     <!-- OOo writes out empty paragraphs layouted behind an image,
  639.         those have to be neglected in HTML
  640.     This method checks if an empty paragraph is of that kind! -->
  641.     <xsl:template name="follows-empty-paragraphs-and-image">
  642.         <xsl:param name="precedingElement" />
  643.         <xsl:param name="elementToCheck" select="1"/>
  644.         <xsl:choose>
  645.             <!-- OOo writes out empty paragraphs layouted behind the image,
  646.                 those have to be neglected in HTML
  647.             <xsl:when test="name() = 'text:p' and (normalize-space($childText) = '')">                         -->
  648.                 <!-- WorkAround: Test if the empty paragraph was added after an image, which OOO often does -->
  649.             <xsl:when test="(name($precedingElement) = 'text:p' and not($precedingElement/text()) and not($precedingElement/*))">
  650.                 <xsl:call-template name="follows-empty-paragraphs-and-image">
  651.                     <xsl:with-param name="precedingElement" select="preceding-sibling::*[$elementToCheck]"/>
  652.                     <xsl:with-param name="elementToCheck" select="$elementToCheck +1"/>
  653.                 </xsl:call-template>
  654.             </xsl:when>
  655.             <xsl:when test="$precedingElement/draw:frame">yes</xsl:when>
  656.             <xsl:otherwise>no</xsl:otherwise>
  657.         </xsl:choose>
  658.     </xsl:template>
  659.  
  660.     <xsl:template name="create-paragraph">
  661.         <xsl:param name="globalData"/>
  662.         <!-- the footnote symbol is the prefix for a footnote in the footer -->
  663.         <xsl:param name="footnotePrefix"/>
  664.  
  665.         <!-- xhtml:p may only contain inline elements.
  666.              If there is one frame beyond, div must be used! -->
  667.         <xsl:variable name="elementName">
  668.             <xsl:choose>
  669.                 <xsl:when test="descendant::draw:frame[1] or descendant::text:p[1]">div</xsl:when>
  670.                 <xsl:otherwise>p</xsl:otherwise>
  671.             </xsl:choose>
  672.         </xsl:variable>
  673.  
  674.         <xsl:element name="{$elementName}">
  675.             <xsl:choose>
  676.                 <!-- in ODF borders of paragraphs will be merged by default. Merging means the adjactend paragraphs are building a unit,
  677.                     where only the first and the last will have have a border to the surrounding (top / bottom border)
  678.                                                 <xsl:variable name="precedingParagraphStyle" select="preceding-sibling::*[1][name() = 'text:p']/@text:style-name"/>
  679.                     <xsl:variable name="followingParagraphStyle" select="following-sibling::*[1][name() = 'text:p']/@text:style-name"/>
  680.                     -->
  681.                 <xsl:when test="$globalData/all-styles/style[@style:name = current()/@text:style-name]/@mergedBorders">
  682.                     <xsl:variable name="precedingParagraphStyle" select="preceding-sibling::*[1][name() = 'text:p']/@text:style-name"/>
  683.                     <xsl:variable name="followingParagraphStyle" select="following-sibling::*[1][name() = 'text:p']/@text:style-name"/>
  684.                     <xsl:choose>
  685.                         <xsl:when test="$precedingParagraphStyle or $followingParagraphStyle">
  686.                             <xsl:variable name="isPrecedingBorderParagraph" select="$globalData/all-styles/style[@style:name = $precedingParagraphStyle]/@mergedBorders"/>
  687.                             <xsl:variable name="isFollowingBorderParagraph" select="$globalData/all-styles/style[@style:name = $followingParagraphStyle]/@mergedBorders"/>
  688.                             <xsl:choose>
  689.                                 <xsl:when test="not($isPrecedingBorderParagraph) and $isFollowingBorderParagraph">
  690.                                     <xsl:attribute name="class">
  691.                                         <xsl:value-of select="concat(translate(@text:style-name, '.,;: %()[]/\+', '_____________'), '_borderStart')"/>
  692.                                     </xsl:attribute>
  693.                                     <xsl:apply-templates>
  694.                                         <xsl:with-param name="globalData" select="$globalData"/>
  695.                                     </xsl:apply-templates>
  696.                                 </xsl:when>
  697.                                 <xsl:when test="$isPrecedingBorderParagraph and not($isFollowingBorderParagraph)">
  698.                                     <xsl:attribute name="class">
  699.                                         <xsl:value-of select="concat(translate(@text:style-name, '.,;: %()[]/\+', '_____________'), '_borderEnd')"/>
  700.                                     </xsl:attribute>
  701.                                     <xsl:apply-templates>
  702.                                         <xsl:with-param name="globalData" select="$globalData"/>
  703.                                     </xsl:apply-templates>
  704.                                 </xsl:when>
  705.                                 <xsl:otherwise>
  706.                                     <xsl:attribute name="class">
  707.                                         <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
  708.                                     </xsl:attribute>
  709.                                     <xsl:apply-templates>
  710.                                         <xsl:with-param name="globalData" select="$globalData"/>
  711.                                     </xsl:apply-templates>
  712.                                 </xsl:otherwise>
  713.                             </xsl:choose>
  714.                         </xsl:when>
  715.                         <xsl:otherwise>
  716.                             <xsl:call-template name="write-paragraph">
  717.                                 <xsl:with-param name="globalData" select="$globalData"/>
  718.                             </xsl:call-template>
  719.                         </xsl:otherwise>
  720.                     </xsl:choose>
  721.                 </xsl:when>
  722.                 <xsl:otherwise>
  723.                     <xsl:call-template name="write-paragraph">
  724.                         <xsl:with-param name="globalData" select="$globalData" />
  725.                         <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
  726.                     </xsl:call-template>
  727.                 </xsl:otherwise>
  728.             </xsl:choose>
  729.         </xsl:element>
  730.     </xsl:template>
  731.  
  732.     <xsl:template name="write-paragraph">
  733.         <xsl:param name="globalData"/>
  734.         <!-- the footnote symbol is the prefix for a footnote in the footer -->
  735.         <xsl:param name="footnotePrefix" />
  736.  
  737.             <!-- empty paragraph tags does not provoke an carridge return,
  738.                 therefore an non breakable space ( ) have been inserted.-->
  739.         <xsl:choose>
  740.             <xsl:when test="node()">
  741.                 <xsl:call-template name="apply-styles-and-content">
  742.                     <xsl:with-param name="globalData" select="$globalData" />
  743.                     <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
  744.                 </xsl:call-template>
  745.             </xsl:when>
  746.             <xsl:otherwise>
  747.                 <xsl:call-template name="apply-styles-and-content">
  748.                     <xsl:with-param name="globalData" select="$globalData" />
  749.                     <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
  750.                 </xsl:call-template>
  751.                 <xsl:text> </xsl:text>
  752.             </xsl:otherwise>
  753.         </xsl:choose>
  754.     </xsl:template>
  755.  
  756.     <xsl:template match="style:tab-stop/@style:type">
  757.         <xsl:text>text-align:</xsl:text>
  758.         <xsl:choose>
  759.             <xsl:when test=". = 'left'">left</xsl:when>
  760.             <xsl:when test=". = 'right'">right</xsl:when>
  761.             <xsl:when test=". = 'center'">center</xsl:when>
  762.             <xsl:otherwise>justify</xsl:otherwise>
  763.         </xsl:choose>
  764.         <xsl:text>;</xsl:text>
  765.     </xsl:template>
  766.  
  767.     <!-- As soon a frame is within a paragraph (text:p) or page:frame, every child element is  floating (CSS) and worked out in sequence.
  768.     Accumulating prior frame width and adding parent's left margin -->
  769.     <!-- Matching all elements and text beyond a paragraph/text:page which are sibling of a draw:frame -->
  770.     <xsl:template match="* | text()" mode="frameFloating">
  771.         <xsl:param name="globalData"/>
  772.         <xsl:param name="previousFrameWidths" select="0"/>
  773.         <xsl:param name="previousFrameHeights" select="0" />
  774.         <!-- it becomes true for siblings after a draw:frame  -->
  775.         <xsl:param name="createDiv" select="false()"/>
  776.         <xsl:param name="noDivBefore" select="true()"/>
  777.         <xsl:param name="leftPosition" />
  778.         <xsl:param name="parentMarginLeft" />
  779.         <xsl:param name="frameAlignedToParagraphWithSvgY" />
  780.  
  781.         <xsl:choose>
  782.             <xsl:when test="name() = 'draw:frame'">
  783.                 <xsl:copy-of select="$frameAlignedToParagraphWithSvgY"/>
  784.  
  785.                 <!-- if the first node is a draw:frame create a div -->
  786.                 <xsl:call-template name="createDrawFrame">
  787.                     <xsl:with-param name="globalData" select="$globalData"/>
  788.                     <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
  789.                     <xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
  790.                     <xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
  791.                 </xsl:call-template>
  792.                 <!-- next elements will be called after the creation with the new indent (plus width of frame) -->
  793.             </xsl:when>
  794.             <xsl:otherwise>
  795.                 <xsl:variable name="nextSiblingIsFrame" select="name(following-sibling::node()[1]) = 'draw:frame'"/>
  796.                 <xsl:choose>
  797.                     <xsl:when test="$createDiv and normalize-space(.) != ''">
  798.                         <!-- every following frame sibling till the next draw:frame
  799.                             have to be incapuslated within a div with left indent.
  800.                             To be moved alltogether arcording the indent (usually right) -->
  801.                         <xsl:comment>Next 'div' added for floating.</xsl:comment>
  802.                         <xsl:element name="div">
  803.                             <xsl:attribute name="style">
  804.                                 <xsl:text>position:relative; left:</xsl:text>
  805.                                 <xsl:value-of select="$leftPosition"/>
  806.                                 <xsl:text>cm;</xsl:text>
  807.                             </xsl:attribute>
  808.                             <xsl:apply-templates select=".">
  809.                                 <xsl:with-param name="globalData" select="$globalData"/>
  810.                             </xsl:apply-templates>
  811.                             <!-- if it is a frame sibling it will be NOT incapuslated within the div (as already within one) -->
  812.                             <xsl:if test="not($nextSiblingIsFrame)">
  813.                                 <xsl:apply-templates select="following-sibling::node()[1]" mode="frameFloating">
  814.                                     <xsl:with-param name="globalData" select="$globalData"/>
  815.                                     <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
  816.                                     <xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
  817.                                     <xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
  818.                                     <xsl:with-param name="leftPosition" select="$leftPosition"/>
  819.                                     <xsl:with-param name="createDiv" select="false()"/>
  820.                                     <xsl:with-param name="noDivBefore" select="$noDivBefore"/>
  821.                                     <xsl:with-param name="frameAlignedToParagraphWithSvgY" select="$frameAlignedToParagraphWithSvgY"/>
  822.                                 </xsl:apply-templates>
  823.                             </xsl:if>
  824.                         </xsl:element>
  825.                         <xsl:copy-of select="$frameAlignedToParagraphWithSvgY"/>
  826.  
  827.                         <!-- Other draw:frame will be created outside of the div element  -->
  828.                         <xsl:apply-templates select="following-sibling::draw:frame[1]" mode="frameFloating">
  829.                             <xsl:with-param name="globalData" select="$globalData"/>
  830.                             <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
  831.                             <xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
  832.                             <xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
  833.                             <xsl:with-param name="leftPosition" select="$leftPosition"/>
  834.                             <xsl:with-param name="frameAlignedToParagraphWithSvgY" select="$frameAlignedToParagraphWithSvgY"/>
  835.                         </xsl:apply-templates>
  836.                     </xsl:when>
  837.                     <xsl:when test="not($createDiv)">
  838.                         <xsl:apply-templates select=".">
  839.                             <xsl:with-param name="globalData" select="$globalData"/>
  840.                             <xsl:with-param name="frameAlignedToParagraphWithSvgY" select="$frameAlignedToParagraphWithSvgY"/>
  841.                         </xsl:apply-templates>
  842.                         <xsl:if test="not($nextSiblingIsFrame) or $noDivBefore">
  843.                             <xsl:apply-templates select="following-sibling::node()[1]" mode="frameFloating">
  844.                                 <xsl:with-param name="globalData" select="$globalData"/>
  845.                                 <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
  846.                                 <xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
  847.                                 <xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
  848.                                 <xsl:with-param name="leftPosition" select="$leftPosition"/>
  849.                                 <xsl:with-param name="createDiv" select="false()"/>
  850.                                 <xsl:with-param name="noDivBefore" select="$noDivBefore"/>
  851.                                 <xsl:with-param name="frameAlignedToParagraphWithSvgY" select="$frameAlignedToParagraphWithSvgY"/>
  852.                             </xsl:apply-templates>
  853.                         </xsl:if>
  854.                     </xsl:when>
  855.                 </xsl:choose>
  856.             </xsl:otherwise>
  857.         </xsl:choose>
  858.     </xsl:template>
  859.  
  860.     <!-- A XML node other than text or element (e.g. commment) should not stop the recursion  -->
  861.     <xsl:template match="comment()" mode="frameFloating">
  862.         <xsl:param name="globalData"/>
  863.         <xsl:param name="previousFrameWidths" select="0"/>
  864.         <xsl:param name="previousFrameHeights" select="0" />
  865.         <!-- it becomes true for siblings after a draw:frame  -->
  866.         <xsl:param name="createDiv" select="false()"/>
  867.         <xsl:param name="noDivBefore" select="true()"/>
  868.         <xsl:param name="leftPosition" />
  869.         <xsl:param name="parentMarginLeft" />
  870.         <xsl:param name="frameAlignedToParagraphWithSvgY" />
  871.  
  872.         <xsl:apply-templates select="following-sibling::node()[1]" mode="frameFloating">
  873.             <xsl:with-param name="globalData" select="$globalData"/>
  874.             <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
  875.             <xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
  876.             <xsl:with-param name="leftPosition" select="$leftPosition"/>
  877.             <xsl:with-param name="createDiv" select="$createDiv"/>
  878.             <xsl:with-param name="noDivBefore" select="$noDivBefore"/>
  879.         </xsl:apply-templates>
  880.     </xsl:template>
  881.  
  882.  
  883.  
  884.     <!-- As draw:fame may occure within more elements than in text:p and draw:page -->
  885.     <xsl:template match="draw:frame">
  886.         <xsl:param name="globalData"/>
  887.         <xsl:param name="previousFrameWidths" select="0"/>
  888.         <xsl:param name="previousFrameHeights" select="0" />
  889.  
  890.         <xsl:call-template name="createDrawFrame">
  891.             <xsl:with-param name="globalData" select="$globalData" />
  892.             <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
  893.             <xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
  894.         </xsl:call-template>
  895.         <!-- after the last draw:frame sibling the CSS float is disabled -->
  896.         <xsl:if test="@text:anchor-type!='as-char'">
  897.             <div style="clear:both; line-height:0; width:0; height:0; margin:0; padding:0;"> </div>
  898.         </xsl:if>
  899.     </xsl:template>
  900.  
  901.     <xsl:template name="getPageMarginLeft">
  902.         <!-- approximation to find the correct master page style (with page dimensions) -->
  903.         <xsl:variable name="masterPageNames">
  904.             <!-- Loop over every style:style containing a @style:master-page-name attribute -->
  905.             <xsl:for-each select="key('masterPage','count')">
  906.                     <!-- Check if this style is being used in the body -->
  907.                 <xsl:if test="key('elementUsingStyle', ../@style:name)">
  908.                         <!-- Check every master-page-name if it is not emtpy and return as ';' separated list  -->
  909.                     <xsl:if test="string-length(../@style:master-page-name) > 0">
  910.                         <xsl:value-of select="../@style:master-page-name"/>;
  911.                     </xsl:if>
  912.                 </xsl:if>
  913.             </xsl:for-each>
  914.         </xsl:variable>
  915.         <!-- Take the first of the masterpage list and get the according style:master-page element and find the @style:page-layout-name  -->
  916.         <xsl:variable name="pageLayoutName" select="key('masterPageElements', substring-before($masterPageNames,';'))/@style:page-layout-name"/>
  917.          <!-- Find the according style:page-layout and store the properties in a variable  -->
  918.         <xsl:variable name="pageMarginLeftAttr" select="key('pageLayoutElements', $pageLayoutName)/style:page-layout-properties/@fo:margin-left"/>
  919.         <xsl:choose>
  920.             <xsl:when test="$pageMarginLeftAttr">
  921.                 <xsl:call-template name="convert2cm">
  922.                     <xsl:with-param name="value" select="$pageMarginLeftAttr"/>
  923.                 </xsl:call-template>
  924.             </xsl:when>
  925.             <xsl:otherwise>0</xsl:otherwise>
  926.         </xsl:choose>
  927.     </xsl:template>
  928.  
  929.     <!-- Elements and text aside of a draw:frame are floating, here a div is being created.
  930.         Either for a draw:frame or for text and other elements floating aside -->
  931.     <xsl:template name="createDrawFrame">
  932.         <xsl:param name="globalData"/>
  933.         <xsl:param name="previousFrameWidths" select="0"/>
  934.         <xsl:param name="previousFrameHeights" select="0" />
  935.         <xsl:param name="parentMarginLeft"/>
  936.  
  937.         <xsl:variable name="parentMarginLeftNew">
  938.             <xsl:choose>
  939.                 <xsl:when test="string-length(normalize-space($parentMarginLeft)) < 1">
  940.                     <!-- Styles of first paragraph in list item, including ancestor styles (inheritance) -->
  941.                     <xsl:variable name="paragraphName" select="parent::*/@text:style-name" />
  942.                     <xsl:variable name="imageParagraphStyle" select="$globalData/all-styles/style[@style:name = $paragraphName]/final-properties"/>
  943.                     <!-- Only the left margin of the first paragraph of a list item will be added to the margin of the complete list (all levels)-->
  944.                     <xsl:choose>
  945.                         <xsl:when test="contains($imageParagraphStyle, 'margin-left:')">
  946.                             <xsl:call-template name="convert2cm">
  947.                                 <xsl:with-param name="value" select="normalize-space(substring-before(substring-after($imageParagraphStyle, 'margin-left:'), ';'))"/>
  948.                             </xsl:call-template>
  949.                         </xsl:when>
  950.                         <xsl:otherwise>0</xsl:otherwise>
  951.                     </xsl:choose>
  952.                 </xsl:when>
  953.                 <xsl:otherwise>
  954.                     <xsl:value-of select="$parentMarginLeft"/>
  955.                 </xsl:otherwise>
  956.             </xsl:choose>
  957.         </xsl:variable>
  958.         <xsl:variable name="svgWidth">
  959.             <xsl:choose>
  960.                 <xsl:when test="@svg:width">
  961.                     <xsl:call-template name="convert2cm">
  962.                         <xsl:with-param name="value" select="@svg:width"/>
  963.                     </xsl:call-template>
  964.                 </xsl:when>
  965.                 <xsl:otherwise>0</xsl:otherwise>
  966.             </xsl:choose>
  967.         </xsl:variable>
  968.         <xsl:variable name="svgX">
  969.             <xsl:choose>
  970.                 <xsl:when test="@svg:x">
  971.                     <xsl:call-template name="convert2cm">
  972.                         <xsl:with-param name="value" select="@svg:x"/>
  973.                     </xsl:call-template>
  974.                 </xsl:when>
  975.                 <xsl:otherwise>0</xsl:otherwise>
  976.             </xsl:choose>
  977.         </xsl:variable>
  978.         <xsl:variable name="leftPosition" select="$svgX - $parentMarginLeftNew - $previousFrameWidths"/>
  979.         <xsl:variable name="svgY">
  980.             <xsl:choose>
  981.                 <xsl:when test="@svg:y">
  982.                     <xsl:call-template name="convert2cm">
  983.                         <xsl:with-param name="value" select="@svg:y"/>
  984.                     </xsl:call-template>
  985.                 </xsl:when>
  986.                 <xsl:otherwise>0</xsl:otherwise>
  987.             </xsl:choose>
  988.         </xsl:variable>
  989.         <!-- if the frame is anchored on a paragraph -->
  990.         <xsl:if test="@text:anchor-type='paragraph'">
  991.             <xsl:comment>Next 'div' is emulating the top hight of a draw:frame.</xsl:comment>
  992.             <!-- When the svg:y is set relativ to the paragraph content, the best way to emulate a positive height,
  993.              is to add an invisbile division inbetween with a height.
  994.              Often text will flow into this 'gap', which is handled separately!
  995.              -->
  996.             <xsl:if test="$svgY > 0">
  997.                 <xsl:element name="div">
  998.                     <xsl:attribute name="style">
  999.                         <xsl:text>height:</xsl:text>
  1000.                         <xsl:value-of select="$svgY"/>
  1001.                         <xsl:text>cm;</xsl:text>
  1002.                     </xsl:attribute>
  1003.                     <xsl:text> </xsl:text>
  1004.                 </xsl:element>
  1005.             </xsl:if>
  1006.         </xsl:if>
  1007.  
  1008.  
  1009.       <!--
  1010.         <xsl:variable name="followingSibling" select="following-sibling::node()[1]"/>
  1011.         <xsl:choose>
  1012.            HEURISTIC: if the frame is anchored on a paragraph and the above gab is big enough to hold a text line,
  1013.                 move it behind the text
  1014.             <xsl:when test="@text:anchor-type='paragraph' and
  1015.                 (
  1016.                     ($svgY > 0.5) or
  1017.                     ($svgX > 4)
  1018.                 ) and normalize-space($followingSibling) != ''">
  1019.                 <xsl:apply-templates select="$followingSibling" mode="frameFloating">
  1020.                     <xsl:with-param name="globalData" select="$globalData"/>
  1021.                     <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths + $svgWidth"/>
  1022.                     <xsl:with-param name="parentMarginLeft" select="$parentMarginLeftNew"/>
  1023.                     <xsl:with-param name="leftPosition" select="$leftPosition"/>
  1024.                     <xsl:with-param name="createDiv" select="true()"/>
  1025.                     <xsl:with-param name="noDivBefore" select="false()"/>
  1026.                     <xsl:with-param name="frameAlignedToParagraphWithSvgY">
  1027.                         <xsl:call-template name="createDrawFrame2">
  1028.                             <xsl:with-param name="globalData" select="$globalData"/>
  1029.                             <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths + $svgWidth"/>
  1030.                             <xsl:with-param name="parentMarginLeftNew" select="$parentMarginLeftNew"/>
  1031.                             <xsl:with-param name="leftPosition" select="$leftPosition"/>
  1032.                             <xsl:with-param name="svgY" select="$svgY"/>
  1033.                         </xsl:call-template>
  1034.                     </xsl:with-param>
  1035.                 </xsl:apply-templates>
  1036.             </xsl:when>
  1037.             <xsl:otherwise>-->
  1038.         <xsl:call-template name="createDrawFrame2">
  1039.             <xsl:with-param name="globalData" select="$globalData"/>
  1040.             <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths + $svgWidth"/>
  1041.             <xsl:with-param name="parentMarginLeftNew" select="$parentMarginLeftNew"/>
  1042.             <xsl:with-param name="leftPosition" select="$leftPosition"/>
  1043.             <xsl:with-param name="svgY" select="$svgY"/>
  1044.         </xsl:call-template>
  1045.         <xsl:apply-templates select="following-sibling::node()[1]" mode="frameFloating">
  1046.             <xsl:with-param name="globalData" select="$globalData"/>
  1047.             <xsl:with-param name="previousFrameWidths" select="$previousFrameWidths + $svgWidth"/>
  1048.             <xsl:with-param name="parentMarginLeft" select="$parentMarginLeftNew"/>
  1049.             <xsl:with-param name="leftPosition" select="$leftPosition"/>
  1050.             <xsl:with-param name="createDiv" select="true()"/>
  1051.             <xsl:with-param name="noDivBefore" select="false()"/>
  1052.         </xsl:apply-templates>
  1053.                 <!--
  1054.  
  1055.             </xsl:otherwise>
  1056.         </xsl:choose> -->
  1057.     </xsl:template>
  1058.  
  1059.     <xsl:template name="createDrawFrame2">
  1060.         <xsl:param name="globalData"/>
  1061.         <xsl:param name="previousFrameWidths" />
  1062.         <xsl:param name="parentMarginLeftNew"/>
  1063.         <xsl:param name="leftPosition" />
  1064.         <xsl:param name="svgY" />
  1065.  
  1066.         <xsl:variable name="elem-name">
  1067.             <xsl:choose>
  1068.                 <xsl:when test="@text:anchor-type='as-char'">span</xsl:when>
  1069.                 <xsl:otherwise>div</xsl:otherwise>
  1070.             </xsl:choose>
  1071.         </xsl:variable>
  1072.         <xsl:comment>Next '
  1073.             <xsl:value-of select="$elem-name"/>' is a draw:frame.
  1074.         </xsl:comment>
  1075.         <xsl:element name="{$elem-name}">
  1076.             <xsl:attribute name="style">
  1077.                 <xsl:call-template name="widthAndHeight"/>
  1078.                 <!-- MIB -->
  1079.                 <xsl:text> padding:0; </xsl:text>
  1080.                 <xsl:if test="@text:anchor-type!='as-char'">
  1081.                     <!-- all images float (CSS float reltaive) with a left position calculated by svg:x - parentMarginLeft - previousFrameWidths -->
  1082.                     <xsl:text> float:left; position:relative; left:</xsl:text>
  1083.                     <xsl:value-of select="$leftPosition"/>
  1084.                     <xsl:text>cm; </xsl:text>
  1085.                     <!-- if the frame is anchored on a char -->
  1086.                     <xsl:if test="@text:anchor-type='char'">
  1087.                         <xsl:text>top:</xsl:text>
  1088.                         <xsl:value-of select="$svgY"/>
  1089.                         <xsl:text>cm; </xsl:text>
  1090.                     </xsl:if>
  1091.                 </xsl:if>
  1092.             </xsl:attribute>
  1093.             <xsl:apply-templates select="@*">
  1094.                 <xsl:with-param name="globalData" select="$globalData"/>
  1095.             </xsl:apply-templates>
  1096.             <xsl:apply-templates select="node()">
  1097.                 <xsl:with-param name="globalData" select="$globalData"/>
  1098.             </xsl:apply-templates>
  1099.         </xsl:element>
  1100.     </xsl:template>
  1101.  
  1102.     <xsl:template match="svg:desc"/>
  1103.  
  1104.     <xsl:template name="widthAndHeight">
  1105.         <xsl:if test="@svg:height | @svg:width">
  1106.             <xsl:choose>
  1107.                 <xsl:when test="not(@svg:width)">
  1108.                     <xsl:call-template name="svg:height"/>
  1109.                 </xsl:when>
  1110.                 <xsl:when test="not(@svg:height)">
  1111.                     <xsl:call-template name="svg:width"/>
  1112.                 </xsl:when>
  1113.                 <xsl:otherwise>
  1114.                     <xsl:call-template name="svg:height"/>
  1115.                     <xsl:call-template name="svg:width"/>
  1116.                 </xsl:otherwise>
  1117.             </xsl:choose>
  1118.         </xsl:if>
  1119.     </xsl:template>
  1120.  
  1121.     <!-- ***************** -->
  1122.     <!-- *** Text Span *** -->
  1123.     <!-- ***************** -->
  1124.  
  1125.     <xsl:template match="text:span">
  1126.         <xsl:param name="globalData"/>
  1127.  
  1128.         <xsl:choose>
  1129.             <xsl:when test="draw:frame">
  1130.                 <!-- sometimes an ODF image is anchored as character and the
  1131.                     image frame appears within a span (which is not valid for HTML)
  1132.                     Heuristic: Neglecting the span assuming no text content aside
  1133.                     of frame within span -->
  1134.                 <xsl:apply-templates>
  1135.                     <xsl:with-param name="globalData" select="$globalData"/>
  1136.                 </xsl:apply-templates>
  1137.             </xsl:when>
  1138.             <xsl:otherwise>
  1139.                 <xsl:element name="span">
  1140.                     <xsl:call-template name="apply-styles-and-content">
  1141.                         <xsl:with-param name="globalData" select="$globalData"/>
  1142.                     </xsl:call-template>
  1143.                 </xsl:element>
  1144.             </xsl:otherwise>
  1145.         </xsl:choose>
  1146.     </xsl:template>
  1147.  
  1148.  
  1149.  
  1150.     <!-- **************** -->
  1151.     <!-- *** Headings *** -->
  1152.     <!-- **************** -->
  1153.  
  1154.     <xsl:template match="text:h">
  1155.         <xsl:param name="globalData"/>
  1156.  
  1157.         <!-- no creation of empty headings (without text content)   -->
  1158.         <xsl:if test="text() or descendant::text()">
  1159.             <!-- The URL linking of an table-of-content is due to a bug (cp. bug id# 102311) not mapped as URL in the XML.
  1160.                  Linking of the table-of-content can therefore only be archieved by a work-around in HTML -->
  1161.             <xsl:call-template name="create-heading">
  1162.                 <xsl:with-param name="globalData" select="$globalData"/>
  1163.             </xsl:call-template>
  1164.         </xsl:if>
  1165.     </xsl:template>
  1166.  
  1167.     <!-- default matching for header elements -->
  1168.     <xsl:template name="create-heading">
  1169.         <xsl:param name="globalData"/>
  1170.  
  1171.         <xsl:variable name="headingLevel">
  1172.             <xsl:choose>
  1173.                 <xsl:when test="@text:outline-level < 6">
  1174.                     <xsl:value-of select="@text:outline-level"/>
  1175.                 </xsl:when>
  1176.                 <xsl:otherwise>6</xsl:otherwise>
  1177.             </xsl:choose>
  1178.         </xsl:variable>
  1179.         <xsl:variable name="headertyp" select="concat('h', $headingLevel)"/>
  1180.         <xsl:element name="{$headertyp}">
  1181.             <!-- outline style 'text:min-label-width' is interpreted as a CSS 'margin-right' attribute
  1182.             NOTE: Should be handled as CSS style in style header -->
  1183.             <xsl:variable name="min-label" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/*/@text:min-label-width"/>
  1184.             <xsl:attribute name="class">
  1185.                 <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
  1186.             </xsl:attribute>
  1187.  
  1188.             <xsl:call-template name="create-heading-anchor">
  1189.                 <xsl:with-param name="globalData" select="$globalData"/>
  1190.             </xsl:call-template>
  1191.  
  1192.             <xsl:apply-templates>
  1193.                 <xsl:with-param name="globalData" select="$globalData"/>
  1194.             </xsl:apply-templates>
  1195.         </xsl:element>
  1196.  
  1197.     </xsl:template>
  1198.  
  1199.     <xsl:template name="create-heading-anchor">
  1200.         <xsl:param name="globalData"/>
  1201.  
  1202.         <!-- writing out a heading number if desired.-->
  1203.         <!-- if a corresponding 'text:outline-style' exist or is not empty -->
  1204.         <xsl:choose>
  1205.             <xsl:when test="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@style:num-format != ''">
  1206.  
  1207.                 <!-- Every heading element will get an unique anchor for its file, from its hiearchy level and name:
  1208.                      For example:  The heading title 'My favorite heading' might get <a name="1_2_2_My_favorite_heading" /> -->
  1209.                 <!-- creating an anchor for referencing the heading (e.g. from content table) -->
  1210.                 <xsl:variable name="headingNumber">
  1211.                     <xsl:call-template name="get-heading-number">
  1212.                         <xsl:with-param name="globalData" select="$globalData"/>
  1213.                     </xsl:call-template>
  1214.                 </xsl:variable>
  1215.                 <xsl:call-template name="create-heading-anchor2">
  1216.                     <xsl:with-param name="globalData" select="$globalData"/>
  1217.                     <xsl:with-param name="headingNumber" select="$headingNumber"/>
  1218.                 </xsl:call-template>
  1219.             </xsl:when>
  1220.             <xsl:otherwise>
  1221.                 <xsl:call-template name="create-heading-anchor2">
  1222.                     <xsl:with-param name="globalData" select="$globalData"/>
  1223.                 </xsl:call-template>
  1224.             </xsl:otherwise>
  1225.         </xsl:choose>
  1226.     </xsl:template>
  1227.  
  1228.  
  1229.     <xsl:template name="get-heading-number">
  1230.         <xsl:param name="globalData"/>
  1231.  
  1232.         <!-- write number prefix -->
  1233.         <xsl:value-of select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@style:num-prefix"/>
  1234.         <xsl:call-template name="write-heading-number">
  1235.             <xsl:with-param name="globalData" select="$globalData"/>
  1236.         </xsl:call-template>
  1237.         <!-- write number suffix -->
  1238.         <xsl:value-of select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@style:num-suffix"/>
  1239.     </xsl:template>
  1240.  
  1241.     <!-- creating an anchor for referencing the heading -->
  1242.     <xsl:template name="create-heading-anchor2">
  1243.         <xsl:param name="globalData"/>
  1244.         <xsl:param name="headingNumber" />
  1245.  
  1246.         <xsl:variable name="title">
  1247.             <xsl:apply-templates mode="concatenate"/>
  1248.         </xsl:variable>
  1249.         <!-- REFERENCE HANDLING - ANCHOR -->
  1250.         <xsl:element namespace="{$namespace}" name="a">
  1251.             <xsl:attribute name="id">
  1252.                 <xsl:value-of select="translate(concat('a_',$headingNumber, '_', normalize-space($title)), ' &<>.,;: %()[]/\+', '___________________________')"/>
  1253.             </xsl:attribute>
  1254.  
  1255.             <xsl:element name="span">
  1256.                 <!-- outline style 'text:min-label-distance' is interpreted as a CSS 'margin-right' attribute
  1257.                 NOTE: Should be handled as CSS style in style header -->
  1258.                 <xsl:variable name="minLabelDistance" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/*/@text:min-label-distance"/>
  1259.                 <xsl:variable name="minLabelWidth" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/*/@text:min-label-width"/>
  1260.  
  1261.                 <xsl:if test="$minLabelDistance | $minLabelWidth">
  1262.                     <xsl:attribute name="style">
  1263.                         <xsl:if test="$minLabelDistance">
  1264.                             <xsl:text>margin-right:</xsl:text>
  1265.                             <xsl:call-template name="convert2cm">
  1266.                                 <xsl:with-param name="value" select="$minLabelDistance"/>
  1267.                             </xsl:call-template>
  1268.                             <xsl:text>cm;</xsl:text>
  1269.                         </xsl:if>
  1270.                         <xsl:if test="$minLabelWidth">
  1271.                             <xsl:text>min-width:</xsl:text>
  1272.                             <xsl:call-template name="convert2cm">
  1273.                                 <xsl:with-param name="value" select="$minLabelWidth"/>
  1274.                             </xsl:call-template>
  1275.                             <xsl:text>cm;</xsl:text>
  1276.                         </xsl:if>
  1277.                     </xsl:attribute>
  1278.                 </xsl:if>
  1279.                 <xsl:copy-of select="$headingNumber"/>
  1280.             </xsl:element>
  1281.         </xsl:element>
  1282.     </xsl:template>
  1283.  
  1284.     <xsl:template name="write-heading-number">
  1285.         <xsl:param name="globalData"/>
  1286.  
  1287.         <!-- By default heading start with '1', the parameter 'textStartValue' will only be set, if the attribute @text:start-value exist -->
  1288.         <xsl:choose>
  1289.             <xsl:when test="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@text:start-value">
  1290.                 <xsl:call-template name="calc-heading-number">
  1291.                     <xsl:with-param name="globalData" select="$globalData"/>
  1292.                     <xsl:with-param name="outlineLevel" select="@text:outline-level"/>
  1293.                     <xsl:with-param name="textStartValue" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@text:start-value"/>
  1294.                 </xsl:call-template>
  1295.             </xsl:when>
  1296.             <xsl:otherwise>
  1297.                 <xsl:call-template name="calc-heading-number">
  1298.                     <xsl:with-param name="globalData" select="$globalData"/>
  1299.                     <xsl:with-param name="outlineLevel" select="@text:outline-level"/>
  1300.                 </xsl:call-template>
  1301.             </xsl:otherwise>
  1302.         </xsl:choose>
  1303.     </xsl:template>
  1304.  
  1305.     <!--
  1306.     Find the correct heading no., which is the sum of 'text:start-value'
  1307.     and preceding siblings of 'text:h' with the same 'text:outline-level' (until a text:outline-level with lower value is found).
  1308.     If the 'text:start-value is not set the default value of '1' has to be taken.
  1309.     If a heading number is found (e.g. text:outline-level='3') all heading numbers
  1310.     for the higher levels have to be written out -->
  1311.     <xsl:template name="calc-heading-number">
  1312.         <xsl:param name="globalData"/>
  1313.         <xsl:param name="outlineLevel"/><!-- text level of the heading -->
  1314.         <xsl:param name="iOutlineLevel" select="1"/><!-- iterator, counts from 1 to the text level of the heading -->
  1315.         <xsl:param name="textStartValue" select="1"/><!-- text level to start with, default is '1' -->
  1316.  
  1317.         <xsl:choose>
  1318.             <!-- iText levels counts up from '1' to outlineLevel
  1319.                 Which means writing a heading number from left to right -->
  1320.             <xsl:when test="$iOutlineLevel < $outlineLevel">
  1321.  
  1322.             <!-- Write preceding heading numbers -->
  1323.                 <xsl:call-template name="writeNumber">
  1324.                     <xsl:with-param name="numberDigit">
  1325.                         <xsl:call-template name="calc-heading-digit">
  1326.                             <xsl:with-param name="value" select="0"/>
  1327.                             <xsl:with-param name="currentoutlineLevel" select="$iOutlineLevel"/>
  1328.                         </xsl:call-template>
  1329.                     </xsl:with-param>
  1330.                     <xsl:with-param name="numberFormat" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = ($outlineLevel)]/@style:num-format"/>
  1331.                 </xsl:call-template>
  1332.                 <xsl:choose>
  1333.                     <xsl:when test="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = ($iOutlineLevel + 1)]/@text:start-value">
  1334.                         <xsl:call-template name="calc-heading-number">
  1335.                             <xsl:with-param name="globalData" select="$globalData"/>
  1336.                             <xsl:with-param name="outlineLevel" select="$outlineLevel"/>
  1337.                             <xsl:with-param name="iOutlineLevel" select="$iOutlineLevel + 1"/>
  1338.                             <xsl:with-param name="textStartValue" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = ($iOutlineLevel + 1)]/@text:start-value"/>
  1339.                         </xsl:call-template>
  1340.                     </xsl:when>
  1341.                     <xsl:otherwise>
  1342.                         <xsl:call-template name="calc-heading-number">
  1343.                             <xsl:with-param name="globalData" select="$globalData"/>
  1344.                             <xsl:with-param name="outlineLevel" select="$outlineLevel"/>
  1345.                             <xsl:with-param name="iOutlineLevel" select="$iOutlineLevel + 1"/>
  1346.                         </xsl:call-template>
  1347.                     </xsl:otherwise>
  1348.                 </xsl:choose>
  1349.             </xsl:when>
  1350.             <xsl:otherwise>
  1351.                 <!-- Write preceding heading numbers -->
  1352.                 <xsl:call-template name="writeNumber">
  1353.                     <xsl:with-param name="numberDigit">
  1354.                         <xsl:call-template name="calc-heading-digit">
  1355.                             <xsl:with-param name="value" select="$textStartValue"/>
  1356.                             <xsl:with-param name="currentoutlineLevel" select="$iOutlineLevel"/>
  1357.                         </xsl:call-template>
  1358.                     </xsl:with-param>
  1359.                     <xsl:with-param name="numberFormat" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = $outlineLevel]/@style:num-format"/>
  1360.                     <xsl:with-param name="last" select="true()"/>
  1361.                 </xsl:call-template>
  1362.             </xsl:otherwise>
  1363.         </xsl:choose>
  1364.     </xsl:template>
  1365.  
  1366.     <xsl:template name="writeNumber">
  1367.         <xsl:param name="numberDigit"/>
  1368.         <xsl:param name="numberFormat"/>
  1369.         <xsl:param name="last"/>
  1370.  
  1371.         <xsl:choose>
  1372.             <xsl:when test="not($numberFormat)">
  1373.                 <xsl:number value="$numberDigit" format="1."/>
  1374.             </xsl:when>
  1375.             <xsl:otherwise>
  1376.                 <xsl:choose>
  1377.                     <xsl:when test="$last">
  1378.                         <xsl:number value="$numberDigit" format="{$numberFormat}"/>
  1379.                     </xsl:when>
  1380.                     <xsl:otherwise>
  1381.                         <xsl:number value="$numberDigit" format="{$numberFormat}."/>
  1382.                     </xsl:otherwise>
  1383.                 </xsl:choose>
  1384.             </xsl:otherwise>
  1385.         </xsl:choose>
  1386.     </xsl:template>
  1387.  
  1388.     <xsl:template name="calc-heading-digit">
  1389.         <xsl:param name="value"/>
  1390.         <xsl:param name="currentoutlineLevel"/>
  1391.         <xsl:param name="i" select="1"/>
  1392.  
  1393.         <xsl:variable name="precedingoutlineLevel" select="preceding-sibling::text:h[$i]/@text:outline-level"/>
  1394.         <xsl:choose>
  1395.             <xsl:when test="$currentoutlineLevel = $precedingoutlineLevel">
  1396.                 <xsl:call-template name="calc-heading-digit">
  1397.                     <xsl:with-param name="value" select="$value + 1"/>
  1398.                     <xsl:with-param name="currentoutlineLevel" select="$currentoutlineLevel"/>
  1399.                     <xsl:with-param name="i" select="$i + 1"/>
  1400.                 </xsl:call-template>
  1401.             </xsl:when>
  1402.             <xsl:when test="$currentoutlineLevel < $precedingoutlineLevel">
  1403.                 <xsl:call-template name="calc-heading-digit">
  1404.                     <xsl:with-param name="value" select="$value"/>
  1405.                     <xsl:with-param name="currentoutlineLevel" select="$currentoutlineLevel"/>
  1406.                     <xsl:with-param name="i" select="$i + 1"/>
  1407.                 </xsl:call-template>
  1408.             </xsl:when>
  1409.             <xsl:otherwise>
  1410.                 <xsl:value-of select="$value"/>
  1411.             </xsl:otherwise>
  1412.         </xsl:choose>
  1413.     </xsl:template>
  1414.  
  1415.     <!-- Neglect Annotations -->
  1416.     <xsl:template match="office:annotation" mode="concatenate"/>
  1417.  
  1418.     <!-- Match text:placeholder child nodes (e.g. text) -->
  1419.     <xsl:template match="text:placeholder">
  1420.         <xsl:param name="globalData"/>
  1421.  
  1422.         <xsl:call-template name="apply-styles-and-content">
  1423.             <xsl:with-param name="globalData" select="$globalData"/>
  1424.         </xsl:call-template>
  1425.     </xsl:template>
  1426.  
  1427.     <!-- ************* -->
  1428.     <!-- *** Link  *** -->
  1429.     <!-- ************* -->
  1430.  
  1431.     <xsl:template match="text:a | draw:a">
  1432.         <xsl:param name="globalData"/>
  1433.  
  1434.         <xsl:call-template name="create-common-anchor-link">
  1435.             <xsl:with-param name="globalData" select="$globalData"/>
  1436.         </xsl:call-template>
  1437.     </xsl:template>
  1438.  
  1439.  
  1440.     <xsl:template name="create-common-anchor-link">
  1441.         <xsl:param name="globalData"/>
  1442.  
  1443.         <xsl:element name="a">
  1444.             <xsl:attribute name="href">
  1445.                 <xsl:call-template name="create-href">
  1446.                     <xsl:with-param name="href" select="@xlink:href"/>
  1447.                 </xsl:call-template>
  1448.             </xsl:attribute>
  1449.             <xsl:call-template name="apply-styles-and-content">
  1450.                 <xsl:with-param name="globalData" select="$globalData"/>
  1451.             </xsl:call-template>
  1452.         </xsl:element>
  1453.     </xsl:template>
  1454.  
  1455.  
  1456.  
  1457.     <!-- ******************* -->
  1458.     <!-- *** Image Link  *** -->
  1459.     <!-- ******************* -->
  1460.  
  1461.     <!-- currently suggesting that all draw:object-ole elements are images -->
  1462.     <xsl:template match="draw:image | draw:object-ole">
  1463.         <xsl:param name="globalData"/>
  1464.  
  1465.         <xsl:choose>
  1466.             <xsl:when test="ancestor::text:p or parent::text:span or parent::text:h or parent::draw:a or parent::text:a or text:ruby-base">
  1467.                 <!-- XHTML does not allow the mapped elements to contain paragraphs -->
  1468.                 <xsl:call-template name="create-image-element">
  1469.                     <xsl:with-param name="globalData" select="$globalData"/>
  1470.                 </xsl:call-template>
  1471.             </xsl:when>
  1472.             <xsl:otherwise>
  1473.                 <!-- images are embedded in a paragraph, but are in CSS not able to express a horizontal alignment for themself.
  1474.                     A 'div' element taking over the image style would solve that problem, but is invalid as child of a paragraph -->
  1475.                 <xsl:element name="p">
  1476.                     <xsl:apply-templates select="@draw:style-name">
  1477.                         <xsl:with-param name="globalData" select="$globalData"/>
  1478.                     </xsl:apply-templates>
  1479.  
  1480.                     <xsl:call-template name="create-image-element">
  1481.                         <xsl:with-param name="globalData" select="$globalData"/>
  1482.                     </xsl:call-template>
  1483.                 </xsl:element>
  1484.             </xsl:otherwise>
  1485.         </xsl:choose>
  1486.     </xsl:template>
  1487.  
  1488.     <xsl:template name="create-image-element">
  1489.         <xsl:param name="globalData"/>
  1490.  
  1491.         <xsl:element name="img">
  1492.             <xsl:if test="../@svg:width or ../@svg:height">
  1493.                 <xsl:attribute name="style">
  1494.                     <xsl:if test="../@svg:height">
  1495.                         <xsl:text>height:</xsl:text>
  1496.                         <xsl:call-template name="convert2cm">
  1497.                             <xsl:with-param name="value" select="../@svg:height"/>
  1498.                         </xsl:call-template>
  1499.                         <xsl:text>cm;</xsl:text>
  1500.                     </xsl:if>
  1501.                     <xsl:if test="../@svg:width">
  1502.                         <xsl:text>width:</xsl:text>
  1503.                         <xsl:call-template name="convert2cm">
  1504.                             <xsl:with-param name="value" select="../@svg:width"/>
  1505.                         </xsl:call-template>
  1506.                         <xsl:text>cm;</xsl:text>
  1507.                     </xsl:if>
  1508.                 </xsl:attribute>
  1509.             </xsl:if>
  1510.             <xsl:attribute name="alt">
  1511.                 <xsl:choose>
  1512.                     <xsl:when test="../svg:desc">
  1513.                         <xsl:value-of select="../svg:desc"/>
  1514.                     </xsl:when>
  1515.                     <xsl:otherwise>
  1516.                         <xsl:message>
  1517.     Accessibility Warning:
  1518.          No alternate text ('svg:desc' element) set for
  1519.          image '
  1520.                             <xsl:value-of select="@xlink:href"/>'!
  1521.                         </xsl:message>
  1522.                     </xsl:otherwise>
  1523.                 </xsl:choose>
  1524.             </xsl:attribute>
  1525.  
  1526.             <xsl:attribute name="src">
  1527.                 <xsl:call-template name="create-href">
  1528.                     <xsl:with-param name="href" select="@xlink:href"/>
  1529.                 </xsl:call-template>
  1530.             </xsl:attribute>
  1531.  
  1532.             <!-- style interpretation only, as no subelements are allowed for img in XHTML -->
  1533.             <xsl:apply-templates select="@draw:style-name">
  1534.                 <xsl:with-param name="globalData" select="$globalData"/>
  1535.             </xsl:apply-templates>
  1536.         </xsl:element>
  1537.     </xsl:template>
  1538.  
  1539.     <!-- ************ -->
  1540.     <!-- *** list *** -->
  1541.     <!-- ************ -->
  1542.     <!--
  1543.         Due to the requirements below the ODF list functionality is not handled by CSS, but the list labels calculated and written by XSLT.
  1544.  
  1545.         REQUIREMENTS:
  1546.         =============
  1547.  
  1548.         A)
  1549.         One significant difference between XHTML and Office List elements is that a list without text nodes but only further list children
  1550.         would not show a list symbol in the Office, but in the browser from XHTML.
  1551.  
  1552.         B)
  1553.         Since OASIS Open Document XML (implemented in OOo2.0) only one parent type exists for list items
  1554.         the 'text:list' element. The XHTML element 'ol', 'ul' will be choosen upon the list style type.
  1555.  
  1556.         C)
  1557.         An Office list may be spread over the whole document. Linked by their style and text:continue-numbering='true'.
  1558.  
  1559.         D)
  1560.         An Office list can use characters or images as list label.
  1561.  
  1562.         E)
  1563.         An Office list can have a prefix and suffix around the list label.
  1564.  
  1565.         F)
  1566.         An Office list style may have the attribute consecutive numbering, which resolves in a list counting for all levels
  1567.  
  1568.         G)
  1569.         An Office list may (re)start on any arbitrary value by using @text:start-value on the text:list-item
  1570.  
  1571.         INDENDATION:
  1572.         ============
  1573.  
  1574.         The indent of a list label is not only calculated by using the text:space-before of the list level (listLevelStyle), but
  1575.         as well taking the left margin of the first paragraph (or heading) of the list into account as loy match="" name="" use=""/>ng it is not negative.
  1576.  
  1577.         |           MARGIN LEFT                 |        LABEL           |
  1578.  
  1579.         |   text:space-before (listlevelstyle)  | text:min-label-width   |
  1580.         | + fo:left-margin (firstParagraph)     |                        |
  1581.  
  1582.         Further details beyond text:list-list..
  1583.     -->
  1584.     <xsl:key name="listStyles" match=" /*/office:styles/text:list-style | /*/office:automatic-styles/text:list-style | /*/office:styles/style:graphic-properties/text:list-style | /*/office:automatic-styles/style:graphic-properties/text:list-style | /*/office:styles/text:list-style | /*/office:automatic-styles/text:list-style | /*/office:styles/style:graphic-properties/text:list-style | /*/office:automatic-styles/style:graphic-properties/text:list-style" use="@style:name"/>
  1585.  
  1586.     <!--
  1587.         A text list may only have text:list-item and text:list-header as children.
  1588.     -->
  1589.     <xsl:template match="text:list">
  1590.         <xsl:param name="globalData"/>
  1591.         <xsl:param name="isListNumberingReset"/>
  1592.         <xsl:param name="isNextLevelNumberingReset"/>
  1593.         <xsl:param name="listLevel" select="1"/>
  1594.         <xsl:param name="listRestart" select="false()"/>
  1595.         <xsl:param name="itemLabel" select="''"/>
  1596.         <xsl:param name="listStyle"/>
  1597.         <xsl:param name="listStyleName" select="@text:style-name"/>
  1598.  
  1599.         <!-- To choose list type - get the list style, with the same 'text:style-name' and same 'text:level' >-->
  1600.         <xsl:variable name="listStyleRTF">
  1601.             <xsl:variable name="listStyleInContentFile" select="key('listStyles', $listStyleName)"/>
  1602.             <xsl:choose>
  1603.                 <xsl:when test="$listStyleInContentFile">
  1604.                     <xsl:copy-of select="$listStyleInContentFile"/>
  1605.                 </xsl:when>
  1606.                 <xsl:when test="$globalData/office:styles/text:list-style[@style:name = $listStyleName]">
  1607.                     <xsl:copy-of select="$globalData/office:styles/text:list-style[@style:name = $listStyleName]"/>
  1608.                 </xsl:when>
  1609.                 <xsl:when test="$globalData/office:styles/style:graphic-properties/text:list-style[@style:name = $listStyleName]">
  1610.                     <xsl:copy-of select="$globalData/office:styles/style:graphic-properties/text:list-style[@style:name = $listStyleName]"/>
  1611.                 </xsl:when>
  1612.             </xsl:choose>
  1613.         </xsl:variable>
  1614.  
  1615.         <xsl:choose>
  1616.             <xsl:when test="function-available('common:node-set')">
  1617.                 <xsl:call-template name="create-list-type">
  1618.                     <xsl:with-param name="listStyle" select="common:node-set($listStyleRTF)" />
  1619.                     <xsl:with-param name="globalData" select="$globalData"/>
  1620.                     <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  1621.                     <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  1622.                     <xsl:with-param name="listLevel" select="$listLevel"/>
  1623.                     <xsl:with-param name="listRestart" select="$listRestart"/>
  1624.                     <xsl:with-param name="itemLabel" select="$itemLabel"/>
  1625.                     <xsl:with-param name="listStyleName" select="$listStyleName" />
  1626.                 </xsl:call-template>
  1627.             </xsl:when>
  1628.             <xsl:when test="function-available('xalan:nodeset')">
  1629.                 <xsl:call-template name="create-list-type">
  1630.                     <xsl:with-param name="listStyle" select="xalan:nodeset($listStyleRTF)" />
  1631.                     <xsl:with-param name="globalData" select="$globalData"/>
  1632.                     <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  1633.                     <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  1634.                     <xsl:with-param name="listLevel" select="$listLevel"/>
  1635.                     <xsl:with-param name="listRestart" select="$listRestart"/>
  1636.                     <xsl:with-param name="itemLabel" select="$itemLabel"/>
  1637.                     <xsl:with-param name="listStyleName" select="$listStyleName" />
  1638.                 </xsl:call-template>
  1639.             </xsl:when>
  1640.             <xsl:when test="function-available('xt:node-set')">
  1641.                 <xsl:call-template name="create-list-type">
  1642.                     <xsl:with-param name="listStyle" select="xt:node-set($listStyleRTF)" />
  1643.                     <xsl:with-param name="globalData" select="$globalData"/>
  1644.                     <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  1645.                     <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  1646.                     <xsl:with-param name="listLevel" select="$listLevel"/>
  1647.                     <xsl:with-param name="listRestart" select="$listRestart"/>
  1648.                     <xsl:with-param name="itemLabel" select="$itemLabel"/>
  1649.                     <xsl:with-param name="listStyleName" select="$listStyleName" />
  1650.                 </xsl:call-template>
  1651.             </xsl:when>
  1652.             <xsl:otherwise>
  1653.                 <xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
  1654.             </xsl:otherwise>
  1655.         </xsl:choose>
  1656.     </xsl:template>
  1657.  
  1658.     <xsl:template name="create-list-type">
  1659.         <xsl:param name="globalData"/>
  1660.         <xsl:param name="isListNumberingReset"/>
  1661.         <xsl:param name="isNextLevelNumberingReset"/>
  1662.         <xsl:param name="listLevel" />
  1663.         <xsl:param name="listRestart" />
  1664.         <xsl:param name="itemLabel"/>
  1665.         <xsl:param name="listStyle"/>
  1666.         <xsl:param name="listStyleName" />
  1667.  
  1668.         <!-- $globalData/styles-file/*/office:styles/ -->
  1669.         <xsl:variable name="listLevelStyle" select="$listStyle/*/*[@text:level = number($listLevel)]"/>
  1670.         <xsl:variable name="listIndent">
  1671.             <xsl:call-template name="getListIndent">
  1672.                 <xsl:with-param name="globalData" select="$globalData"/>
  1673.                 <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  1674.                 <xsl:with-param name="firstPara" select="*[1]/*[name() = 'text:p' or name() = 'text:h'][1]"/>
  1675.             </xsl:call-template>
  1676.         </xsl:variable>
  1677.         <xsl:variable name="isEmptyList" select="not(*[1]/*[name() = 'text:h' or name() = 'text:p' or name() = 'text:name'])"/>
  1678.         <xsl:variable name="listType">
  1679.             <xsl:choose>
  1680.                 <!-- ordered list -->
  1681.                 <xsl:when test="name($listLevelStyle) = 'text:list-level-style-number'">
  1682.                     <xsl:text>ol</xsl:text>
  1683.                 </xsl:when>
  1684.                 <!-- unordered list (bullet or image) -->
  1685.                 <xsl:otherwise>
  1686.                     <xsl:text>ul</xsl:text>
  1687.                 </xsl:otherwise>
  1688.             </xsl:choose>
  1689.         </xsl:variable>
  1690.  
  1691.         <xsl:element name="{$listType}">
  1692.             <xsl:apply-templates select="*[1]" mode="listItemSibling">
  1693.                 <xsl:with-param name="globalData" select="$globalData"/>
  1694.                 <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
  1695.                 <xsl:with-param name="isListNumberingReset" select="$isNextLevelNumberingReset"/>
  1696.                 <xsl:with-param name="isNextLevelNumberingReset">
  1697.                     <xsl:choose>
  1698.                         <xsl:when test="$isListNumberingReset">
  1699.                             <xsl:value-of select="true()"/>
  1700.                         </xsl:when>
  1701.                         <xsl:otherwise>
  1702.                             <!-- A list is empty if a text:list does not have a text:list-header or text:list-item (wildcard as only those can exist beyond a text:list), which contains a text:h or text:p -->
  1703.                             <xsl:value-of select="not($isEmptyList)"/>
  1704.                         </xsl:otherwise>
  1705.                     </xsl:choose>
  1706.                 </xsl:with-param>
  1707.                 <xsl:with-param name="itemLabel" select="$itemLabel"/>
  1708.                 <xsl:with-param name="listIndent" select="$listIndent"/>
  1709.                 <xsl:with-param name="listLevel" select="$listLevel"/>
  1710.                 <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  1711.                 <xsl:with-param name="listRestart">
  1712.                     <xsl:choose>
  1713.                         <xsl:when test="$listRestart">
  1714.                             <xsl:value-of select="$listRestart"/>
  1715.                         </xsl:when>
  1716.                         <xsl:otherwise>
  1717.                             <!-- descdendants restart their list numbering, when an ancestor is not empty -->
  1718.                             <xsl:value-of select="not($isEmptyList)"/>
  1719.                         </xsl:otherwise>
  1720.                     </xsl:choose>
  1721.                 </xsl:with-param>
  1722.                 <xsl:with-param name="listStyle" select="$listStyle"/>
  1723.                 <xsl:with-param name="listStyleName" select="$listStyleName"/>
  1724.                 <xsl:with-param name="minLabelDist">
  1725.                     <xsl:choose>
  1726.                         <xsl:when test="$listLevelStyle/*/@text:min-label-distance">
  1727.                             <xsl:call-template name="convert2cm">
  1728.                                 <xsl:with-param name="value" select="$listLevelStyle/*/@text:min-label-distance"/>
  1729.                             </xsl:call-template>
  1730.                         </xsl:when>
  1731.                         <xsl:otherwise>0</xsl:otherwise>
  1732.                     </xsl:choose>
  1733.                 </xsl:with-param>
  1734.                 <xsl:with-param name="minLabelWidth">
  1735.                     <xsl:choose>
  1736.                         <xsl:when test="$listLevelStyle/*/@text:min-label-width">
  1737.                             <xsl:call-template name="convert2cm">
  1738.                                 <xsl:with-param name="value" select="$listLevelStyle/*/@text:min-label-width"/>
  1739.                             </xsl:call-template>
  1740.                         </xsl:when>
  1741.                         <xsl:otherwise>0</xsl:otherwise>
  1742.                     </xsl:choose>
  1743.                 </xsl:with-param>
  1744.             </xsl:apply-templates>
  1745.         </xsl:element>
  1746.     </xsl:template>
  1747.  
  1748.     <!-- See comment before text:list template -->
  1749.     <xsl:template name="getListIndent">
  1750.         <xsl:param name="globalData"/>
  1751.         <xsl:param name="listLevelStyle"/>
  1752.         <!-- The first paragraph of the list item (heading is special paragraph in ODF) -->
  1753.         <xsl:param name="firstPara" />
  1754.  
  1755.         <!-- Styles of first paragraph in list item, including ancestor styles (inheritance) -->
  1756.         <xsl:variable name="firstParaStyles" select="$globalData/all-styles/style[@style:name = $firstPara/@text:style-name]/final-properties"/>
  1757.  
  1758.         <!-- Only the left margin of the first paragraph of a list item will be added to the margin of the complete list (all levels)-->
  1759.         <xsl:variable name="firstParaLeftMargin">
  1760.             <xsl:choose>
  1761.                 <xsl:when test="contains($firstParaStyles, 'margin-left:')">
  1762.                     <xsl:call-template name="convert2cm">
  1763.                         <xsl:with-param name="value" select="normalize-space(substring-before(substring-after($firstParaStyles, 'margin-left:'), ';'))"/>
  1764.                     </xsl:call-template>
  1765.                 </xsl:when>
  1766.                 <xsl:otherwise>0</xsl:otherwise>
  1767.             </xsl:choose>
  1768.         </xsl:variable>
  1769.         <xsl:variable name="spaceBefore">
  1770.             <xsl:choose>
  1771.                 <xsl:when test="$listLevelStyle/*/@text:space-before">
  1772.                     <xsl:call-template name="convert2cm">
  1773.                         <xsl:with-param name="value" select="$listLevelStyle/*/@text:space-before"/>
  1774.                     </xsl:call-template>
  1775.                 </xsl:when>
  1776.                 <xsl:otherwise>0</xsl:otherwise>
  1777.             </xsl:choose>
  1778.         </xsl:variable>
  1779.         <!-- Only if the left-margin of the first paragraph is positive the sum
  1780.         text:space-before and fo:left-margin is taken as list indent -->
  1781.         <xsl:choose>
  1782.             <xsl:when test="$firstParaLeftMargin > 0">
  1783.                 <xsl:value-of select="$firstParaLeftMargin + $spaceBefore"/>
  1784.             </xsl:when>
  1785.             <xsl:otherwise>
  1786.                 <xsl:value-of select="$spaceBefore"/>
  1787.             </xsl:otherwise>
  1788.         </xsl:choose>
  1789.     </xsl:template>
  1790.  
  1791.     <!-- ****************** -->
  1792.     <!-- *** list item  *** -->
  1793.     <!-- ****************** -->
  1794. <!--
  1795.     Left margin of the complete list:
  1796.     The space between left page and the list symbol (left-margin) is in the Office implemented by
  1797.     the sum of three values:
  1798.         1) 'text:space-before', which is part of the 'text:list-style' element.
  1799.         2) 'margin:left' from the style of the first child (e.g. paragraph).
  1800.         3) 'fo:text-indent' the indent of the first line of some child (e.g. paragraph) (applied by CSS class style)
  1801.  
  1802.     Possible list children:
  1803.     <!ELEMENT text:list-item (text:p|text:h|text:list|text:list)+>
  1804.  
  1805.     In the Office the list label before the text depends on two attributes:
  1806.         - 'text:min-label-width': the distance between list label and all text of the list item.
  1807.         - 'text:min-label-distance': the distance between list label and text of the first line,
  1808.             only used, when text does not fit in text:min-label-width (ignored)
  1809.  
  1810. -->
  1811.     <xsl:template match="text:list-item | text:list-header" mode="listItemSibling">
  1812.         <xsl:param name="globalData"/>
  1813.         <xsl:param name="firstitemLabelWidth"/>
  1814.         <xsl:param name="isEmptyList" select="not(*[name() = 'text:h' or name() = 'text:p' or name() = 'text:name'])"/>
  1815.         <xsl:param name="isListNumberingReset"/>
  1816.         <xsl:param name="isNextLevelNumberingReset"/>
  1817.         <xsl:param name="itemNumber"/>
  1818.         <xsl:param name="itemLabel"/>
  1819.         <xsl:param name="listLevel"/>
  1820.         <xsl:param name="listLevelStyle"/>
  1821.         <xsl:param name="listRestart"/>
  1822.         <xsl:param name="listStyle"/>
  1823.         <xsl:param name="listStyleName"/>
  1824.         <xsl:param name="minLabelDist"/>
  1825.         <xsl:param name="minLabelWidth"/>
  1826.         <xsl:param name="listIndent" />
  1827.  
  1828.         <!-- The text:list-header shall not be labeled. According to ODF specification (sect. 4.3.2):
  1829.         "The <text:list-header> element represents a list header and is a special kind of list item. It
  1830.         contains one or more paragraphs that are displayed before a list. The paragraphs are formatted
  1831.         like list items but they do not have a preceding number or bullet." -->
  1832.         <xsl:variable name="isListHeader" select="boolean(self::text:list-header)"/>
  1833.  
  1834.         <xsl:variable name="listIndentNew">
  1835.             <xsl:choose>
  1836.                 <xsl:when test="$listIndent">
  1837.                     <xsl:value-of select="$listIndent"/>
  1838.                 </xsl:when>
  1839.                 <xsl:otherwise>
  1840.                     <xsl:call-template name="getListIndent">
  1841.                         <xsl:with-param name="globalData" select="$globalData"/>
  1842.                         <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  1843.                         <xsl:with-param name="firstPara" select="*[name() = 'text:p' or name() = 'text:h'][1]" />
  1844.                     </xsl:call-template>
  1845.                 </xsl:otherwise>
  1846.             </xsl:choose>
  1847.         </xsl:variable>
  1848.         <xsl:variable name="itemNumberNew">
  1849.             <xsl:if test="$listStyle/text:list-style/text:list-level-style-number">
  1850.                 <xsl:choose>
  1851.                     <xsl:when test="$isListHeader">0</xsl:when>
  1852.                     <xsl:when test="$isEmptyList">
  1853.                         <!--  An empty list item (no text:h/text:p as child), will not count as item and does not increment the count.  -->
  1854.                         <xsl:variable name="tempItemNumber">
  1855.                             <xsl:choose>
  1856.                                 <!-- siblings will be incremented by one -->
  1857.                                 <xsl:when test="$itemNumber">
  1858.                                     <xsl:if test="not($isListHeader)">
  1859.                                         <xsl:value-of select="$itemNumber + 1"/>
  1860.                                     </xsl:if>
  1861.                                 </xsl:when>
  1862.                                 <!-- if a higher list level had content the numbering starts with 1 -->
  1863.                                 <xsl:when test="$isListNumberingReset and $listLevel > 1">
  1864.                                     <xsl:value-of select="1"/>
  1865.                                 </xsl:when>
  1866.                                 <xsl:otherwise>
  1867.                                     <xsl:call-template name="getItemNumber">
  1868.                                         <xsl:with-param name="listStyleName" select="$listStyleName"/>
  1869.                                         <xsl:with-param name="listLevel" select="$listLevel"/>
  1870.                                         <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  1871.                                         <xsl:with-param name="listStyle" select="$listStyle"/>
  1872.                                     </xsl:call-template>
  1873.                                 </xsl:otherwise>
  1874.                             </xsl:choose>
  1875.                         </xsl:variable>
  1876.                         <xsl:choose>
  1877.                             <!-- in case the empty list-item is the first list-item in document -->
  1878.                             <xsl:when test="$tempItemNumber = 1">
  1879.                                 <xsl:value-of select="1"/>
  1880.                             </xsl:when>
  1881.                             <xsl:otherwise>
  1882.                                 <xsl:value-of select="$tempItemNumber - 1"/>
  1883.                             </xsl:otherwise>
  1884.                         </xsl:choose>
  1885.                     </xsl:when>
  1886.                     <xsl:otherwise>
  1887.                         <xsl:choose>
  1888.                             <xsl:when test="@text:start-value">
  1889.                                 <xsl:value-of select="@text:start-value"/>
  1890.                             </xsl:when>
  1891.                             <!-- text:start-value from list level style will only be taken on the first list-item of a list -->
  1892.                             <xsl:when test="$listLevelStyle/@text:start-value and count(preceding-sibling::text:list-item) = 0">
  1893.                                 <xsl:value-of select="$listLevelStyle/@text:start-value"/>
  1894.                             </xsl:when>
  1895.                             <!-- siblings will be incremented by one -->
  1896.                             <xsl:when test="$itemNumber">
  1897.                                 <xsl:value-of select="$itemNumber + 1"/>
  1898.                             </xsl:when>
  1899.                             <!-- if a higher list level had content the numbering starts with 1 -->
  1900.                             <xsl:when test="$isListNumberingReset and $listLevel > 1">
  1901.                                 <xsl:value-of select="1"/>
  1902.                             </xsl:when>
  1903.                             <xsl:otherwise>
  1904.                                 <xsl:call-template name="getItemNumber">
  1905.                                     <xsl:with-param name="listStyleName" select="$listStyleName"/>
  1906.                                     <xsl:with-param name="listLevel" select="$listLevel"/>
  1907.                                     <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  1908.                                     <xsl:with-param name="listStyle" select="$listStyle"/>
  1909.                                 </xsl:call-template>
  1910.                             </xsl:otherwise>
  1911.                         </xsl:choose>
  1912.                     </xsl:otherwise>
  1913.                 </xsl:choose>
  1914.             </xsl:if>
  1915.         </xsl:variable>
  1916.         <xsl:variable name="itemLabelNew">
  1917.             <xsl:if test="$listStyle/text:list-style/text:list-level-style-number">
  1918.                 <!--
  1919.                     A numbered label (e.g. 2.C.III) is created for every text:list-item/header.
  1920.                     Above list levels are listed in the label, if the list-style requires this. Levels are separated by a '.'
  1921.                     Formatation is dependent for every list level depth.
  1922.                     The label is passed from anchestor text:list-item/header and if requrired truncated.
  1923.                     The prefix/suffix (as well list level dependent) comes before and after the complete label (after truncation)
  1924.                 -->
  1925.                 <!-- Numbered label will be generated  -->
  1926.                 <xsl:call-template name="createItemLabel">
  1927.                     <xsl:with-param name="itemNumber" select="$itemNumberNew"/>
  1928.                     <xsl:with-param name="itemLabel" select="$itemLabel"/>
  1929.                     <xsl:with-param name="listLevelsToDisplay">
  1930.                         <xsl:variable name="display" select="$listLevelStyle/@text:display-levels"/>
  1931.                         <xsl:choose>
  1932.                             <xsl:when test="$display">
  1933.                                 <xsl:value-of select="$display"/>
  1934.                             </xsl:when>
  1935.                             <xsl:when test="$isListHeader">0</xsl:when>
  1936.                             <xsl:otherwise>1</xsl:otherwise>
  1937.                         </xsl:choose>
  1938.                     </xsl:with-param>
  1939.                     <xsl:with-param name="listLevel" select="$listLevel"/>
  1940.                     <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  1941.                 </xsl:call-template>
  1942.             </xsl:if>
  1943.         </xsl:variable>
  1944.         <xsl:element name="li">
  1945.             <xsl:choose>
  1946.                 <xsl:when test="$isEmptyList or $isListHeader">
  1947.                     <xsl:apply-templates>
  1948.                         <xsl:with-param name="globalData" select="$globalData"/>
  1949.                         <xsl:with-param name="itemLabel" select="$itemLabelNew"/>
  1950.                         <xsl:with-param name="listLevel" select="$listLevel + 1"/>
  1951.                         <xsl:with-param name="listStyleName" select="$listStyleName"/>
  1952.                     </xsl:apply-templates>
  1953.                 </xsl:when>
  1954.                 <xsl:otherwise>
  1955.                     <!-- Possible following children are text:h, text:p, list:text, text:soft-page-break -->
  1956.                     <xsl:apply-templates mode="list-item-children" select="*[1]">
  1957.                         <xsl:with-param name="globalData" select="$globalData"/>
  1958.                         <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
  1959.                         <xsl:with-param name="isNextLevelNumberingReset" select="$isListHeader or $isNextLevelNumberingReset"/>
  1960.                         <!-- The new created label is given to the children -->
  1961.                         <xsl:with-param name="itemLabel" select="$itemLabelNew"/>
  1962.                         <xsl:with-param name="listLabelElement">
  1963.                             <xsl:choose>
  1964.                                 <xsl:when test="name() = 'text:list-header'"/>
  1965.                                 <xsl:otherwise>
  1966.                                     <xsl:variable name="listLabelWidth">
  1967.                                         <xsl:choose>
  1968.                                             <xsl:when test="$minLabelWidth > $minLabelDist">
  1969.                                                 <xsl:value-of select="$minLabelWidth"/>
  1970.                                             </xsl:when>
  1971.                                             <xsl:otherwise>
  1972.                                                 <xsl:value-of select="$minLabelDist"/>
  1973.                                             </xsl:otherwise>
  1974.                                         </xsl:choose>
  1975.                                     </xsl:variable>
  1976.                                     <!-- Numbering is being done by this transformation creating a HTML span representing the number label
  1977.                                          The html:span represents the list item/header label (e.g. 1.A.III)
  1978.                                          As the html:span is usually a inline element is formated by CSS as block element to use width upon it,
  1979.                                          to disable the caridge return float:left is used and later neglected -->
  1980.                                     <xsl:element name="span">
  1981.                                         <xsl:if test="$listLevelStyle/@text:style-name">
  1982.                                             <xsl:attribute name="class">
  1983.                                                 <xsl:value-of select="$listLevelStyle/@text:style-name"/>
  1984.                                             </xsl:attribute>
  1985.                                         </xsl:if>
  1986.                                         <xsl:attribute name="style">
  1987.                                             <xsl:text>display:block;float:</xsl:text>
  1988.                                             <!-- 2DO: Svante - copy this functionality for other used margin:left (in western country 'left') -->
  1989.                                             <xsl:call-template name="getOppositeWritingDirection">
  1990.                                                 <xsl:with-param name="globalData" select="$globalData"/>
  1991.                                                 <xsl:with-param name="paraStyleName" select="descendant-or-self::*/@text:style-name"/>
  1992.                                             </xsl:call-template>
  1993.                                             <xsl:text>;min-width:</xsl:text>
  1994.                                             <xsl:value-of select="$listLabelWidth"/>
  1995.                                             <xsl:text>cm</xsl:text>
  1996.                                         </xsl:attribute>
  1997.                                         <xsl:variable name="labelContent">
  1998.                                             <xsl:choose>
  1999.                                                 <xsl:when test="text:number">
  2000.                                                     <xsl:apply-templates select="text:number" mode="listnumber"/>
  2001.                                                 </xsl:when>
  2002.                                                 <xsl:when test="name($listLevelStyle) = 'text:list-level-style-bullet'">
  2003.                                                     <xsl:value-of select="$listLevelStyle/@style:num-prefix"/>
  2004.                                                     <xsl:value-of select="$listLevelStyle/@text:bullet-char"/>
  2005.                                                     <xsl:value-of select="$listLevelStyle/@style:num-suffix"/>
  2006.                                                 </xsl:when>
  2007.                                                 <xsl:when test="name($listLevelStyle) = 'text:list-level-style-number'">
  2008.                                                     <xsl:value-of select="$listLevelStyle/@style:num-prefix"/>
  2009.                                                     <xsl:value-of select="$itemLabelNew"/>
  2010.                                                     <xsl:value-of select="$listLevelStyle/@style:num-suffix"/>
  2011.                                                 </xsl:when>
  2012.                                                 <xsl:otherwise>
  2013.                                                 <!-- Listing with image as bullets, taken from the list style's href -->
  2014.                                                     <xsl:value-of select="$listLevelStyle/@xlink:href"/>
  2015.                                                 </xsl:otherwise>
  2016.                                             </xsl:choose>
  2017.                                         </xsl:variable>
  2018.                                         <!-- Some browsers have problem with stand-alone elements (e.g. <span/>)
  2019.                                             Therefore a comment is being inserted into an empty label -->
  2020.                                         <xsl:choose>
  2021.                                             <xsl:when test="$labelContent != ''">
  2022.                                                 <xsl:value-of select="$labelContent"/>
  2023.                                             </xsl:when>
  2024.                                             <xsl:otherwise>
  2025.                                                 <xsl:comment> </xsl:comment>
  2026.                                             </xsl:otherwise>
  2027.                                         </xsl:choose>
  2028.                                     </xsl:element>
  2029.                                 </xsl:otherwise>
  2030.                             </xsl:choose>
  2031.                         </xsl:with-param>
  2032.                         <xsl:with-param name="listLabelEmptyElement">
  2033.                             <xsl:variable name="listLabelWidth">
  2034.                                 <xsl:choose>
  2035.                                     <xsl:when test="$minLabelWidth > $minLabelDist">
  2036.                                         <xsl:value-of select="$minLabelWidth"/>
  2037.                                     </xsl:when>
  2038.                                     <xsl:otherwise>
  2039.                                         <xsl:value-of select="$minLabelDist"/>
  2040.                                     </xsl:otherwise>
  2041.                                 </xsl:choose>
  2042.                             </xsl:variable>
  2043.                             <xsl:element name="span">
  2044.                                 <xsl:if test="$listLevelStyle/@text:style-name">
  2045.                                     <xsl:attribute name="class">
  2046.                                         <xsl:value-of select="$listLevelStyle/@text:style-name"/>
  2047.                                     </xsl:attribute>
  2048.                                 </xsl:if>
  2049.                                 <xsl:attribute name="style">
  2050.                                     <xsl:text>display:block;float:</xsl:text>
  2051.                                     <xsl:call-template name="getOppositeWritingDirection">
  2052.                                         <xsl:with-param name="globalData" select="$globalData"/>
  2053.                                         <xsl:with-param name="paraStyleName" select="descendant-or-self::*/@text:style-name"/>
  2054.                                     </xsl:call-template>
  2055.                                     <xsl:text>;min-width:</xsl:text>
  2056.                                     <xsl:value-of select="$listLabelWidth"/>
  2057.                                     <xsl:text>cm</xsl:text>
  2058.                                 </xsl:attribute>
  2059.                                 <xsl:comment> </xsl:comment>
  2060.                             </xsl:element>
  2061.                         </xsl:with-param>
  2062.                         <xsl:with-param name="listLevel" select="$listLevel + 1"/>
  2063.                         <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2064.                         <xsl:with-param name="listRestart" select="$listRestart"/>
  2065.                         <xsl:with-param name="listStyle" select="$listStyle"/>
  2066.                         <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2067.                         <xsl:with-param name="listIndent" select="$listIndentNew"/>
  2068.                         <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
  2069.                     </xsl:apply-templates>
  2070.                 </xsl:otherwise>
  2071.             </xsl:choose>
  2072.         </xsl:element>
  2073.         <xsl:apply-templates select="following-sibling::*[1]" mode="listItemSibling">
  2074.             <xsl:with-param name="globalData" select="$globalData"/>
  2075.             <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  2076.             <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  2077.             <xsl:with-param name="itemNumber" select="$itemNumberNew"/>
  2078.             <xsl:with-param name="listIndent">
  2079.                 <xsl:choose>
  2080.                     <xsl:when test="not($isEmptyList)">
  2081.                         <xsl:value-of select="$listIndentNew"/>
  2082.                     </xsl:when>
  2083.                 </xsl:choose>
  2084.             </xsl:with-param>
  2085.             <!-- Receives the same parent label -->
  2086.             <xsl:with-param name="itemLabel" select="$itemLabel"/>
  2087.             <xsl:with-param name="listLevel" select="$listLevel"/>
  2088.             <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2089.             <xsl:with-param name="listStyle" select="$listStyle"/>
  2090.             <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2091.             <xsl:with-param name="minLabelDist" select="$minLabelDist"/>
  2092.             <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
  2093.         </xsl:apply-templates>
  2094.     </xsl:template>
  2095.  
  2096.     <xsl:template name="getOppositeWritingDirection">
  2097.         <xsl:param name="globalData"/>
  2098.         <xsl:param name="paraStyleName"/>
  2099.  
  2100.         <xsl:variable name="imageParagraphStyle" select="$globalData/all-styles/style[@style:name = $paraStyleName]/final-properties"/>
  2101.  
  2102.         <xsl:choose>
  2103.             <xsl:when test="contains($imageParagraphStyle, 'writing-mode:')">
  2104.                 <xsl:choose>
  2105.                     <xsl:when test="contains(substring-before(substring-after($imageParagraphStyle, 'writing-mode:'), ';'), 'rl')">right</xsl:when>
  2106.                     <xsl:otherwise>left</xsl:otherwise>
  2107.                 </xsl:choose>
  2108.             </xsl:when>
  2109.             <xsl:otherwise>left</xsl:otherwise>
  2110.         </xsl:choose>
  2111.     </xsl:template>
  2112.  
  2113.     <xsl:template match="text:number" mode="listnumber">
  2114.         <xsl:apply-templates/>
  2115.     </xsl:template>
  2116.  
  2117.     <xsl:template match="text:number" mode="list-item-children">
  2118.         <xsl:param name="globalData"/>
  2119.         <xsl:param name="listLabelElement"/>
  2120.         <xsl:param name="listLabelEmptyElement"/>
  2121.         <xsl:param name="isEmptyList"/>
  2122.         <xsl:param name="isListNumberingReset"/>
  2123.         <xsl:param name="isNextLevelNumberingReset"/>
  2124.         <xsl:param name="itemLabel"/>
  2125.         <xsl:param name="itemNumber"/>
  2126.         <xsl:param name="listIndent"/>
  2127.         <xsl:param name="listLevel"/>
  2128.         <xsl:param name="listLevelStyle" />
  2129.         <xsl:param name="listRestart"/>
  2130.         <xsl:param name="listStyle"/>
  2131.         <xsl:param name="listStyleName"/>
  2132.         <xsl:param name="minLabelWidth"/>
  2133.  
  2134.         <xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
  2135.             <xsl:with-param name="globalData" select="$globalData"/>
  2136.             <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
  2137.             <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  2138.             <xsl:with-param name="itemLabel" select="$itemLabel"/>
  2139.             <xsl:with-param name="listLabelElement" select="$listLabelElement"/>
  2140.             <xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
  2141.             <xsl:with-param name="listLevel" select="$listLevel"/>
  2142.             <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2143.             <xsl:with-param name="listRestart" select="$listRestart"/>
  2144.             <xsl:with-param name="listStyle" select="$listStyle"/>
  2145.             <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2146.             <xsl:with-param name="listIndent" select="$listIndent"/>
  2147.             <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
  2148.         </xsl:apply-templates>
  2149.     </xsl:template>
  2150.  
  2151.     <!-- Each key element holds the set of all text:list-item/text:list-header of a certain level and a certain style -->
  2152.     <xsl:key name="getListItemsByLevelAndStyle" use="concat(count(ancestor::text:list), ancestor::text:list/@text:style-name)" match="text:list-item | text:list-header"/>
  2153.     <!-- Each key element holds the set of all text:list-item/text:list-header of a certain style -->
  2154.     <xsl:key name="getListItemsByStyle" use="ancestor::text:list/@text:style-name" match="text:list-item | text:list-header"/>
  2155.  
  2156.  
  2157.     <!-- The Numbering start value (or offset from regular counteing) is used at the first item of offset,
  2158.     but have to be reused on following items with no text:start-value -->
  2159.     <xsl:template name="getItemNumber">
  2160.         <xsl:param name="listLevel"/>
  2161.         <xsl:param name="listLevelStyle"/>
  2162.         <xsl:param name="listStyleName"/>
  2163.         <xsl:param name="listStyle"/>
  2164.  
  2165.         <xsl:call-template name="countListItemTillStartValue">
  2166.             <xsl:with-param name="listLevel" select="$listLevel"/>
  2167.             <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2168.             <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2169.             <xsl:with-param name="listStyle" select="$listStyle"/>
  2170.             <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="preceding::text:list-item[generate-id(key('getListItemsByLevelAndStyle', concat($listLevel, $listStyleName))) = generate-id(key('getListItemsByLevelAndStyle', concat(count(ancestor::text:list), ancestor::text:list/@text:style-name)))]"/>
  2171.  
  2172.             <xsl:with-param name="precedingListItemsOfSameStyle" select="preceding::text:list-item[generate-id(key('getListItemsByStyle', $listStyleName)) = generate-id(key('getListItemsByStyle', ancestor::text:list/@text:style-name))]"/>
  2173.         </xsl:call-template>
  2174.     </xsl:template>
  2175.  
  2176.     <!-- When there is a text:start-value the last have to be found and added to the number -->
  2177.     <xsl:template name="countListItemTillStartValue">
  2178.         <xsl:param name="IteratorSameLevelAndStyle" select="1"/>
  2179.         <xsl:param name="IteratorSameStyle" select="1"/>
  2180.         <xsl:param name="itemNumber" select="1"/>
  2181.         <xsl:param name="listLevel"/>
  2182.         <xsl:param name="listLevelStyle"/>
  2183.         <xsl:param name="listStyle"/>
  2184.         <xsl:param name="listStyleName"/>
  2185.         <xsl:param name="precedingListItemsOfSameLevelAndStyle" />
  2186.         <xsl:param name="precedingListItemsOfSameLevelAndStyleCount" select="count($precedingListItemsOfSameLevelAndStyle)"/>
  2187.         <xsl:param name="precedingListItemsOfSameStyle" />
  2188.         <xsl:param name="precedingListItemsOfSameStyleCount" select="count($precedingListItemsOfSameStyle)"/>
  2189.         <!-- E.g.: If a list level 2 number is searched, a level 3 with content found with only a level 1 parent with content,
  2190.             the level 3 gets a 'pseudoLevel' -->
  2191.         <xsl:param name="pseudoLevel" select="0" />
  2192.  
  2193.         <xsl:variable name="isListHeader" select="boolean(self::text:list-header)"/>
  2194.         <xsl:variable name="isEmptyList" select="not(*[name() = 'text:h' or name() = 'text:p'])"/>
  2195.  
  2196.         <!-- set the next of preceding list items. Starting from the current to the next previous text:list-item -->
  2197.         <xsl:variable name="precedingListItemOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle[$precedingListItemsOfSameLevelAndStyleCount - $IteratorSameLevelAndStyle + 1]"/>
  2198.         <xsl:variable name="precedingListItemOfSameStyle" select="$precedingListItemsOfSameStyle[$precedingListItemsOfSameStyleCount - $IteratorSameStyle + 1]"/>
  2199.         <xsl:choose>
  2200.             <xsl:when test="($precedingListItemOfSameStyle and $precedingListItemOfSameLevelAndStyle) or ($precedingListItemOfSameStyle and $listStyle/text:list-style/@text:consecutive-numbering)">
  2201.                 <xsl:for-each select="$precedingListItemOfSameStyle">
  2202.                     <xsl:choose>
  2203.                         <!-- if it is a higher list level element  -->
  2204.                         <xsl:when test="$listStyle/text:list-style/@text:consecutive-numbering">
  2205.  
  2206.                             <xsl:call-template name="countListItem">
  2207.                                 <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
  2208.                                 <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle"/>
  2209.                                 <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2210.                                 <xsl:with-param name="listLevel" select="$listLevel"/>
  2211.                                 <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2212.                                 <xsl:with-param name="listStyle" select="$listStyle"/>
  2213.                                 <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
  2214.                                 <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
  2215.                                 <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
  2216.                                 <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
  2217.                                 <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
  2218.                             </xsl:call-template>
  2219.                         </xsl:when>
  2220.                         <xsl:otherwise>
  2221.                             <!-- NOT CONSECUTIVE NUMBERING -->
  2222.                             <xsl:variable name="currentListLevel" select="count(ancestor::text:list)"/>
  2223.                             <xsl:choose>
  2224.                                 <!-- IF IT IS A HIGHER LIST LEVEL ELEMENT -->
  2225.                                 <xsl:when test="$currentListLevel < $listLevel">
  2226.                                     <xsl:choose>
  2227.                                         <!-- if it has content the counting is ended -->
  2228.                                         <xsl:when test="*[name() = 'text:h' or name() = 'text:p'] or $isListHeader">
  2229.                                             <!-- 2DO: Perhaps the children still have to be processed -->
  2230.                                             <xsl:value-of select="$itemNumber + $pseudoLevel"/>
  2231.                                         </xsl:when>
  2232.                                         <xsl:otherwise>
  2233.                                         <!-- if it is empty the counting continues -->
  2234.                                             <xsl:call-template name="countListItemTillStartValue">
  2235.                                                 <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
  2236.                                                 <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
  2237.                                                 <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2238.                                                 <xsl:with-param name="listLevel" select="$listLevel"/>
  2239.                                                 <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2240.                                                 <xsl:with-param name="listStyle" select="$listStyle"/>
  2241.                                                 <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
  2242.                                                 <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
  2243.                                                 <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
  2244.                                                 <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
  2245.                                                 <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
  2246.                                             </xsl:call-template>
  2247.                                         </xsl:otherwise>
  2248.                                     </xsl:choose>
  2249.                                 </xsl:when>
  2250.                                 <!-- IF IT IS A LIST LEVEL ELEMENT OF THE COUNTING LEVEL -->
  2251.                                 <xsl:when test="$currentListLevel = $listLevel">
  2252.                                     <xsl:call-template name="countListItem">
  2253.                                         <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
  2254.                                         <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle"/>
  2255.                                         <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2256.                                         <xsl:with-param name="listLevel" select="$listLevel"/>
  2257.                                         <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2258.                                         <xsl:with-param name="listStyle" select="$listStyle"/>
  2259.                                         <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
  2260.                                         <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
  2261.                                         <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
  2262.                                         <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
  2263.                                         <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
  2264.                                     </xsl:call-template>
  2265.                                 </xsl:when>
  2266.                                 <xsl:otherwise>
  2267.                                     <!-- list item below the current level does not count -->
  2268.                                     <xsl:call-template name="countListItemTillStartValue">
  2269.                                         <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
  2270.                                         <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
  2271.                                         <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2272.                                         <xsl:with-param name="listLevel" select="$listLevel"/>
  2273.                                         <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2274.                                         <xsl:with-param name="listStyle" select="$listStyle"/>
  2275.                                         <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2276.                                         <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
  2277.                                         <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
  2278.                                         <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
  2279.                                         <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
  2280.                                         <xsl:with-param name="pseudoLevel">
  2281.                                             <xsl:choose>
  2282.                                                 <!-- empty list item does not count -->
  2283.                                                 <xsl:when test="not(*[name() = 'text:h' or name() = 'text:p']) or $isListHeader">
  2284.                                                     <xsl:value-of select="$pseudoLevel"/>
  2285.                                                 </xsl:when>
  2286.                                                 <xsl:otherwise>1</xsl:otherwise>
  2287.                                             </xsl:choose>
  2288.                                         </xsl:with-param>
  2289.                                     </xsl:call-template>
  2290.                                 </xsl:otherwise>
  2291.                             </xsl:choose>
  2292.                         </xsl:otherwise>
  2293.                     </xsl:choose>
  2294.                 </xsl:for-each>
  2295.             </xsl:when>
  2296.             <xsl:otherwise>
  2297.                 <xsl:value-of select="$itemNumber"/>
  2298.             </xsl:otherwise>
  2299.         </xsl:choose>
  2300.     </xsl:template>
  2301.  
  2302.     <xsl:template name="countListItem">
  2303.         <xsl:param name="IteratorSameLevelAndStyle"/>
  2304.         <xsl:param name="IteratorSameStyle"/>
  2305.         <xsl:param name="itemNumber"/>
  2306.         <xsl:param name="listLevel"/>
  2307.         <xsl:param name="listLevelStyle"/>
  2308.         <xsl:param name="listStyle"/>
  2309.         <xsl:param name="listStyleName"/>
  2310.         <xsl:param name="precedingListItemsOfSameLevelAndStyle"/>
  2311.         <xsl:param name="precedingListItemsOfSameLevelAndStyleCount"/>
  2312.         <xsl:param name="precedingListItemsOfSameStyle"/>
  2313.         <xsl:param name="precedingListItemsOfSameStyleCount"/>
  2314.         <xsl:param name="pseudoLevel" />
  2315.  
  2316.         <xsl:variable name="isListHeader" select="boolean(self::text:list-header)"/>
  2317.         <xsl:variable name="isEmptyList" select="not(*[name() = 'text:h' or name() = 'text:p'])"/>
  2318.  
  2319.         <xsl:choose>
  2320.             <xsl:when test="@text:start-value">
  2321.                 <xsl:choose>
  2322.                     <xsl:when test="$isEmptyList or $isListHeader">
  2323.                         <!-- empty list item does not count. neither does list header -->
  2324.                         <xsl:call-template name="countListItemTillStartValue">
  2325.                             <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
  2326.                             <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
  2327.                             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2328.                             <xsl:with-param name="listLevel" select="$listLevel"/>
  2329.                             <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2330.                             <xsl:with-param name="listStyle" select="$listStyle"/>
  2331.                             <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
  2332.                             <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
  2333.                             <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
  2334.                             <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
  2335.                             <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
  2336.                         </xsl:call-template>
  2337.                     </xsl:when>
  2338.                     <xsl:otherwise>
  2339.                         <xsl:value-of select="$itemNumber + @text:start-value"/>
  2340.                     </xsl:otherwise>
  2341.                 </xsl:choose>
  2342.             </xsl:when>
  2343.             <xsl:when test="$listLevelStyle/@text:start-value">
  2344.                 <xsl:choose>
  2345.                     <xsl:when test="$isEmptyList or $isListHeader">
  2346.                         <!-- empty list item does not count. neither does list header -->
  2347.                         <xsl:call-template name="countListItemTillStartValue">
  2348.                             <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
  2349.                             <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
  2350.                             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2351.                             <xsl:with-param name="listLevel" select="$listLevel"/>
  2352.                             <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2353.                             <xsl:with-param name="listStyle" select="$listStyle"/>
  2354.                             <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
  2355.                             <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
  2356.                             <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
  2357.                             <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
  2358.                             <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
  2359.                         </xsl:call-template>
  2360.                     </xsl:when>
  2361.                     <xsl:otherwise>
  2362.                         <xsl:value-of select="$itemNumber + $listLevelStyle/@text:start-value"/>
  2363.                     </xsl:otherwise>
  2364.                 </xsl:choose>
  2365.             </xsl:when>
  2366.             <xsl:otherwise>
  2367.                 <xsl:choose>
  2368.                     <xsl:when test="$isEmptyList or $isListHeader">
  2369.                         <!-- empty list item does not count. neither does list header -->
  2370.                         <xsl:call-template name="countListItemTillStartValue">
  2371.                             <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
  2372.                             <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
  2373.                             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2374.                             <xsl:with-param name="listLevel" select="$listLevel"/>
  2375.                             <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2376.                             <xsl:with-param name="listStyle" select="$listStyle"/>
  2377.                             <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
  2378.                             <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
  2379.                             <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
  2380.                             <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
  2381.                             <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
  2382.                         </xsl:call-template>
  2383.                     </xsl:when>
  2384.                     <xsl:otherwise>
  2385.                         <!-- count on till you find a start-value or the end is reached -->
  2386.                         <xsl:call-template name="countListItemTillStartValue">
  2387.                             <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
  2388.                             <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
  2389.                             <xsl:with-param name="itemNumber" select="$itemNumber + 1"/>
  2390.                             <xsl:with-param name="listLevel" select="$listLevel"/>
  2391.                             <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2392.                             <xsl:with-param name="listStyle" select="$listStyle"/>
  2393.                             <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
  2394.                             <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
  2395.                             <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
  2396.                             <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
  2397.                             <xsl:with-param name="pseudoLevel" select="0" />
  2398.                         </xsl:call-template>
  2399.                     </xsl:otherwise>
  2400.                 </xsl:choose>
  2401.             </xsl:otherwise>
  2402.         </xsl:choose>
  2403.     </xsl:template>
  2404.  
  2405.  
  2406.     <!-- Creates the list label containing the number, which is separated by '.' between the levels.
  2407.         Depending on the levels to display (listLevelsToDisplay) -->
  2408.     <xsl:template name="createItemLabel">
  2409.         <xsl:param name="itemLabel" select="''"/>
  2410.         <xsl:param name="itemNumber" />
  2411.         <xsl:param name="listLevel" />
  2412.         <xsl:param name="listLevelStyle" />
  2413.         <xsl:param name="listLevelsToDisplay" />
  2414.  
  2415.         <xsl:choose>
  2416.             <xsl:when test="$listLevelsToDisplay < $listLevel">
  2417.                 <xsl:call-template name="truncLabel">
  2418.                     <xsl:with-param name="itemLabel" select="$itemLabel"/>
  2419.                     <xsl:with-param name="itemNumber" select="$itemNumber" />
  2420.                     <xsl:with-param name="listLevel" select="$listLevel"/>
  2421.                     <xsl:with-param name="listLevelStyle" select="$listLevelStyle" />
  2422.                     <xsl:with-param name="listLevelsToDisplay" select="$listLevelsToDisplay"/>
  2423.                 </xsl:call-template>
  2424.             </xsl:when>
  2425.             <xsl:otherwise>
  2426.                 <xsl:variable name="numberedSymbol">
  2427.                     <xsl:comment> </xsl:comment>
  2428.                     <!-- only give out a number when number format is not empty -->
  2429.                     <xsl:if test="$listLevelStyle/@style:num-format != ''">
  2430.                         <xsl:number value="$itemNumber" format="{$listLevelStyle/@style:num-format}"/>
  2431.                     </xsl:if>
  2432.                 </xsl:variable>
  2433.                 <xsl:choose>
  2434.                     <xsl:when test="$listLevelsToDisplay != 1">
  2435.                         <xsl:value-of select="concat($itemLabel, '.' , $numberedSymbol)"/>
  2436.                     </xsl:when>
  2437.                     <xsl:otherwise>
  2438.                         <xsl:value-of select="$numberedSymbol"/>
  2439.                     </xsl:otherwise>
  2440.                 </xsl:choose>
  2441.             </xsl:otherwise>
  2442.         </xsl:choose>
  2443.     </xsl:template>
  2444.  
  2445.     <xsl:template name="truncLabel">
  2446.         <xsl:param name="itemLabel" />
  2447.         <xsl:param name="itemNumber" />
  2448.         <xsl:param name="listLevel" />
  2449.         <xsl:param name="listLevelStyle" />
  2450.         <xsl:param name="listLevelsToDisplay" />
  2451.         <xsl:param name="listStyle" />
  2452.         <xsl:param name="listStyleName" />
  2453.  
  2454.         <xsl:call-template name="createItemLabel">
  2455.             <xsl:with-param name="itemLabel">
  2456.                 <xsl:if test="contains($itemLabel, '.')">
  2457.                     <xsl:value-of select="substring-after($itemLabel, '.')"/>
  2458.                 </xsl:if>
  2459.             </xsl:with-param>
  2460.             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2461.             <xsl:with-param name="listLevel" select="$listLevel - 1"/>
  2462.             <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
  2463.             <xsl:with-param name="listLevelsToDisplay" select="$listLevelsToDisplay"/>
  2464.         </xsl:call-template>
  2465.     </xsl:template>
  2466.  
  2467.  
  2468.     <xsl:template match="text:p" mode="list-item-children">
  2469.         <xsl:param name="globalData"/>
  2470.         <xsl:param name="listLabelElement"/>
  2471.         <xsl:param name="listLabelEmptyElement"/>
  2472.         <xsl:param name="isEmptyList"/>
  2473.         <xsl:param name="isListNumberingReset"/>
  2474.         <xsl:param name="isNextLevelNumberingReset"/>
  2475.         <xsl:param name="itemLabel"/>
  2476.         <xsl:param name="itemNumber"/>
  2477.         <xsl:param name="listIndent"/>
  2478.         <xsl:param name="listLevel"/>
  2479.         <xsl:param name="listRestart"/>
  2480.         <xsl:param name="listStyle"/>
  2481.         <xsl:param name="listStyleName"/>
  2482.         <xsl:param name="minLabelWidth"/>
  2483.  
  2484.         <!-- 2DO page alignment fix - PART1 -->
  2485.  
  2486.         <!-- xhtml:p may only contain inline elements.
  2487.              If there is one frame beyond, div must be used! -->
  2488.         <xsl:variable name="elementName">
  2489.             <xsl:choose>
  2490.                 <xsl:when test="descendant::draw:frame[1] or descendant::text:p[1]">div</xsl:when>
  2491.                 <xsl:otherwise>p</xsl:otherwise>
  2492.             </xsl:choose>
  2493.         </xsl:variable>
  2494.         <xsl:element name="{$elementName}">
  2495.             <xsl:call-template name="create-list-style">
  2496.                 <xsl:with-param name="globalData" select="$globalData"/>
  2497.                 <xsl:with-param name="listIndent" select="$listIndent"/>
  2498.                 <xsl:with-param name="styleName" select="@text:style-name"/>
  2499.             </xsl:call-template>
  2500.             <xsl:choose>
  2501.                 <xsl:when test="$listLabelElement">
  2502.                     <xsl:copy-of select="$listLabelElement"/>
  2503.                 </xsl:when>
  2504.                 <xsl:otherwise>
  2505.                     <xsl:copy-of select="$listLabelEmptyElement"/>
  2506.                 </xsl:otherwise>
  2507.             </xsl:choose>
  2508.             <xsl:apply-templates>
  2509.                 <xsl:with-param name="globalData" select="$globalData"/>
  2510.                 <xsl:with-param name="listIndent" select="$minLabelWidth"/>
  2511.             </xsl:apply-templates>
  2512.             <!-- this span disables the float necessary to bring two block elements on one line. It contains a space as IE6 bug workaround -->
  2513.             <span class="odfLiEnd"></span>
  2514.             <xsl:text> </xsl:text>
  2515.         </xsl:element>
  2516.  
  2517.         <xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
  2518.             <xsl:with-param name="globalData" select="$globalData"/>
  2519.             <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
  2520.             <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  2521.             <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  2522.             <xsl:with-param name="itemLabel" select="$itemLabel"/>
  2523.             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2524.             <xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
  2525.             <xsl:with-param name="listLevel" select="$listLevel"/>
  2526.             <xsl:with-param name="listRestart" select="$listRestart"/>
  2527.             <xsl:with-param name="listStyle" select="$listStyle"/>
  2528.             <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2529.             <xsl:with-param name="listIndent" select="$listIndent"/>
  2530.             <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
  2531.         </xsl:apply-templates>
  2532.     </xsl:template>
  2533.  
  2534.  
  2535.     <!-- Neglecting the left margin behavior for headings for now -->
  2536.     <xsl:template match="text:h" mode="list-item-children">
  2537.         <xsl:param name="globalData"/>
  2538.         <xsl:param name="listLabelElement"/>
  2539.         <xsl:param name="listLabelEmptyElement"/>
  2540.         <xsl:param name="isEmptyList"/>
  2541.         <xsl:param name="isListNumberingReset"/>
  2542.         <xsl:param name="isNextLevelNumberingReset"/>
  2543.         <xsl:param name="itemLabel"/>
  2544.         <xsl:param name="itemNumber"/>
  2545.         <xsl:param name="listIndent"/>
  2546.         <xsl:param name="listLevel"/>
  2547.         <xsl:param name="listRestart"/>
  2548.         <xsl:param name="listStyle"/>
  2549.         <xsl:param name="listStyleName"/>
  2550.         <xsl:param name="minLabelWidth"/>
  2551.  
  2552.         <xsl:element name="h">
  2553.             <xsl:call-template name="create-list-style">
  2554.                 <xsl:with-param name="globalData" select="$globalData"/>
  2555.                 <xsl:with-param name="listIndent" select="$listIndent"/>
  2556.                 <xsl:with-param name="styleName" select="@text:style-name"/>
  2557.             </xsl:call-template>
  2558.             <xsl:variable name="title">
  2559.                 <xsl:apply-templates mode="concatenate"/>
  2560.             </xsl:variable>
  2561.             <xsl:choose>
  2562.                 <xsl:when test="$listLabelElement">
  2563.                     <xsl:copy-of select="$listLabelElement"/>
  2564.                 </xsl:when>
  2565.                 <xsl:otherwise>
  2566.                     <xsl:copy-of select="$listLabelEmptyElement"/>
  2567.                 </xsl:otherwise>
  2568.             </xsl:choose>
  2569.  
  2570.             <!-- REFERENCE HANDLING - ANCHOR -->
  2571.             <xsl:element namespace="{$namespace}" name="a">
  2572.                 <xsl:attribute name="id">
  2573.                     <xsl:value-of select="translate(concat('a_',$listLabelElement, '_', normalize-space($title)), ' &<>.,;: %()[]/\+', '___________________________')"/>
  2574.                 </xsl:attribute>
  2575.                 <xsl:apply-templates>
  2576.                     <xsl:with-param name="globalData" select="$globalData"/>
  2577.                     <xsl:with-param name="listIndent" select="$minLabelWidth"/>
  2578.                 </xsl:apply-templates>
  2579.             </xsl:element>
  2580.  
  2581.             <!-- this span disables the float necessary to bring two block elements on one line. It contains a space as IE6 bug workaround -->
  2582.             <span class="odfLiEnd"></span>
  2583.             <xsl:text> </xsl:text>
  2584.         </xsl:element>
  2585.  
  2586.         <xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
  2587.             <xsl:with-param name="globalData" select="$globalData"/>
  2588.             <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
  2589.             <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  2590.             <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  2591.             <xsl:with-param name="itemLabel" select="$itemLabel"/>
  2592.             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2593.             <xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
  2594.             <xsl:with-param name="listLevel" select="$listLevel"/>
  2595.             <xsl:with-param name="listRestart" select="$listRestart"/>
  2596.             <xsl:with-param name="listStyle" select="$listStyle"/>
  2597.             <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2598.             <xsl:with-param name="listIndent" select="$listIndent"/>
  2599.             <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
  2600.         </xsl:apply-templates>
  2601.     </xsl:template>
  2602.  
  2603.  
  2604.     <xsl:template match="*" mode="list-item-children">
  2605.         <xsl:param name="globalData"/>
  2606.         <xsl:param name="isEmptyList"/>
  2607.         <xsl:param name="listLabelEmptyElement"/>
  2608.         <xsl:param name="isListNumberingReset"/>
  2609.         <xsl:param name="isNextLevelNumberingReset"/>
  2610.         <xsl:param name="itemLabel"/>
  2611.         <xsl:param name="itemNumber"/>
  2612.         <xsl:param name="listIndent"/>
  2613.         <xsl:param name="listLevel"/>
  2614.         <xsl:param name="listRestart"/>
  2615.         <xsl:param name="listStyle"/>
  2616.         <xsl:param name="listStyleName"/>
  2617.         <xsl:param name="minLabelWidth"/>
  2618.  
  2619.         <xsl:apply-templates select="self::*">
  2620.             <xsl:with-param name="globalData" select="$globalData"/>
  2621.             <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
  2622.             <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  2623.             <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  2624.             <xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
  2625.             <xsl:with-param name="itemLabel" select="$itemLabel"/>
  2626.             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2627.             <xsl:with-param name="listIndent" select="$listIndent"/>
  2628.             <xsl:with-param name="listLevel" select="$listLevel"/>
  2629.             <xsl:with-param name="listRestart" select="$listRestart"/>
  2630.             <xsl:with-param name="listStyle" select="$listStyle"/>
  2631.             <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2632.         </xsl:apply-templates>
  2633.  
  2634.         <xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
  2635.             <xsl:with-param name="globalData" select="$globalData"/>
  2636.             <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
  2637.             <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  2638.             <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  2639.             <xsl:with-param name="itemLabel" select="$itemLabel"/>
  2640.             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2641.             <xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
  2642.             <xsl:with-param name="listLevel" select="$listLevel"/>
  2643.             <xsl:with-param name="listRestart" select="$listRestart"/>
  2644.             <xsl:with-param name="listStyle" select="$listStyle"/>
  2645.             <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2646.             <xsl:with-param name="listIndent" select="$listIndent"/>
  2647.             <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
  2648.         </xsl:apply-templates>
  2649.     </xsl:template>
  2650.  
  2651.     <xsl:template match="*" mode="listItemSibling">
  2652.         <xsl:param name="globalData"/>
  2653.         <xsl:param name="isEmptyList"/>
  2654.         <xsl:param name="isListNumberingReset"/>
  2655.         <xsl:param name="isNextLevelNumberingReset"/>
  2656.         <xsl:param name="itemLabel"/>
  2657.         <xsl:param name="itemNumber"/>
  2658.         <xsl:param name="listIndent"/>
  2659.         <xsl:param name="listLevel"/>
  2660.         <xsl:param name="listRestart"/>
  2661.         <xsl:param name="listStyle"/>
  2662.         <xsl:param name="listStyleName"/>
  2663.  
  2664.         <xsl:apply-templates select="self::*">
  2665.             <xsl:with-param name="globalData" select="$globalData"/>
  2666.             <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
  2667.             <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  2668.             <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  2669.             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2670.             <xsl:with-param name="listIndent" select="$listIndent"/>
  2671.             <!-- receives the same parent label, only with a different itemNumber -->
  2672.             <xsl:with-param name="itemLabel" select="$itemLabel"/>
  2673.             <xsl:with-param name="listLevel" select="$listLevel"/>
  2674.             <xsl:with-param name="listStyle" select="$listStyle"/>
  2675.             <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2676.         </xsl:apply-templates>
  2677.         <xsl:apply-templates select="following-sibling::*[1]" mode="listItemSibling">
  2678.             <xsl:with-param name="globalData" select="$globalData"/>
  2679.             <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
  2680.             <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
  2681.             <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
  2682.             <xsl:with-param name="itemNumber" select="$itemNumber"/>
  2683.             <xsl:with-param name="listIndent" select="$listIndent"/>
  2684.             <!-- receives the same parent label, only with a different itemNumber -->
  2685.             <xsl:with-param name="itemLabel" select="$itemLabel"/>
  2686.             <xsl:with-param name="listLevel" select="$listLevel"/>
  2687.             <xsl:with-param name="listStyle" select="$listStyle"/>
  2688.             <xsl:with-param name="listStyleName" select="$listStyleName"/>
  2689.         </xsl:apply-templates>
  2690.     </xsl:template>
  2691.  
  2692.     <xsl:template match="text()" mode="list-item-children">
  2693.         <xsl:value-of select="."/>
  2694.     </xsl:template>
  2695.  
  2696.  
  2697.     <xsl:template name="create-list-style">
  2698.         <xsl:param name="globalData"/>
  2699.         <xsl:param name="listIndent" select="0"/>
  2700.         <xsl:param name="styleName"/>
  2701.  
  2702.         <xsl:if test="$styleName">
  2703.             <xsl:attribute name="class">
  2704.                 <xsl:value-of select="translate($styleName, '.,;: %()[]/\+', '_____________')"/>
  2705.             </xsl:attribute>
  2706.         </xsl:if>
  2707.         <xsl:attribute name="style">
  2708.             <xsl:text>margin-</xsl:text>
  2709.             <xsl:call-template name="getOppositeWritingDirection">
  2710.                 <xsl:with-param name="globalData" select="$globalData"/>
  2711.                 <xsl:with-param name="paraStyleName" select="descendant-or-self::*/@text:style-name"/>
  2712.             </xsl:call-template>
  2713.             <xsl:text>:</xsl:text>
  2714.             <xsl:value-of select="$listIndent"/>
  2715.             <xsl:text>cm;</xsl:text>
  2716.         </xsl:attribute>
  2717.     </xsl:template>
  2718.  
  2719.  
  2720.     <!-- ********************************************** -->
  2721.     <!-- *** Text Section (contains: draw:text-box) *** -->
  2722.     <!-- ********************************************** -->
  2723.  
  2724.     <xsl:template match="text:section">
  2725.         <xsl:param name="globalData"/>
  2726.  
  2727.         <xsl:if test="not(contains(@text:display, 'none'))">
  2728.             <xsl:comment>Next 'div' was a 'text:section'.</xsl:comment>
  2729.             <xsl:element name="div">
  2730.                 <xsl:call-template name="apply-styles-and-content">
  2731.                     <xsl:with-param name="globalData" select="$globalData"/>
  2732.                 </xsl:call-template>
  2733.             </xsl:element>
  2734.         </xsl:if>
  2735.     </xsl:template>
  2736.  
  2737.  
  2738.     <!-- Hidden text dependend on Office variables:
  2739.          The text is not shown, if condition is 'true'.
  2740.          Implemented solely for conditons as '<VARIABLE>==0' or '<VARIABLE>==1'
  2741.     -->
  2742.     <xsl:key match="text:variable-set" name="varSet" use="@text:name"/>
  2743.     <xsl:template match="text:hidden-text">
  2744.         <xsl:param name="globalData"/>
  2745.  
  2746.         <xsl:variable name="varName" select="substring-before(@text:condition, '==')"/>
  2747.         <xsl:variable name="varValue" select="substring-after(@text:condition, '==')"/>
  2748.         <xsl:choose>
  2749.             <xsl:when test="key('varSet', $varName)/@text:value != $varValue">
  2750.                 <xsl:value-of select="@text:string-value"/>
  2751.             </xsl:when>
  2752.             <xsl:otherwise>
  2753.                 <xsl:comment>
  2754.                     <xsl:value-of select="$varName"/>
  2755.                     <xsl:value-of select="@text:string-value"/>
  2756.                     <xsl:value-of select="$varName"/>
  2757.                 </xsl:comment>
  2758.             </xsl:otherwise>
  2759.         </xsl:choose>
  2760.     </xsl:template>
  2761.  
  2762.     <xsl:template match="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name-->
  2763.         <xsl:param name="globalData"/>
  2764.  
  2765.         <xsl:attribute name="class">
  2766.             <xsl:value-of select="translate(., '.,;: %()[]/\+', '_____________')"/>
  2767.         </xsl:attribute>
  2768.     </xsl:template>
  2769.  
  2770.  
  2771.     <!-- ***************** -->
  2772.     <!-- *** Footnotes *** -->
  2773.     <!-- ***************** -->
  2774.  
  2775.     <xsl:template match="text:note">
  2776.         <xsl:param name="globalData"/>
  2777.  
  2778.         <!-- get style configuration -->
  2779.         <xsl:variable name="footnoteConfig" select="$globalData/office:styles/text:notes-configuration[@text:note-class=current()/@text:note-class]" />
  2780.  
  2781.         <xsl:variable name="titlePrefix">
  2782.             <xsl:choose>
  2783.                 <xsl:when test="@text:note-class = 'footnote'">
  2784.                     <xsl:text>Footnote: </xsl:text>
  2785.                 </xsl:when>
  2786.                 <xsl:otherwise>
  2787.                     <xsl:text>Endnote: </xsl:text>
  2788.                 </xsl:otherwise>
  2789.             </xsl:choose>
  2790.         </xsl:variable>
  2791.  
  2792.         <!-- write anchor -->
  2793.         <xsl:element name="span">
  2794.             <xsl:attribute name="class">
  2795.                 <xsl:value-of select="$footnoteConfig/@text:citation-body-style-name"/>
  2796.             </xsl:attribute>
  2797.             <xsl:attribute name="title">
  2798.                 <xsl:value-of select="$titlePrefix"/>
  2799.                 <xsl:apply-templates mode="textOnly" select="text:note-body"/>
  2800.             </xsl:attribute>
  2801.             <xsl:element name="a">
  2802.                 <xsl:attribute name="href">
  2803.                     <xsl:value-of select="concat('#', @text:id)"/>
  2804.                 </xsl:attribute>
  2805.                 <xsl:attribute name="id">
  2806.                     <xsl:value-of select="concat('body_', @text:id)"/>
  2807.                 </xsl:attribute>
  2808.                 <xsl:apply-templates mode="textOnly" select="text:note-citation"/>
  2809.             </xsl:element>
  2810.         </xsl:element>
  2811.     </xsl:template>
  2812.  
  2813.     <xsl:template match="*" mode="textOnly">
  2814.         <xsl:apply-templates select="* | text()" mode="textOnly" />
  2815.     </xsl:template>
  2816.  
  2817.     <xsl:template match="text()" mode="textOnly">
  2818.         <xsl:value-of select="."/>
  2819.     </xsl:template>
  2820.  
  2821.     <!-- Useful in case of 'style:map', conditional formatting, where a style references to another -->
  2822.     <xsl:key name="textNotes" match="text:note" use="@text:note-class"/>
  2823.  
  2824.     <!-- writing the footer- and endnotes beyond the body -->
  2825.     <xsl:template name="write-text-nodes">
  2826.         <xsl:param name="globalData"/>
  2827.  
  2828.         <!-- write footnote body -->
  2829.         <xsl:for-each select="key('textNotes', 'footnote')">
  2830.             <xsl:call-template name="write-text-node">
  2831.                 <xsl:with-param name="globalData" select="$globalData"/>
  2832.                 <xsl:with-param name="footnoteConfig" select="$globalData/office:styles/text:notes-configuration[@text:note-class=current()/@text:note-class]" />
  2833.             </xsl:call-template>
  2834.         </xsl:for-each>
  2835.  
  2836.         <!-- write endnote body -->
  2837.         <xsl:for-each select="key('textNotes', 'endnote')">
  2838.             <xsl:call-template name="write-text-node">
  2839.  
  2840.                 <xsl:with-param name="globalData" select="$globalData"/>
  2841.                 <xsl:with-param name="footnoteConfig" select="$globalData/office:styles/text:notes-configuration[@text:note-class=current()/@text:note-class]" />
  2842.             </xsl:call-template>
  2843.         </xsl:for-each>
  2844.     </xsl:template>
  2845.  
  2846.     <xsl:template name="write-text-node">
  2847.         <xsl:param name="globalData"/>
  2848.         <xsl:param name="footnoteConfig"/>
  2849.  
  2850.         <xsl:apply-templates select="text:note-body/*[1]">
  2851.             <xsl:with-param name="globalData" select="$globalData" />
  2852.             <xsl:with-param name="footnotePrefix">
  2853.                 <xsl:element name="span">
  2854.                     <xsl:attribute name="class">footnodeNumber</xsl:attribute>
  2855.                     <xsl:element name="a">
  2856.                         <xsl:attribute name="class">
  2857.                             <xsl:value-of select="$footnoteConfig/@text:citation-style-name"/>
  2858.                         </xsl:attribute>
  2859.                         <xsl:attribute name="id">
  2860.                             <xsl:value-of select="@text:id"/>
  2861.                         </xsl:attribute>
  2862.                         <xsl:attribute name="href">
  2863.                             <xsl:value-of select="concat('#body_', @text:id)"/>
  2864.                         </xsl:attribute>
  2865.                         <xsl:apply-templates mode="textOnly" select="text:note-citation"/>
  2866.                     </xsl:element>
  2867.                 </xsl:element>
  2868.             </xsl:with-param>
  2869.         </xsl:apply-templates>
  2870.         <xsl:apply-templates select="text:note-body/*[position()>1]">
  2871.             <xsl:with-param name="globalData" select="$globalData" />
  2872.         </xsl:apply-templates>
  2873.     </xsl:template>
  2874.  
  2875.     <!-- ***************** -->
  2876.     <!-- *** Bookmarks *** -->
  2877.     <!-- ***************** -->
  2878.  
  2879.     <xsl:template match="text:bookmark|text:bookmark-start">
  2880.         <xsl:element name="a">
  2881.             <xsl:attribute name="name">
  2882.                 <xsl:value-of select="@text:name"/>
  2883.             </xsl:attribute>
  2884.         </xsl:element>
  2885.     </xsl:template>
  2886.  
  2887.     <xsl:template match="text:bookmark-end"/>
  2888.  
  2889.     <!-- DISABLING this tab handling as the tab width is only relative
  2890.     <xsl:template match="text:tab">
  2891.         <xsl:param name="globalData"/>
  2892.  
  2893.         <xsl:variable name="tabNo">
  2894.             <xsl:choose>
  2895.                 <xsl:when test="preceding-sibling::text:line-break">
  2896.                     <xsl:call-template name="countTextTab"/>
  2897.                 </xsl:when>
  2898.                 <xsl:when test="preceding-sibling::text:tab">
  2899.                     <xsl:value-of select="count(preceding-sibling::text:tab)"/>
  2900.                 </xsl:when>
  2901.                 <xsl:otherwise>1</xsl:otherwise>
  2902.             </xsl:choose>
  2903.         </xsl:variable>
  2904.  
  2905.         <xsl:element name="span">
  2906.              <xsl:attribute name="style">margin-left:<xsl:value-of select="$globalData/all-doc-styles/style[@style:name = current()/parent::*/@text:style-name]/*/style:tab-stops/style:tab-stop[$tabNo]/@style:position"/>;</xsl:attribute>
  2907.         </xsl:element>
  2908.     </xsl:template>
  2909.  
  2910.     <xsl:template name="countTextTab">
  2911.         <xsl:param name="tabCount" select="1"/>
  2912.         <xsl:param name="context" select="."/>
  2913.  
  2914.         <xsl:choose>
  2915.             <xsl:when test="preceding-sibling::*[1]">
  2916.                 <xsl:for-each select="preceding-sibling::*[1]">
  2917.                     <xsl:call-template name="countTextTab">
  2918.                         <xsl:with-param name="tabCout">
  2919.                             <xsl:choose>
  2920.                                 <xsl:when test="name(.) = 'text:tab'">
  2921.                                     <xsl:value-of select="$tabCount + 1"/>
  2922.                                 </xsl:when>
  2923.                                 <xsl:otherwise>
  2924.                                     <xsl:value-of select="$tabCount"/>
  2925.                                 </xsl:otherwise>
  2926.                             </xsl:choose>
  2927.                         </xsl:with-param>
  2928.                         <xsl:with-param name="context" select="preceding-sibling::*[1]" />
  2929.                     </xsl:call-template>
  2930.                 </xsl:for-each>
  2931.             </xsl:when>
  2932.             <xsl:otherwise>
  2933.                 <xsl:value-of select="$tabCount"/>
  2934.             </xsl:otherwise>
  2935.         </xsl:choose>
  2936.     </xsl:template>
  2937. -->
  2938.     <!-- MathML -->
  2939.     <xsl:template match="draw:object[math:math]">
  2940.         <math xmlns="http://www.w3.org/1998/Math/MathML">
  2941.             <xsl:apply-templates select="math:math/math:semantics/*" mode="math"/>
  2942.         </math>
  2943.     </xsl:template>
  2944.  
  2945.     <xsl:template match="*" mode="math">
  2946.         <xsl:element name="{local-name()}" namespace="http://www.w3.org/1998/Math/MathML">
  2947.             <xsl:apply-templates select="@*|node()" mode="math"/>
  2948.         </xsl:element>
  2949.     </xsl:template>
  2950.  
  2951.     <xsl:template match="@*" mode="math">
  2952.         <xsl:attribute name="{local-name()}">
  2953.             <xsl:value-of select="."/>
  2954.         </xsl:attribute>
  2955.     </xsl:template>
  2956.  
  2957.     <xsl:template match="math:annotation" mode="math"/>
  2958.  
  2959. </xsl:stylesheet>
  2960.