home *** CD-ROM | disk | FTP | other *** search
/ PC World 2004 May / PCWorld_2004-05_cd.bin / akce / openoffice / f_0397 / MsWordXMLImport.xsl
Extensible Markup Language  |  2004-03-27  |  79KB  |  1,557 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  #  The Contents of this file are made available subject to the terms of
  4.  #  either of the following licenses
  5.  #
  6.  #         - GNU Lesser General Public License Version 2.1
  7.  #         - Sun Industry Standards Source License Version 1.1
  8.  #
  9.  #  Sun Microsystems Inc., October, 2000
  10.  #
  11.  #  GNU Lesser General Public License Version 2.1
  12.  #  =============================================
  13.  #  Copyright 2000 by Sun Microsystems, Inc.
  14.  #  901 San Antonio Road, Palo Alto, CA 94303, USA
  15.  #
  16.  #  This library is free software; you can redistribute it and/or
  17.  #  modify it under the terms of the GNU Lesser General Public
  18.  #  License version 2.1, as published by the Free Software Foundation.
  19.  #
  20.  #  This library is distributed in the hope that it will be useful,
  21.  #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22.  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  23.  #  Lesser General Public License for more details.
  24.  #
  25.  #  You should have received a copy of the GNU Lesser General Public
  26.  #  License along with this library; if not, write to the Free Software
  27.  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28.  #  MA  02111-1307  USA
  29.  #
  30.  #
  31.  #  Sun Industry Standards Source License Version 1.1
  32.  #  =================================================
  33.  #  The contents of this file are subject to the Sun Industry Standards
  34.  #  Source License Version 1.1 (the "License"); You may not use this file
  35.  #  except in compliance with the License. You may obtain a copy of the
  36.  #  License at http://www.openoffice.org/license.html.
  37.  #
  38.  #  Software provided under this License is provided on an "AS IS" basis,
  39.  #  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  40.  #  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  41.  #  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  42.  #  See the License for the specific provisions governing your rights and
  43.  #  obligations concerning the Software.
  44.  #
  45.  #  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  46.  #
  47.  #  Copyright: 2000 by Sun Microsystems, Inc.
  48.  #
  49.  #  All Rights Reserved.
  50.  #
  51.  #  Contributor(s): _______________________________________
  52.  #
  53.  #
  54.  -->
  55. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:SL="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:office="http://openoffice.org/2000/office" xmlns:table="http://openoffice.org/2000/table" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:meta="http://openoffice.org/2000/meta" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" xmlns:config="http://openoffice.org/2001/config" office:version="1.0">
  56.     <xsl:output method="xml" indent="no" encoding="UTF-8" version="1.0"/>
  57.     <xsl:template match="w:wordDocument">
  58.         <office:document xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:meta="http://openoffice.org/2000/meta" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" xmlns:config="http://openoffice.org/2001/config" office:class="text" office:version="1.0">
  59.             <xsl:apply-templates select="o:DocumentProperties"/>
  60.             <xsl:apply-templates select="w:docPr"/>
  61.             <xsl:apply-templates select="w:fonts"/>
  62.             <xsl:apply-templates select="w:styles"/>
  63.             <xsl:apply-templates select="w:body"/>
  64.         </office:document>
  65.     </xsl:template>
  66.     <xsl:template match="o:DocumentProperties">
  67.         <office:meta>
  68.             <meta:generator>Microsoft Word 2003</meta:generator>
  69.             <dc:title>
  70.                 <xsl:value-of select="o:Title"/>
  71.             </dc:title>
  72.             <dc:description>
  73.                 <xsl:value-of select="o:Description"/>
  74.             </dc:description>
  75.             <dc:subject>
  76.                 <xsl:value-of select="o:Subject"/>
  77.             </dc:subject>
  78.             <meta:initial-creator>
  79.                 <xsl:value-of select="o:Author"/>
  80.             </meta:initial-creator>
  81.             <meta:creation-date>
  82.                 <xsl:value-of select="substring-before( o:Created, 'Z')"/>
  83.             </meta:creation-date>
  84.             <dc:creator>
  85.                 <xsl:value-of select="o:LastAuthor"/>
  86.             </dc:creator>
  87.             <dc:date>
  88.                 <xsl:value-of select="substring-before( o:LastSaved, 'Z')"/>
  89.             </dc:date>
  90.             <meta:printed-by/>
  91.             <meta:print-date/>
  92.             <meta:keywords>
  93.                 <meta:keyword>
  94.                     <xsl:value-of select="o:Keywords"/>
  95.                 </meta:keyword>
  96.             </meta:keywords>
  97.             <dc:language/>
  98.             <meta:editing-cycles>
  99.                 <xsl:value-of select="o:Revision"/>
  100.             </meta:editing-cycles>
  101.             <meta:editing-duration>
  102.                 <xsl:if test="o:TotalTime">
  103.                     <xsl:value-of select="concat('PT', floor(o:TotalTime div 60), 'H', o:TotalTime mod 60, 'M0S')"/>
  104.                 </xsl:if>
  105.             </meta:editing-duration>
  106.             <meta:user-defined meta:name="Category">
  107.                 <xsl:value-of select="o:Category"/>
  108.             </meta:user-defined>
  109.             <meta:user-defined meta:name="Manager">
  110.                 <xsl:value-of select="o:Manager"/>
  111.             </meta:user-defined>
  112.             <meta:user-defined meta:name="Company">
  113.                 <xsl:value-of select="o:Company"/>
  114.             </meta:user-defined>
  115.             <meta:user-defined meta:name="Version">
  116.                 <xsl:value-of select="o:Version"/>
  117.             </meta:user-defined>
  118.             <meta:user-defined meta:name="HyperlinkBase">
  119.                 <xsl:value-of select="o:HyperlinkBase"/>
  120.             </meta:user-defined>
  121.             <xsl:apply-templates select="../o:CustomDocumentProperties"/>
  122.             <meta:document-statistic/>
  123.         </office:meta>
  124.     </xsl:template>
  125.     <xsl:template match="o:CustomDocumentProperties">
  126.         <xsl:for-each select="node()[@dt:dt]">
  127.             <meta:user-defined meta:name="{name()}">
  128.                 <xsl:value-of select="."/>
  129.             </meta:user-defined>
  130.         </xsl:for-each>
  131.     </xsl:template>
  132.     <xsl:template match="w:docPr">
  133.         <office:settings>
  134.             <config:config-item-set config:name="view-settings">
  135.                 <config:config-item config:name="InBrowseMode" config:type="boolean">
  136.                     <xsl:choose>
  137.                         <xsl:when test="w:view/@w:val = 'outline'">true</xsl:when>
  138.                         <xsl:when test="w:view/@w:val = 'print'">false</xsl:when>
  139.                         <!-- others: web, reading, normal, master-pages, none. glu -->
  140.                         <xsl:otherwise>true</xsl:otherwise>
  141.                     </xsl:choose>
  142.                 </config:config-item>
  143.                 <config:config-item-map-indexed config:name="Views">
  144.                     <config:config-item-map-entry>
  145.                         <xsl:if test="w:zoom">
  146.                             <!-- VisibleRight and VisibleBottom are arbitrary positive numbers. ;) glu -->
  147.                             <config:config-item config:name="VisibleRight" config:type="int">1</config:config-item>
  148.                             <config:config-item config:name="VisibleBottom" config:type="int">1</config:config-item>
  149.                             <xsl:choose>
  150.                                 <xsl:when test="w:zoom/@w:val = 'best-fit'">
  151.                                     <config:config-item config:name="ZoomType" config:type="short">3</config:config-item>
  152.                                 </xsl:when>
  153.                                 <xsl:when test="w:zoom/@w:val = 'full-page'">
  154.                                     <config:config-item config:name="ZoomType" config:type="short">2</config:config-item>
  155.                                 </xsl:when>
  156.                                 <xsl:when test="w:zoom/@w:val = 'text-fit'">
  157.                                     <config:config-item config:name="ZoomType" config:type="short">1</config:config-item>
  158.                                 </xsl:when>
  159.                                 <xsl:otherwise>
  160.                                     <config:config-item config:name="ZoomType" config:type="short">0</config:config-item>
  161.                                 </xsl:otherwise>
  162.                             </xsl:choose>
  163.                             <config:config-item config:name="ZoomFactor" config:type="short">
  164.                                 <xsl:value-of select="w:zoom/@w:percent"/>
  165.                             </config:config-item>
  166.                         </xsl:if>
  167.                     </config:config-item-map-entry>
  168.                 </config:config-item-map-indexed>
  169.             </config:config-item-set>
  170.         </office:settings>
  171.     </xsl:template>
  172.     <xsl:template match="w:fonts">
  173.         <xsl:element name="office:font-decls">
  174.             <!-- MS Word's default font declaration, added for Writer automatically. glu -->
  175.             <style:font-decl style:name="Arial" fo:font-family="Arial" style:font-family-generic="roman" style:font-pitch="variable"/>
  176.             <style:font-decl style:name="Times New Roman" fo:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/>
  177.             <style:font-decl style:name="Symbol" fo:font-family="Symbol" style:font-family-generic="roman" style:font-pitch="variable" style:font-charset="x-symbol"/>
  178.             <style:font-decl style:name="Courier New" fo:font-family="'Courier New'" style:font-family-generic="modern" style:font-pitch="fixed"/>
  179.             <xsl:if test="not(w:font[@w:name='StarSymbol'])">
  180.                 <style:font-decl style:name="StarSymbol" fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
  181.             </xsl:if>
  182.             <xsl:for-each select="w:font">
  183.                 <xsl:element name="style:font-decl">
  184.                     <xsl:attribute name="style:name"><xsl:value-of select="@w:name"/></xsl:attribute>
  185.                     <xsl:attribute name="fo:font-family"><xsl:value-of select="@w:name"/></xsl:attribute>
  186.                     <!-- added by glu, for process special fonts e.g. Marlett, -->
  187.                     <xsl:if test="w:charset/@w:val = '02'">
  188.                         <xsl:attribute name="style:font-charset">x-symbol</xsl:attribute>
  189.                     </xsl:if>
  190.                     <xsl:if test="w:family">
  191.                         <xsl:choose>
  192.                             <xsl:when test="w:family/@w:val = 'Swiss'">
  193.                                 <xsl:attribute name="style:font-family-generic">swiss</xsl:attribute>
  194.                             </xsl:when>
  195.                             <xsl:when test="w:family/@w:val='Modern'">
  196.                                 <xsl:attribute name="style:font-family-generic">modern</xsl:attribute>
  197.                             </xsl:when>
  198.                             <xsl:when test="w:family/@w:val='Roman'">
  199.                                 <xsl:attribute name="style:font-family-generic">roman</xsl:attribute>
  200.                             </xsl:when>
  201.                             <xsl:when test="w:family/@w:val='Script'">
  202.                                 <xsl:attribute name="style:font-family-generic">script</xsl:attribute>
  203.                             </xsl:when>
  204.                             <xsl:when test="w:family/@w:val='Decorative'">
  205.                                 <xsl:attribute name="style:font-family-generic">decorative</xsl:attribute>
  206.                             </xsl:when>
  207.                             <xsl:when test="w:family/@w:val='System'">
  208.                                 <xsl:attribute name="style:font-family-generic">system</xsl:attribute>
  209.                             </xsl:when>
  210.                             <xsl:otherwise>
  211.                                 <xsl:attribute name="style:font-family-generic">system</xsl:attribute>
  212.                             </xsl:otherwise>
  213.                         </xsl:choose>
  214.                     </xsl:if>
  215.                     <xsl:if test="w:pitch">
  216.                         <xsl:attribute name="style:font-pitch"><xsl:value-of select="w:pitch/@w:val"/></xsl:attribute>
  217.                     </xsl:if>
  218.                 </xsl:element>
  219.             </xsl:for-each>
  220.             <xsl:apply-templates select="w:font"/>
  221.         </xsl:element>
  222.     </xsl:template>
  223.     <xsl:template match="w:styles">
  224.         <xsl:variable name="default_paragraph_style" select="w:style[@w:default = 'on' and @w:type = 'paragraph']"/>
  225.         <xsl:variable name="default_character_style" select="w:style[@w:default = 'on' and @w:type = 'character']"/>
  226.         <xsl:variable name="default_table_style" select="w:style[@w:default = 'on' and @w:type = 'table']"/>
  227.         <office:styles>
  228.             <!-- make default paragarph  and other styles. glu -->
  229.             <xsl:if test="$default_paragraph_style">
  230.                 <style:default-style style:family="paragraph">
  231.                     <xsl:element name="style:properties">
  232.                         <xsl:choose>
  233.                             <xsl:when test="/w:wordDocument/w:fonts/w:defaultFonts">
  234.                                 <xsl:attribute name="style:font-name"><xsl:value-of select="/w:wordDocument/w:fonts/w:defaultFonts/@w:ascii"/></xsl:attribute>
  235.                                 <xsl:attribute name="style:font-name-asian"><xsl:value-of select="/w:wordDocument/w:fonts/w:defaultFonts/@w:fareast"/></xsl:attribute>
  236.                                 <xsl:attribute name="style:font-name-complex"><xsl:value-of select="/w:wordDocument/w:fonts/w:defaultFonts/@w:cs"/></xsl:attribute>
  237.                             </xsl:when>
  238.                             <xsl:otherwise>
  239.                                 <xsl:attribute name="style:font-name">Times New Roman</xsl:attribute>
  240.                             </xsl:otherwise>
  241.                         </xsl:choose>
  242.                         <xsl:apply-templates select="$default_paragraph_style/w:rPr/w:sz"/>
  243.                         <xsl:apply-templates select="$default_paragraph_style/w:rPr/w:sz-cs"/>
  244.                         <!-- if not defined default font size in Word, make it out as 10pt. glu -->
  245.                         <xsl:if test="not($default_paragraph_style/w:rPr/w:sz or w:rPr/w:sz-cs)">
  246.                             <xsl:attribute name="fo:font-size">10pt</xsl:attribute>
  247.                             <xsl:attribute name="fo:font-size-asian">10pt</xsl:attribute>
  248.                             <xsl:attribute name="fo:font-size-complex">10pt</xsl:attribute>
  249.                         </xsl:if>
  250.                         <xsl:apply-templates select="$default_paragraph_style/w:rPr/w:lang"/>
  251.                         <xsl:attribute name="style:tab-stop-distance"><xsl:value-of select="concat( number(/w:wordDocument/w:docPr/w:defaultTabStop/@w:val)div 1440 *2.54, 'cm')"/></xsl:attribute>
  252.                     </xsl:element>
  253.                 </style:default-style>
  254.             </xsl:if>
  255.             <style:style style:name="ColumnBreakPara" style:family="paragraph">
  256.                 <style:properties fo:break-after="column"/>
  257.             </style:style>
  258.             <xsl:if test="$default_character_style">
  259.                 <style:default-style style:family="text"/>
  260.             </xsl:if>
  261.             <style:style style:name="Numbering Symbols" style:family="text"/>
  262.             <style:style style:name="Bullet Symbols" style:family="text">
  263.                 <style:properties style:font-name="StarSymbol" fo:font-size="9pt" style:font-name-asian="StarSymbol" style:font-size-asian="9pt" style:font-name-complex="StarSymbol" style:font-size-complex="9pt"/>
  264.             </style:style>
  265.             <xsl:if test="$default_table_style">
  266.                 <style:default-style style:family="table">
  267.                     <xsl:element name="style:properties">
  268.                         <xsl:apply-templates select="$default_table_style/w:rPr/wx:font"/>
  269.                     </xsl:element>
  270.                 </style:default-style>
  271.             </xsl:if>
  272.             <!-- StarWriter has no default style family 'list'. glu -->
  273.             <xsl:apply-templates select="w:style"/>
  274.         </office:styles>
  275.         <xsl:element name="office:automatic-styles">
  276.             <style:style style:name="PageBreak" style:family="paragraph">
  277.                 <style:properties fo:break-before="page"/>
  278.             </style:style>
  279.             <xsl:for-each select="/w:wordDocument/w:body//w:p">
  280.                 <xsl:choose>
  281.                     <xsl:when test="w:pPr">
  282.                         <xsl:element name="style:style">
  283.                             <xsl:attribute name="style:family">paragraph</xsl:attribute>
  284.                             <xsl:attribute name="style:name">P<xsl:number from="/w:wordDocument/w:body" level="any" count="w:p[w:pPr]"/></xsl:attribute>
  285.                             <xsl:if test="w:pPr/w:pStyle">
  286.                                 <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:pPr/w:pStyle/@w:val"/></xsl:attribute>
  287.                             </xsl:if>
  288.                             <!-- We don't want to change the page style if there are columns being created. The Columns will be handled by using in-line sections.-->
  289.                             <xsl:if test="not(ancestor::wx:sect/descendant::w:sectPr/w:cols[@w:num > 1])">
  290.                                 <xsl:variable name="section-property-number">
  291.                                     <xsl:number count="wx:sect" from="/w:wordDocument/w:body" level="any"/>
  292.                                 </xsl:variable>
  293.                                 <xsl:choose>
  294.                                     <xsl:when test="generate-id(ancestor::wx:sect/descendant::w:p[1]) = generate-id(.)">
  295.                                         <xsl:attribute name="style:master-page-name"><xsl:value-of select="concat('Standard', $section-property-number)"/></xsl:attribute>
  296.                                     </xsl:when>
  297.                                     <xsl:when test="descendant::w:br[@w:type = 'page'] and following::w:sectPr">
  298.                                         <xsl:attribute name="style:master-page-name"><xsl:value-of select="concat('Standard', $section-property-number)"/></xsl:attribute>
  299.                                     </xsl:when>
  300.                                 </xsl:choose>
  301.                             </xsl:if>
  302.                             <xsl:element name="style:properties">
  303.                                 <xsl:apply-templates select="w:rPr/*"/>
  304.                                 <xsl:apply-templates select="w:pPr/*"/>
  305.                                 <xsl:call-template name="paragraph-properties"/>
  306.                             </xsl:element>
  307.                         </xsl:element>
  308.                     </xsl:when>
  309.                     <xsl:when test="generate-id(ancestor::wx:sect/descendant::w:p[1]) = generate-id(.)">
  310.                         <xsl:element name="style:style">
  311.                             <xsl:attribute name="style:family">paragraph</xsl:attribute>
  312.                             <xsl:attribute name="style:name">P<xsl:number from="/w:wordDocument/w:body" level="any" count="w:pPr"/>_1</xsl:attribute>
  313.                             <xsl:attribute name="style:master-page-name">Standard<xsl:number count="wx:sect" from="/w:wordDocument/w:body" level="any"/></xsl:attribute>
  314.                         </xsl:element>
  315.                     </xsl:when>
  316.                 </xsl:choose>
  317.             </xsl:for-each>
  318.             <xsl:for-each select="/w:wordDocument/w:body//w:rPr">
  319.                 <xsl:element name="style:style">
  320.                     <xsl:attribute name="style:name">T<xsl:value-of select="count(preceding::w:rPr)"/></xsl:attribute>
  321.                     <xsl:if test="w:rStyle">
  322.                         <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:rStyle/@w:val"/></xsl:attribute>
  323.                     </xsl:if>
  324.                     <xsl:choose>
  325.                         <xsl:when test="ancestor::w:pPr">
  326.                             <xsl:attribute name="style:family">paragraph</xsl:attribute>
  327.                         </xsl:when>
  328.                         <xsl:otherwise>
  329.                             <xsl:attribute name="style:family">text</xsl:attribute>
  330.                         </xsl:otherwise>
  331.                     </xsl:choose>
  332.                     <xsl:element name="style:properties">
  333.                         <xsl:apply-templates select="*"/>
  334.                     </xsl:element>
  335.                 </xsl:element>
  336.             </xsl:for-each>
  337.             <xsl:for-each select="/w:wordDocument/w:body//w:tblPr">
  338.                 <xsl:element name="style:style">
  339.                     <xsl:attribute name="style:name">Table<xsl:value-of select="count(preceding::w:tblPr)"/></xsl:attribute>
  340.                     <xsl:attribute name="style:family">table</xsl:attribute>
  341.                     <xsl:if test="w:tblStyle/@w:val">
  342.                         <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:tblStyle/@w:val"/></xsl:attribute>
  343.                     </xsl:if>
  344.                     <xsl:element name="style:properties">
  345.                         <xsl:choose>
  346.                             <xsl:when test="w:jc/@w:val = 'left' or w:jc/@w:val = 'center' or w:jc/@w:val = 'right'">
  347.                                 <xsl:attribute name="table:align"><xsl:value-of select="w:jc/@w:val"/></xsl:attribute>
  348.                             </xsl:when>
  349.                             <xsl:otherwise>
  350.                                 <xsl:attribute name="table:align">margins</xsl:attribute>
  351.                             </xsl:otherwise>
  352.                         </xsl:choose>
  353.                         <xsl:if test="w:bidiVisual">
  354.                             <xsl:attribute name="style:writing-mode">rl-tb</xsl:attribute>
  355.                         </xsl:if>
  356.                         <!-- Setting table margins using cell padding-->
  357.                         <xsl:if test="w:tblStyle/@w:val">
  358.                             <xsl:variable name="rootStyle" select="w:tblStyle/@w:val"/>
  359.                             <xsl:variable name="rootStyleNode" select="/w:wordDocument/w:styles/w:style[@w:styleId = $rootStyle]"/>
  360.                             <xsl:variable name="paddingleft">
  361.                                 <xsl:value-of select="$rootStyleNode/w:tblPr/w:tblCellMar/w:left/@w:w"/>
  362.                             </xsl:variable>
  363.                             <xsl:variable name="paddingright">
  364.                                 <xsl:value-of select="$rootStyleNode/w:tblPr/w:tblCellMar/w:right/@w:w"/>
  365.                             </xsl:variable>
  366.                             <xsl:variable name="paddingtop">
  367.                                 <xsl:value-of select="$rootStyleNode/w:tblPr/w:tblCellMar/w:top/@w:w"/>
  368.                             </xsl:variable>
  369.                             <xsl:variable name="paddingbottom">
  370.                                 <xsl:value-of select="$rootStyleNode/w:tblPr/w:tblCellMar/w:bottom/@w:w"/>
  371.                             </xsl:variable>
  372.                             <xsl:if test="$rootStyleNode/w:tblPr/w:tblCellMar/w:left">
  373.                                 <xsl:attribute name="fo:margin-left">-<xsl:value-of select="(number($paddingleft) div 1440) *2.54"/>cm</xsl:attribute>
  374.                             </xsl:if>
  375.                             <!--
  376.                             <xsl:if test="$rootStyleNode/w:tblPr/w:tblCellMar/w:right">
  377.                                 <xsl:attribute name="fo:margin-right">-<xsl:value-of select="(number($paddingright) div 1440) *2.54"/>cm</xsl:attribute>
  378.                             </xsl:if>
  379.                             -->
  380.                         </xsl:if>
  381.                         <xsl:choose>
  382.                             <xsl:when test="w:tblW/@w:type ='pct'">
  383.                                 <xsl:variable name="sectPr" select="/descendant::wx:sect/w:sectPr"/>
  384.                                 <xsl:variable name="pageSize" select="number($sectPr/w:pgSz/@w:w)"/>
  385.                                 <xsl:variable name="pageLeftMar" select="number($sectPr/w:pgMar/@w:left)"/>
  386.                                 <xsl:variable name="pageRightMar" select="number($sectPr/w:pgMar/@w:right)"/>
  387.                                 <xsl:attribute name="style:width"><xsl:value-of select="concat( ((    (number($sectPr/w:pgSz/@w:w) - number($pageLeftMar + $pageRightMar)  +(113 *2))div 1440)*2.54)*(number(w:tblW/@w:w) div 5000), 'cm')"/></xsl:attribute>
  388.                             </xsl:when>
  389.                             <xsl:otherwise>
  390.                                 <xsl:variable name="colwidth" select="parent::w:tbl"/>
  391.                                 <xsl:variable name="gridcols" select="$colwidth/w:tblGrid/w:gridCol"/>
  392.                                 <xsl:variable name="tblsize" select="sum($gridcols/@w:w)"/>
  393.                                 <xsl:if test="not($tblsize='0')">
  394.                                     <xsl:choose>
  395.                                         <xsl:when test="w:tblInd">
  396.                                             <xsl:attribute name="style:width"><xsl:value-of select="concat( (number($tblsize -  w:tblInd/@w:w) div 1440)*2.54, 'cm')"/></xsl:attribute>
  397.                                         </xsl:when>
  398.                                         <xsl:otherwise>
  399.                                             <xsl:attribute name="style:width"><xsl:value-of select="concat( (number($tblsize  ) div 1440)*2.54, 'cm')"/></xsl:attribute>
  400.                                         </xsl:otherwise>
  401.                                     </xsl:choose>
  402.                                 </xsl:if>
  403.                                 <!-- If previous w:p has a page break, the table must have the page break attribute applied to it    -->
  404.                                 <!-- May need this for tables starting on new pages-->
  405.                                 <!--    <xsl:if test="parent::w:tbl/preceding-sibling::w:p[1][descendant::w:br/@w:type='page']">
  406.                                     <xsl:attribute name="fo:break-before">page</xsl:attribute></xsl:if>    -->
  407.                             </xsl:otherwise>
  408.                         </xsl:choose>
  409.                         <!-- initial values for tables-->
  410.                         <xsl:apply-templates/>
  411.                     </xsl:element>
  412.                 </xsl:element>
  413.             </xsl:for-each>
  414.             <xsl:for-each select="/w:wordDocument/w:body//w:gridCol ">
  415.                 <xsl:element name="style:style">
  416.                     <xsl:attribute name="style:family">table-column</xsl:attribute>
  417.                     <xsl:attribute name="style:name">TColumn<xsl:value-of select="count(preceding::w:gridCol)"/></xsl:attribute>
  418.                     <xsl:variable name="tableRoot" select="ancestor::w:tbl"/>
  419.                     <xsl:element name="style:properties">
  420.                         <xsl:choose>
  421.                             <xsl:when test="$tableRoot/w:tblPr/w:tblW/@w:type = 'pct'">
  422.                                 <xsl:variable name="pageWidth" select="number(ancestor::wx:sect/w:sectPr/w:pgSz/@w:w)"/>
  423.                                 <xsl:variable name="pageLeftMar" select="number(ancestor::wx:sect/w:sectPr/w:pgMar/@w:left)"/>
  424.                                 <xsl:variable name="pageRightMar" select="number(ancestor::wx:sect/w:sectPr/w:pgMar/@w:right)"/>
  425.                                 <xsl:variable name="pctTotal" select="$tableRoot/w:tblPr/w:tblW/@w:w"/>
  426.                                 <xsl:variable name="prevCols" select="count(preceding-sibling::w:gridCol)"/>
  427.                                 <xsl:variable name="relSize" select="$tableRoot/w:tr[1]/w:tc[$prevCols+1]/w:tcPr/w:tcW/@w:w"/>
  428.                                 <xsl:attribute name="style:column-width"><xsl:value-of select="concat( (number(($relSize div $pctTotal) * ($pageWidth - ($pageLeftMar + $pageRightMar))) div 1440) *2.54, 'cm')"/></xsl:attribute>
  429.                             </xsl:when>
  430.                             <xsl:otherwise>
  431.                                 <xsl:attribute name="style:column-width"><xsl:value-of select="concat( (number(@w:w) div 1440) *2.54, 'cm')"/></xsl:attribute>
  432.                             </xsl:otherwise>
  433.                         </xsl:choose>
  434.                     </xsl:element>
  435.                 </xsl:element>
  436.             </xsl:for-each>
  437.             <xsl:for-each select="/w:wordDocument/w:body//w:tcPr">
  438.                 <style:style>
  439.                     <xsl:attribute name="style:name">TCell<xsl:value-of select="count(preceding::w:tcPr)"/></xsl:attribute>
  440.                     <xsl:attribute name="style:family">table-cell</xsl:attribute>
  441.                     <xsl:element name="style:properties">
  442.                         <xsl:if test="ancestor::w:tbl/w:tblPr/w:tblStyle/@w:val">
  443.                             <xsl:variable name="rootStyle" select="ancestor::w:tbl/w:tblPr/w:tblStyle/@w:val"/>
  444.                             <xsl:variable name="rootStyleNode" select="/descendant::w:style[@w:styleId = $rootStyle]"/>
  445.                             <xsl:if test="$rootStyleNode/w:tcPr/w:shd/@wx:bgcolor">
  446.                                 <xsl:attribute name="fo:background-color">#<xsl:value-of select="$rootStyleNode/w:tcPr/w:shd/@wx:bgcolor"/></xsl:attribute>
  447.                             </xsl:if>
  448.                             <xsl:variable name="tblpropsright" select="$rootStyleNode/w:tblPr/w:tblCellMar/w:right"/>
  449.                             <xsl:variable name="tblpropsleft" select="$rootStyleNode/w:tblPr/w:tblCellMar/w:left"/>
  450.                             <xsl:variable name="tblpropstop" select="$rootStyleNode/w:tblPr/w:tblCellMar/w:top"/>
  451.                             <xsl:variable name="tblpropsbottom" select="$rootStyleNode/w:tblPr/w:tblCellMar/w:bottom"/>
  452.                             <xsl:variable name="paddingright">
  453.                                 <xsl:value-of select="$tblpropsright/@w:w"/>
  454.                             </xsl:variable>
  455.                             <xsl:variable name="paddingleft">
  456.                                 <xsl:value-of select="$tblpropsleft/@w:w"/>
  457.                             </xsl:variable>
  458.                             <xsl:variable name="paddingtop">
  459.                                 <xsl:value-of select="$tblpropstop/@w:w"/>
  460.                             </xsl:variable>
  461.                             <xsl:variable name="paddingbottom">
  462.                                 <xsl:value-of select="$tblpropsbottom/@w:w"/>
  463.                             </xsl:variable>
  464.                             <xsl:if test="$rootStyleNode/w:tblPr/w:tblCellMar/w:left">
  465.                                 <xsl:attribute name="fo:padding-left"><xsl:value-of select="(number($paddingleft) div 1440) *2.54"/>cm</xsl:attribute>
  466.                             </xsl:if>
  467.                             <xsl:if test="$rootStyleNode/w:tblPr/w:tblCellMar/w:right">
  468.                                 <xsl:attribute name="fo:padding-right"><xsl:value-of select="(number($paddingright) div 1440) *2.54"/>cm</xsl:attribute>
  469.                             </xsl:if>
  470.                             <xsl:if test="$rootStyleNode/w:tblPr/w:tblCellMar/w:top">
  471.                                 <xsl:attribute name="fo:padding-top"><xsl:value-of select="(number($paddingtop) div 1440) *2.54"/>cm</xsl:attribute>
  472.                             </xsl:if>
  473.                             <xsl:if test="$rootStyleNode/w:tblPr/w:tblCellMar/w:bottom">
  474.                                 <xsl:attribute name="fo:padding-bottom"><xsl:value-of select="(number($paddingbottom) div 1440) *2.54"/>cm</xsl:attribute>
  475.                             </xsl:if>
  476.                         </xsl:if>
  477.                         <xsl:variable name="cellbefore">
  478.                             <xsl:value-of select="count(ancestor::w:tc/preceding-sibling::w:tc)"/>
  479.                         </xsl:variable>
  480.                         <xsl:variable name="cellafter">
  481.                             <xsl:value-of select="count(ancestor::w:tc/following-sibling::w:tc)"/>
  482.                         </xsl:variable>
  483.                         <xsl:variable name="rowbefore">
  484.                             <xsl:value-of select="count(ancestor::w:tr/preceding-sibling::w:tr)"/>
  485.                         </xsl:variable>
  486.                         <xsl:variable name="table" select="ancestor::w:tbl/w:tblPr"/>
  487.                         <xsl:choose>
  488.                             <xsl:when test="$table/w:tblBorders">
  489.                                 <xsl:variable name="Borders" select="$table/w:tblBorders"/>
  490.                                 <xsl:attribute name="fo:border-top"><xsl:choose><xsl:when test="number($rowbefore) > 0"><xsl:text>none</xsl:text></xsl:when><xsl:otherwise><xsl:value-of select="(number($Borders/w:top/@wx:bdrwidth)div 1440)*2.54"/><xsl:text>cm </xsl:text></xsl:otherwise></xsl:choose><xsl:if test="not(number($rowbefore) > 0)"><xsl:choose><xsl:when test="$Borders/w:top/@w:color ='auto'"><xsl:text>solid #000000</xsl:text></xsl:when><xsl:otherwise><xsl:text>solid #</xsl:text><xsl:value-of select="$Borders/w:top/@w:color"/></xsl:otherwise></xsl:choose></xsl:if></xsl:attribute>
  491.                                 <xsl:attribute name="fo:border-bottom"><xsl:value-of select="(number($Borders/w:bottom/@wx:bdrwidth)div 1440)*2.54"/><xsl:text>cm </xsl:text><xsl:choose><xsl:when test="$Borders/w:bottom/@w:color ='auto'"><xsl:text>solid #000000</xsl:text></xsl:when><xsl:otherwise><xsl:text>solid #</xsl:text><xsl:value-of select="$Borders/w:bottom/@w:color"/></xsl:otherwise></xsl:choose></xsl:attribute>
  492.                                 <xsl:attribute name="text:aidan"><xsl:value-of select="$cellafter"/></xsl:attribute>
  493.                                 <xsl:attribute name="fo:border-right"><xsl:choose><xsl:when test="number($cellafter) > 0"><xsl:text>none</xsl:text></xsl:when><xsl:otherwise><xsl:value-of select="(number($Borders/w:right/@wx:bdrwidth)div 1440)*2.54"/><xsl:text>cm </xsl:text></xsl:otherwise></xsl:choose><xsl:if test="not(number($cellafter) > 0)"><xsl:choose><xsl:when test="$Borders/w:right/@w:color ='auto'"><xsl:text>solid #000000</xsl:text></xsl:when><xsl:otherwise><xsl:text>solid #</xsl:text><xsl:value-of select="$Borders/w:right/@w:color"/></xsl:otherwise></xsl:choose></xsl:if></xsl:attribute>
  494.                                 <xsl:attribute name="fo:border-left"><xsl:value-of select="(number($Borders/w:left/@wx:bdrwidth)div 1440)*2.54"/><xsl:text>cm </xsl:text><xsl:choose><xsl:when test="$Borders/w:left/@w:color ='auto'"><xsl:text>solid #000000</xsl:text></xsl:when><xsl:otherwise><xsl:text>solid #</xsl:text><xsl:value-of select="$Borders/w:left/@w:color"/></xsl:otherwise></xsl:choose></xsl:attribute>
  495.                             </xsl:when>
  496.                             <xsl:otherwise>
  497.                                 <xsl:choose>
  498.                                     <xsl:when test="number($cellafter) > 0">
  499.                                         <xsl:attribute name="fo:border-right">none</xsl:attribute>
  500.                                     </xsl:when>
  501.                                     <xsl:otherwise>
  502.                                         <xsl:attribute name="fo:border-right">0.002cm solid #000000</xsl:attribute>
  503.                                     </xsl:otherwise>
  504.                                 </xsl:choose>
  505.                                 <xsl:attribute name="fo:border-left">0.002cm solid #000000</xsl:attribute>
  506.                                 <xsl:choose>
  507.                                     <xsl:when test="number($rowbefore) > 0">
  508.                                         <xsl:attribute name="fo:border-top">none</xsl:attribute>
  509.                                     </xsl:when>
  510.                                     <xsl:otherwise>
  511.                                         <xsl:attribute name="fo:border-top">0.002cm solid #000000</xsl:attribute>
  512.                                     </xsl:otherwise>
  513.                                 </xsl:choose>
  514.                                 <xsl:attribute name="fo:border-bottom">0.002cm solid #000000</xsl:attribute>
  515.                             </xsl:otherwise>
  516.                         </xsl:choose>
  517.                         <xsl:attribute name="fo:vertical-align">top</xsl:attribute>
  518.                         <xsl:apply-templates/>
  519.                     </xsl:element>
  520.                 </style:style>
  521.             </xsl:for-each>
  522.             <xsl:for-each select="/w:wordDocument/w:body//w:listPr">
  523.                 <xsl:variable name="currlistid" select="w:ilfo/@w:val"/>
  524.                 <xsl:variable name="currlist" select="."/>
  525.                 <xsl:variable name="rootlistid" select="/w:wordDocument/w:lists/w:list[@w:ilfo=$currlistid]/w:ilst/@w:val"/>
  526.                 <xsl:variable name="rootlist" select="/w:wordDocument/w:lists/w:listDef[@w:listDefId =$rootlistid ]"/>
  527.                 <xsl:if test="not(ancestor::w:p/preceding-sibling::w:p[1]/w:pPr/w:listPr/w:ilfo/@w:val= $currlistid) ">
  528.                     <xsl:element name="text:list-style">
  529.                         <!--<xsl:attribute name="style:name">List<xsl:number from="w:wordDocument/w:body" level="any"/></xsl:attribute>-->
  530.                         <xsl:attribute name="style:name">List<xsl:value-of select="count(preceding::w:listPr)"/></xsl:attribute>
  531.                         <xsl:for-each select="$rootlist/w:lvl">
  532.                             <xsl:variable name="listtype" select="w:nfc/@w:val"/>
  533.                             <xsl:choose>
  534.                                 <xsl:when test="$listtype =23">
  535.                                     <!-- nfcBullet: Bullet character. glu -->
  536.                                     <xsl:element name="text:list-level-style-bullet">
  537.                                         <xsl:call-template name="list-styles-common">
  538.                                             <xsl:with-param name="listtype" select="$listtype"/>
  539.                                             <xsl:with-param name="rootlist" select="$rootlist"/>
  540.                                             <xsl:with-param name="currlist" select="$currlist"/>
  541.                                         </xsl:call-template>
  542.                                     </xsl:element>
  543.                                 </xsl:when>
  544.                                 <xsl:otherwise>
  545.                                     <!-- all kinds of numbering characters. glu :( -->
  546.                                     <xsl:element name="text:list-level-style-number">
  547.                                         <xsl:call-template name="list-styles-common">
  548.                                             <xsl:with-param name="listtype" select="$listtype"/>
  549.                                             <xsl:with-param name="rootlist" select="$rootlist"/>
  550.                                             <xsl:with-param name="currlist" select="$currlist"/>
  551.                                         </xsl:call-template>
  552.                                     </xsl:element>
  553.                                 </xsl:otherwise>
  554.                             </xsl:choose>
  555.                         </xsl:for-each>
  556.                     </xsl:element>
  557.                 </xsl:if>
  558.             </xsl:for-each>
  559.             <xsl:for-each select="/w:wordDocument/w:body//w:sectPr">
  560.                 <xsl:element name="style:page-master">
  561.                     <xsl:attribute name="style:name">pm<xsl:number from="/w:wordDocument/w:body" level="any"/></xsl:attribute>
  562.                     <xsl:element name="style:properties">
  563.                         <xsl:attribute name="fo:page-width"><xsl:value-of select="(number(w:pgSz/@w:w) div 1440)*2.54"/>cm</xsl:attribute>
  564.                         <xsl:attribute name="fo:page-height"><xsl:value-of select="(number(w:pgSz/@w:h) div 1440)*2.54"/>cm</xsl:attribute>
  565.                         <xsl:choose>
  566.                             <xsl:when test="/w:wordDocument/w:docPr/w:gutterAtTop">
  567.                                 <xsl:attribute name="fo:margin-top"><xsl:value-of select="(number(w:pgMar/@w:top + w:pgMar/@w:gutter) div 1440)*2.54"/>cm</xsl:attribute>
  568.                                 <xsl:attribute name="fo:margin-left"><xsl:value-of select="(number(w:pgMar/@w:left) div 1440)*2.54"/>cm</xsl:attribute>
  569.                                 <xsl:attribute name="fo:margin-right"><xsl:value-of select="(number(w:pgMar/@w:right) div 1440)*2.54"/>cm</xsl:attribute>
  570.                             </xsl:when>
  571.                             <xsl:when test="w:rtlGutter">
  572.                                 <xsl:attribute name="fo:margin-top"><xsl:value-of select="(number(w:pgMar/@w:top) div 1440)*2.54"/>cm</xsl:attribute>
  573.                                 <xsl:attribute name="fo:margin-left"><xsl:value-of select="(number(w:pgMar/@w:left) div 1440)*2.54"/>cm</xsl:attribute>
  574.                                 <xsl:attribute name="fo:margin-right"><xsl:value-of select="(number(w:pgMar/@w:right + w:pgMar/@w:gutter) div 1440)*2.54"/>cm</xsl:attribute>
  575.                             </xsl:when>
  576.                             <xsl:otherwise>
  577.                                 <xsl:attribute name="fo:margin-top"><xsl:value-of select="(number(w:pgMar/@w:top) div 1440)*2.54"/>cm</xsl:attribute>
  578.                                 <xsl:attribute name="fo:margin-left"><xsl:value-of select="(number(w:pgMar/@w:left + w:pgMar/@w:gutter) div 1440)*2.54"/>cm</xsl:attribute>
  579.                                 <xsl:attribute name="fo:margin-right"><xsl:value-of select="(number(w:pgMar/@w:right) div 1440)*2.54"/>cm</xsl:attribute>
  580.                             </xsl:otherwise>
  581.                         </xsl:choose>
  582.                         <xsl:attribute name="fo:margin-bottom"><xsl:value-of select="(number(w:pgMar/@w:bottom) div 1440)*2.54"/>cm</xsl:attribute>
  583.                         <xsl:attribute name="style:footnote-max-height"><xsl:value-of select="(number(w:pgMar/@w:footer) div 1440)*2.54"/></xsl:attribute>
  584.                         <xsl:if test="w:pgSz/@w:orient">
  585.                             <xsl:attribute name="style:print-orientation"><xsl:value-of select="w:pgSz/@w:orient"/></xsl:attribute>
  586.                         </xsl:if>
  587.                     </xsl:element>
  588.                 </xsl:element>
  589.                 <xsl:if test="w:cols/@w:num">
  590.                     <!-- create sction property-->
  591.                     <xsl:element name="style:style">
  592.                         <xsl:attribute name="style:name">sect<xsl:value-of select="count(preceding::w:sectPr[w:cols/@w:num])"/></xsl:attribute>
  593.                         <xsl:attribute name="style:family">section</xsl:attribute>
  594.                         <xsl:element name="style:properties">
  595.                             <xsl:element name="style:columns">
  596.                                 <xsl:attribute name="fo:column-count"><xsl:value-of select="number(w:cols/@w:num)"/></xsl:attribute>
  597.                                 <xsl:attribute name="fo:column-gap"><xsl:value-of select="(number(w:cols/@w:space)div 1440)*2.54"/>cm</xsl:attribute>
  598.                             </xsl:element>
  599.                         </xsl:element>
  600.                     </xsl:element>
  601.                 </xsl:if>
  602.             </xsl:for-each>
  603.         </xsl:element>
  604.         <office:master-styles>
  605.             <xsl:for-each select="/w:wordDocument/w:body//w:sectPr">
  606.                 <!-- style:page-master style:style-->
  607.                 <xsl:element name="style:master-page">
  608.                     <xsl:variable name="master-page-name">
  609.                         <xsl:number count="w:sectPr" from="/w:wordDocument/w:body" level="any"/>
  610.                     </xsl:variable>
  611.                     <xsl:attribute name="style:name"><xsl:value-of select="concat('Standard',$master-page-name)"/></xsl:attribute>
  612.                     <xsl:attribute name="style:page-master-name"><xsl:value-of select="concat('pm', $master-page-name)"/></xsl:attribute>
  613.                     <xsl:if test="following::w:sectPr">
  614.                         <xsl:attribute name="style:next-style-name">Standard<xsl:value-of select="$master-page-name +1"/></xsl:attribute>
  615.                     </xsl:if>
  616.                     <!-- Headers and footers-->
  617.                     <xsl:element name="style:header-style">
  618.                         <xsl:element name="style:properties">
  619.                             <xsl:attribute name="fo:min-height"><xsl:value-of select="(number(w:pgMar/@w:header)div 1440)*2.54"/>cm</xsl:attribute>
  620.                             <xsl:attribute name="fo:margin-bottom">0.792cm</xsl:attribute>
  621.                             <xsl:attribute name="style:dynamic-spacing">true</xsl:attribute>
  622.                         </xsl:element>
  623.                     </xsl:element>
  624.                     <xsl:element name="style:footer-style">
  625.                         <xsl:element name="style:properties">
  626.                             <xsl:attribute name="fo:min-height"><xsl:value-of select="(number(w:pgMar/@w:footer)div 1440)*2.54"/>cm</xsl:attribute>
  627.                             <xsl:attribute name="fo:margin-top">0.792cm</xsl:attribute>
  628.                             <xsl:attribute name="style:dynamic-spacing">true</xsl:attribute>
  629.                         </xsl:element>
  630.                     </xsl:element>
  631.                     <xsl:if test="w:hdr and not(w:titlePg)">
  632.                         <xsl:element name="style:header">
  633.                             <xsl:apply-templates select="w:hdr[@w:type='odd']/*"/>
  634.                         </xsl:element>
  635.                         <xsl:element name="style:header-left">
  636.                             <xsl:apply-templates select="w:hdr[@w:type='even']/*"/>
  637.                         </xsl:element>
  638.                     </xsl:if>
  639.                     <xsl:if test="w:ftr and not(w:titlePg)">
  640.                         <xsl:element name="style:footer">
  641.                             <xsl:apply-templates select="w:ftr[@w:type='odd']/*"/>
  642.                         </xsl:element>
  643.                         <xsl:element name="style:footer-left">
  644.                             <xsl:apply-templates select="w:ftr[@w:type='even']/*"/>
  645.                         </xsl:element>
  646.                     </xsl:if>
  647.                 </xsl:element>
  648.             </xsl:for-each>
  649.         </office:master-styles>
  650.     </xsl:template>
  651.     <xsl:template match="w:style">
  652.         <xsl:element name="style:style">
  653.             <xsl:attribute name="style:name"><xsl:value-of select="@w:styleId"/></xsl:attribute>
  654.             <xsl:if test="w:basedOn">
  655.                 <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:basedOn/@w:val"/></xsl:attribute>
  656.             </xsl:if>
  657.             <xsl:if test="w:next">
  658.                 <xsl:attribute name="style:next-style-name"><xsl:value-of select="w:next/@w:val"/></xsl:attribute>
  659.             </xsl:if>
  660.             <xsl:choose>
  661.                 <xsl:when test="@w:type = 'character' ">
  662.                     <xsl:attribute name="style:family">text</xsl:attribute>
  663.                 </xsl:when>
  664.                 <xsl:when test="@w:type = 'list' ">
  665.                     <xsl:attribute name="style:family">text</xsl:attribute>
  666.                 </xsl:when>
  667.                 <!-- table, paragraph are the same as in Writer . glu -->
  668.                 <xsl:when test="@w:type">
  669.                     <xsl:attribute name="style:family"><xsl:value-of select="@w:type"/></xsl:attribute>
  670.                 </xsl:when>
  671.                 <xsl:otherwise>
  672.                     <xsl:attribute name="style:family">text</xsl:attribute>
  673.                 </xsl:otherwise>
  674.             </xsl:choose>
  675.             <xsl:element name="style:properties">
  676.                 <xsl:apply-templates select="w:rPr/*"/>
  677.                 <xsl:apply-templates select="w:pPr/*"/>
  678.                 <xsl:call-template name="paragraph-properties"/>
  679.             </xsl:element>
  680.         </xsl:element>
  681.     </xsl:template>
  682.     <xsl:template name="list-styles-common">
  683.         <xsl:param name="listtype"/>
  684.         <xsl:param name="rootlist"/>
  685.         <xsl:param name="currlist"/>
  686.         <xsl:variable name="currlevel" select="number(@w:ilvl)"/>
  687.         <xsl:variable name="startval" select="w:start/@w:val"/>
  688.         <xsl:attribute name="text:level"><xsl:value-of select="$currlevel+1"/></xsl:attribute>
  689.         <xsl:choose>
  690.             <xsl:when test="$listtype = 23">
  691.                 <!-- bullet character. glu -->
  692.                 <xsl:attribute name="text:style-name">Bullet Symbols</xsl:attribute>
  693.                 <xsl:attribute name="text:bullet-char"><xsl:value-of select="w:lvlText/@w:val"/></xsl:attribute>
  694.             </xsl:when>
  695.             <xsl:when test="($listtype > 0) and ($listtype < 6)">
  696.                 <xsl:attribute name="text:style-name">Numbering Symbols</xsl:attribute>
  697.                 <xsl:if test="$startval">
  698.                     <xsl:attribute name="text:start-value"><xsl:value-of select="$startval"/></xsl:attribute>
  699.                 </xsl:if>
  700.                 <xsl:attribute name="text:display-levels"><xsl:value-of select="string-length(w:lvlText/@w:val) - string-length(translate(w:lvlText/@w:val,'%','') )"/></xsl:attribute>
  701.                 <xsl:choose>
  702.                     <xsl:when test="$listtype = 1">
  703.                         <!-- nfcUCRoman: Uppercase roman -->
  704.                         <xsl:attribute name="style:num-format">I</xsl:attribute>
  705.                     </xsl:when>
  706.                     <xsl:when test="$listtype = 2">
  707.                         <!-- nfcLCRoman: Lowercase roman -->
  708.                         <xsl:attribute name="style:num-format">i</xsl:attribute>
  709.                     </xsl:when>
  710.                     <xsl:when test="$listtype = 3">
  711.                         <!-- nfcUCLetter: Uppercase alpha -->
  712.                         <xsl:attribute name="style:num-format">A</xsl:attribute>
  713.                     </xsl:when>
  714.                     <xsl:when test="$listtype = 4">
  715.                         <!-- nfcLCLetter: Lowercase alpah -->
  716.                         <xsl:attribute name="style:num-format">a</xsl:attribute>
  717.                     </xsl:when>
  718.                     <xsl:when test="$listtype = 5">
  719.                         <!-- nfcOrdinal: Ordinal -->
  720.                         <xsl:attribute name="style:num-format">1</xsl:attribute>
  721.                     </xsl:when>
  722.                 </xsl:choose>
  723.                 <xsl:attribute name="style:num-suffix">.</xsl:attribute>
  724.             </xsl:when>
  725.             <xsl:otherwise>
  726.                 <xsl:attribute name="text:style-name">Numbering Symbols</xsl:attribute>
  727.                 <xsl:if test="$startval">
  728.                     <xsl:attribute name="text:start-value"><xsl:value-of select="$startval"/></xsl:attribute>
  729.                 </xsl:if>
  730.                 <xsl:attribute name="text:display-levels"><xsl:value-of select="string-length(w:lvlText/@w:val) - string-length(translate(w:lvlText/@w:val,'%','') )"/></xsl:attribute>
  731.                 <!-- can't support so many list types (totally 56) as in Word 2003. :( glu -->
  732.                 <xsl:attribute name="style:num-format">1</xsl:attribute>
  733.                 <xsl:attribute name="style:num-suffix">.</xsl:attribute>
  734.             </xsl:otherwise>
  735.         </xsl:choose>
  736.         <xsl:element name="style:properties">
  737.             <!-- Find the node that corresponds to the level being processed. We can use this to determine the indentation to be used-->
  738.             <xsl:variable name="currNode" select="/w:wordDocument/w:body//w:listPr[w:ilvl/@w:val = $currlevel][w:ilfo/@w:val = $currlist/w:ilfo/@w:val]"/>
  739.             <xsl:choose>
  740.                 <xsl:when test="($currNode/wx:t/@wx:wTabBefore ) and ($currNode/wx:t/@wx:wTabAfter ) ">
  741.                     <xsl:attribute name="text:space-before"><xsl:value-of select="(number($currNode/wx:t/@wx:wTabBefore)div 1440)*2.54"/>cm</xsl:attribute>
  742.                     <xsl:attribute name="text:min-label-distance"><xsl:value-of select="(number($currNode/wx:t/@wx:wTabAfter)div 1440)*2.54"/>cm</xsl:attribute>
  743.                 </xsl:when>
  744.                 <xsl:otherwise>
  745.                     <xsl:attribute name="text:space-before"><xsl:value-of select="((number(w:pPr/w:ind/@w:left)  div 1440)*2.54) "/>cm</xsl:attribute>
  746.                     <xsl:attribute name="text:min-label-distance"><xsl:value-of select="(number($currlist/wx:t/@wx:wTabAfter) div 1440)*2.54"/>cm</xsl:attribute>
  747.                 </xsl:otherwise>
  748.             </xsl:choose>
  749.             <xsl:if test="w:rPr/w:rFonts">
  750.                 <xsl:if test="w:rPr/w:rFonts/@w:ascii">
  751.                     <xsl:attribute name="style:font-name"><xsl:value-of select="w:rPr/w:rFonts/@w:ascii"/></xsl:attribute>
  752.                 </xsl:if>
  753.                 <xsl:if test="w:rPr/w:rFonts/@w:fareast">
  754.                     <xsl:attribute name="style:font-name-asian"><xsl:value-of select="w:rPr/w:rFonts/@w:fareast"/></xsl:attribute>
  755.                 </xsl:if>
  756.                 <xsl:if test="w:rPr/w:rFonts/@w:cs">
  757.                     <xsl:attribute name="style:font-name-complex"><xsl:value-of select="w:rPr/w:rFonts/@w:cs"/></xsl:attribute>
  758.                 </xsl:if>
  759.             </xsl:if>
  760.         </xsl:element>
  761.     </xsl:template>
  762.     <xsl:template match="w:body">
  763.         <xsl:element name="office:body">
  764.             <xsl:apply-templates/>
  765.         </xsl:element>
  766.     </xsl:template>
  767.     <!-- avoid listPr in textbox. :( glu -->
  768.     <xsl:template match="w:p[w:pPr/w:listPr[w:ilvl and w:ilfo]]">
  769.         <xsl:call-template name="genlist"/>
  770.     </xsl:template>
  771.     <xsl:template match="w:hlink">
  772.         <xsl:element name="text:a">
  773.             <xsl:attribute name="xlink:type">simple</xsl:attribute>
  774.             <xsl:choose>
  775.                 <xsl:when test="@w:dest and @w:bookmark">
  776.                     <xsl:attribute name="xlink:href"><xsl:value-of select="concat( @w:dest, concat('#', @w:bookmark) )"/></xsl:attribute>
  777.                 </xsl:when>
  778.                 <xsl:when test="@w:dest">
  779.                     <xsl:attribute name="xlink:href"><xsl:value-of select="@w:dest"/></xsl:attribute>
  780.                 </xsl:when>
  781.                 <xsl:when test="@w:bookmark">
  782.                     <xsl:attribute name="xlink:href"><xsl:value-of select="concat('#', @w:bookmark)"/></xsl:attribute>
  783.                 </xsl:when>
  784.             </xsl:choose>
  785.             <xsl:if test="@w:target">
  786.                 <xsl:attribute name="office:target-frame-name"><xsl:value-of select="@w:target"/></xsl:attribute>
  787.             </xsl:if>
  788.             <xsl:apply-templates/>
  789.         </xsl:element>
  790.     </xsl:template>
  791.     <xsl:template match="w:p">
  792.         <xsl:choose>
  793.             <!-- because word treats page breaks as separate tags, we must split some paragraphs up so that we can 
  794.             give the sub para a fo:break-before ="page" attribute    -->
  795.             <xsl:when test="w:r[w:br/@w:type='page']  ">
  796.                 <xsl:call-template name="processPageBreaks"/>
  797.             </xsl:when>
  798.             <xsl:otherwise>
  799.                 <xsl:call-template name="commonParagraph"/>
  800.             </xsl:otherwise>
  801.         </xsl:choose>
  802.     </xsl:template>
  803.     <xsl:template name="processPageBreaks">
  804.         <xsl:variable name="pageBreak" select="w:r[w:br/@w:type='page']"/>
  805.         <xsl:call-template name="createSubParagraph">
  806.             <xsl:with-param name="list" select="$pageBreak[1]/preceding-sibling::w:r"/>
  807.             <xsl:with-param name="pageBreak"/>
  808.             <xsl:with-param name="needsPageBreak">false</xsl:with-param>
  809.         </xsl:call-template>
  810.         <xsl:for-each select="$pageBreak">
  811.             <xsl:call-template name="createSubParagraph">
  812.                 <xsl:with-param name="list" select="./following-sibling::w:r[preceding::w:r/w:br = '.']"/>
  813.                 <xsl:with-param name="pageBreak" select="."/>
  814.                 <xsl:with-param name="needsPageBreak">true</xsl:with-param>
  815.             </xsl:call-template>
  816.         </xsl:for-each>
  817.     </xsl:template>
  818.     <xsl:template name="createSubParagraph">
  819.         <xsl:param name="list"/>
  820.         <xsl:param name="pageBreak"/>
  821.         <xsl:param name="needsPageBreak"/>
  822.         <xsl:if test="(count($list) > 0) or ($needsPageBreak ='true') ">
  823.             <xsl:element name="text:p">
  824.                 <xsl:choose>
  825.                     <xsl:when test="$needsPageBreak = 'true'">
  826.                         <xsl:choose>
  827.                             <xsl:when test="ancestor::w:p/w:pPr">
  828.                                 <xsl:attribute name="text:style-name">P<xsl:number from="/w:wordDocument/w:body" level="any" count="w:pPr"/></xsl:attribute>
  829.                             </xsl:when>
  830.                             <xsl:otherwise>
  831.                                 <xsl:attribute name="text:style-name">PageBreak</xsl:attribute>
  832.                             </xsl:otherwise>
  833.                         </xsl:choose>
  834.                     </xsl:when>
  835.                 </xsl:choose>
  836.                 <xsl:if test="$pageBreak">
  837.                     <xsl:apply-templates select="$pageBreak"/>
  838.                 </xsl:if>
  839.                 <xsl:apply-templates select="$list"/>
  840.             </xsl:element>
  841.         </xsl:if>
  842.     </xsl:template>
  843.     <!-- strange enough, WordML allows bookmarks out of w:p, but this isn't supported by StarWriter. To be patched. :( glu -->
  844.     <xsl:template match="aml:annotation[@w:type = 'Word.Bookmark.Start']">
  845.         <text:bookmark-start text:name="{@w:name}"/>
  846.     </xsl:template>
  847.     <xsl:template match="aml:annotation[@w:type = 'Word.Bookmark.End']">
  848.         <xsl:variable name="id" select="@aml:id"/>
  849.         <text:bookmark-end text:name="{preceding::aml:annotation[@aml:id = $id]/@w:name}"/>
  850.     </xsl:template>
  851.     <xsl:template name="commonParagraph">
  852.         <!-- Heading 1 to 9  or normal paragraph-->
  853.         <xsl:choose>
  854.             <xsl:when test="starts-with(w:pPr/w:pStyle/@w:val, 'Heading')">
  855.                 <xsl:variable name="styleid" select="w:pPr/w:pStyle/@w:val"/>
  856.                 <xsl:element name="text:h">
  857.                     <xsl:variable name="outlinelevel" select="number(/w:wordDocument/w:styles/w:style[@w:styleId = $styleid]/w:pPr/w:outlineLvl/@w:val)+1"/>
  858.                     <xsl:if test="$outlinelevel">
  859.                         <xsl:attribute name="text:level"><xsl:value-of select="$outlinelevel"/></xsl:attribute>
  860.                     </xsl:if>
  861.                     <xsl:call-template name="commonParagraphAttributes"/>
  862.                     <xsl:apply-templates/>
  863.                 </xsl:element>
  864.             </xsl:when>
  865.             <xsl:when test="w:r/w:instrText and contains(w:r/w:instrText , 'HYPERLINK')">
  866.                 <!-- handling another type of Hyperlink address in w:body.cp tom chen. Acutally they're from Field features, a complex one. glu -->
  867.                 <xsl:variable name="hyper-str" select="normalize-space(w:r/w:instrText)"/>
  868.                 <xsl:variable name="hyper-dest" select="substring-before( substring($hyper-str, 12), '"')"/>
  869.                 <xsl:variable name="hyper-bookmark">
  870.                     <xsl:choose>
  871.                         <xsl:when test="contains( $hyper-str, ' \l ')">
  872.                             <xsl:value-of select="concat( '#', substring-before( substring-after( substring-after( $hyper-str, ' \l '), '"'), '"') )"/>
  873.                         </xsl:when>
  874.                         <xsl:otherwise/>
  875.                     </xsl:choose>
  876.                 </xsl:variable>
  877.                 <xsl:element name="text:p">
  878.                     <xsl:element name="text:a">
  879.                         <xsl:attribute name="xlink:type">simple</xsl:attribute>
  880.                         <xsl:attribute name="xlink:href"><xsl:value-of select="concat( $hyper-dest, $hyper-bookmark)"/></xsl:attribute>
  881.                         <xsl:apply-templates/>
  882.                     </xsl:element>
  883.                 </xsl:element>
  884.             </xsl:when>
  885.             <xsl:otherwise>
  886.                 <xsl:element name="text:p">
  887.                     <xsl:call-template name="commonParagraphAttributes"/>
  888.                     <xsl:apply-templates/>
  889.                 </xsl:element>
  890.             </xsl:otherwise>
  891.         </xsl:choose>
  892.     </xsl:template>
  893.     <xsl:template name="commonParagraphAttributes">
  894.         <xsl:choose>
  895.             <xsl:when test="w:pPr">
  896.                 <!-- count="w:pPr" doesn't work well, don't know  the reason actually. glu :( -->
  897.                 <xsl:attribute name="text:style-name">P<xsl:number from="/w:wordDocument/w:body" level="any" count="w:p[w:pPr]"/></xsl:attribute>
  898.             </xsl:when>
  899.             <xsl:when test="generate-id(ancestor::wx:sect/descendant::w:p[1]) = generate-id(.)">
  900.                 <!-- create the leading paragraph style name in one section for master page style application, glu -->
  901.                 <xsl:variable name="paragraph-number">
  902.                     <xsl:number from="/w:wordDocument/w:body" level="any" count="w:p[w:pPr]"/>
  903.                 </xsl:variable>
  904.                 <xsl:attribute name="text:style-name">P<xsl:value-of select="number($paragraph-number)"/>_1</xsl:attribute>
  905.             </xsl:when>
  906.             <xsl:when test="not(w:pPr) and (descendant::w:br[@w:type = 'column'] or ancestor::wx:sect/descendant::w:sectPr[w:cols/@w:num > 1])">
  907.                 <xsl:attribute name="text:style-name">ColumnBreakPara</xsl:attribute>
  908.             </xsl:when>
  909.         </xsl:choose>
  910.     </xsl:template>
  911.     <xsl:template match="w:pPr"/>
  912.     <xsl:template match="w:rPr"/>
  913.     <xsl:template match="wx:sub-section">
  914.         <xsl:apply-templates/>
  915.     </xsl:template>
  916.     <xsl:template match="w:t">
  917.         <xsl:choose>
  918.             <xsl:when test="string(.) = ' ' ">
  919.                 <xsl:element name="text:s"/>
  920.             </xsl:when>
  921.             <xsl:when test="contains(.,'  ')">
  922.                 <xsl:call-template name="replace-spaces">
  923.                     <xsl:with-param name="curr-string" select="."/>
  924.                 </xsl:call-template>
  925.             </xsl:when>
  926.             <xsl:otherwise>
  927.                 <xsl:apply-templates/>
  928.             </xsl:otherwise>
  929.         </xsl:choose>
  930.     </xsl:template>
  931.     <xsl:template name="replace-spaces">
  932.         <xsl:param name="curr-string"/>
  933.         <xsl:if test="contains($curr-string,'  ')">
  934.             <xsl:value-of select="substring-before($curr-string,'  ')"/>
  935.             <text:s text:c="2"/>
  936.             <xsl:variable name="next-string" select="substring-after($curr-string,'  ')"/>
  937.             <xsl:choose>
  938.                 <xsl:when test="contains($next-string, '  ')">
  939.                     <xsl:call-template name="replace-spaces">
  940.                         <xsl:with-param name="curr-string" select="$next-string"/>
  941.                     </xsl:call-template>
  942.                 </xsl:when>
  943.                 <xsl:otherwise>
  944.                     <xsl:value-of select="$next-string"/>
  945.                 </xsl:otherwise>
  946.             </xsl:choose>
  947.         </xsl:if>
  948.     </xsl:template>
  949.     <xsl:template match="w:tab[parent::w:r]">
  950.         <xsl:element name="text:tab-stop"/>
  951.     </xsl:template>
  952.     <xsl:template match="w:hdr">
  953.         <!-- empty template to ignore inline processing of header. These are handled as part of the master style in styles.xsl    -->
  954.     </xsl:template>
  955.     <xsl:template match="w:ftr">
  956.         <!-- empty template to ignore inline processing of header. These are handled as part of the master style in styles.xsl    -->
  957.     </xsl:template>
  958.     <!-- WordML contains multiple w:t within one w:r, so in Star Writer text:span should correspond to w:t glu -->
  959.     <xsl:template match="w:r">
  960.         <xsl:if test="w:br[@w:type='text-wrapping' or not(@w:type)]">
  961.             <xsl:element name="text:line-break"/>
  962.         </xsl:if>
  963.         <xsl:choose>
  964.             <xsl:when test="w:rPr/w:vanish">
  965.                 <text:hidden-text text:is-hidden="true" text:condition="" text:string-value="{.}"/>
  966.             </xsl:when>
  967.             <xsl:when test="aml:annotation/@w:type = 'Word.Comment'">
  968.                 <office:annotation office:author="{aml:annotation/@aml:author}" office:create-date="{substring(aml:annotation/@aml:createdate,1,10)}" office:display="true">
  969.                     <xsl:apply-templates/>
  970.                 </office:annotation>
  971.             </xsl:when>
  972.             <xsl:when test="(preceding-sibling::w:r) or (w:rPr)">
  973.                 <xsl:element name="text:span">
  974.                     <xsl:choose>
  975.                         <xsl:when test="w:rPr/w:rStyle">
  976.                             <xsl:attribute name="text:style-name"><xsl:value-of select="w:rPr/w:rStyle/@w:val"/></xsl:attribute>
  977.                         </xsl:when>
  978.                         <xsl:when test="w:rPr">
  979.                             <xsl:attribute name="text:style-name">T<xsl:value-of select="count(preceding::w:rPr)"/></xsl:attribute>
  980.                         </xsl:when>
  981.                     </xsl:choose>
  982.                     <xsl:apply-templates/>
  983.                 </xsl:element>
  984.             </xsl:when>
  985.             <xsl:otherwise>
  986.                 <xsl:apply-templates/>
  987.             </xsl:otherwise>
  988.         </xsl:choose>
  989.     </xsl:template>
  990.     <!--
  991.     <xsl:template match="w:br[@w:type='text-wrapping' or not(@w:type)]">
  992.         <text:line-break/>
  993.     </xsl:template>
  994.     <xsl:template match="aml:annotation[@w:type = 'Word.Comment']">
  995.         <office:annotation office:author="{@aml:author}" office:create-date="{substring(@aml:createdate,1,10)}" office:display="true">
  996.             <xsl:apply-templates/>
  997.         </office:annotation>
  998.     </xsl:template>
  999.     <xsl:template match="w:rPr/w:vanish">
  1000.         <text:hidden-text text:is-hidden="true" text:condition="" text:string-value="{../..}"/>
  1001.     </xsl:template>
  1002.     <xsl:template match="w:t">
  1003.         <xsl:element name="text:span">
  1004.             <xsl:if test="preceding-sibling::w:rPr">
  1005.                 <xsl:attribute name="text:style-name">T<xsl:value-of select="count(preceding::w:rPr)"/></xsl:attribute>
  1006.             </xsl:if>
  1007.             <xsl:apply-templates/>
  1008.         </xsl:element>
  1009.     </xsl:template>
  1010.     -->
  1011.     <xsl:template match="node()[name() = 'w:vertAlign' or name() = 'w:position']">
  1012.         <xsl:variable name="height">
  1013.             <xsl:choose>
  1014.                 <xsl:when test="parent::w:rPr/w:vertAlign[@w:val = 'superscript' or @w:val = 'subscript']">58%</xsl:when>
  1015.                 <xsl:otherwise>100%</xsl:otherwise>
  1016.             </xsl:choose>
  1017.         </xsl:variable>
  1018.         <xsl:variable name="position">
  1019.             <xsl:choose>
  1020.                 <xsl:when test="parent::w:rPr/w:position">
  1021.                     <!-- con't get font height easily, so just set w:val as percentage. glu -->
  1022.                     <xsl:value-of select="concat( parent::w:rPr/w:position/@w:val, '%')"/>
  1023.                 </xsl:when>
  1024.                 <xsl:when test="parent::w:rPr/w:vertAlign[@w:val = 'superscript']">super</xsl:when>
  1025.                 <xsl:when test="parent::w:rPr/w:vertAlign[@w:val = 'subscript']">sub</xsl:when>
  1026.             </xsl:choose>
  1027.         </xsl:variable>
  1028.         <xsl:attribute name="style:text-position"><xsl:value-of select="concat(concat( $position, ' '), $height)"/></xsl:attribute>
  1029.     </xsl:template>
  1030.     <xsl:template match="w:sz">
  1031.         <xsl:attribute name="fo:font-size"><xsl:value-of select="concat( number(@w:val) div 2, 'pt')"/></xsl:attribute>
  1032.         <xsl:attribute name="fo:font-size-asian"><xsl:value-of select="concat( number(@w:val) div 2, 'pt')"/></xsl:attribute>
  1033.     </xsl:template>
  1034.     <xsl:template match="w:sz-cs">
  1035.         <xsl:attribute name="fo:font-size-complex"><xsl:value-of select="concat( number(@w:val) div 2, 'pt')"/></xsl:attribute>
  1036.     </xsl:template>
  1037.     <xsl:template match="w:i">
  1038.         <xsl:attribute name="fo:font-style">italic</xsl:attribute>
  1039.         <xsl:attribute name="fo:font-style-asian">italic</xsl:attribute>
  1040.     </xsl:template>
  1041.     <xsl:template match="w:i-cs">
  1042.         <xsl:attribute name="fo:font-style-complex">italic</xsl:attribute>
  1043.     </xsl:template>
  1044.     <xsl:template match="w:b">
  1045.         <xsl:attribute name="fo:font-weight">bold</xsl:attribute>
  1046.         <xsl:attribute name="fo:font-weight-asian">bold</xsl:attribute>
  1047.     </xsl:template>
  1048.     <xsl:template match="w:b-cs">
  1049.         <xsl:attribute name="fo:font-weight-complex">bold</xsl:attribute>
  1050.     </xsl:template>
  1051.     <xsl:template match="w:u">
  1052.         <xsl:choose>
  1053.             <xsl:when test="@w:val = 'words'">
  1054.                 <xsl:attribute name="style:text-underline">single</xsl:attribute>
  1055.                 <xsl:attribute name="fo:score-spaces">false</xsl:attribute>
  1056.             </xsl:when>
  1057.             <xsl:when test="@w:val = 'thick'">
  1058.                 <xsl:attribute name="style:text-underline">bold</xsl:attribute>
  1059.             </xsl:when>
  1060.             <xsl:when test="@w:val = 'dotted-heavy'">
  1061.                 <xsl:attribute name="style:text-underline">bold-dotted</xsl:attribute>
  1062.             </xsl:when>
  1063.             <xsl:when test="@w:val = 'dashed-heavy'">
  1064.                 <xsl:attribute name="style:text-underline">bold-dash</xsl:attribute>
  1065.             </xsl:when>
  1066.             <xsl:when test="@w:val = 'dash-long'">
  1067.                 <xsl:attribute name="style:text-underline">long-dash</xsl:attribute>
  1068.             </xsl:when>
  1069.             <xsl:when test="@w:val = 'dash-long-heavy'">
  1070.                 <xsl:attribute name="style:text-underline">bold-long-dash</xsl:attribute>
  1071.             </xsl:when>
  1072.             <xsl:when test="@w:val = 'dash-dot-heavy'">
  1073.                 <xsl:attribute name="style:text-underline">bold-dot-dash</xsl:attribute>
  1074.             </xsl:when>
  1075.             <xsl:when test="@w:val = 'dash-dot-dot-heavy'">
  1076.                 <xsl:attribute name="style:text-underline">bold-dot-dot-dash</xsl:attribute>
  1077.             </xsl:when>
  1078.             <xsl:when test="@w:val = 'wavy-heavy'">
  1079.                 <xsl:attribute name="style:text-underline">bold-wave</xsl:attribute>
  1080.             </xsl:when>
  1081.             <xsl:when test="@w:val = 'wavy-double'">
  1082.                 <xsl:attribute name="style:text-underline">double-wave</xsl:attribute>
  1083.             </xsl:when>
  1084.             <xsl:otherwise>
  1085.                 <xsl:attribute name="style:text-underline"><xsl:value-of select="@w:val"/></xsl:attribute>
  1086.             </xsl:otherwise>
  1087.         </xsl:choose>
  1088.         <xsl:if test="@w:color and not(@w:color = 'auto')">
  1089.             <xsl:attribute name="style:text-underline-color"><xsl:value-of select="concat( '#', @w:color)"/></xsl:attribute>
  1090.         </xsl:if>
  1091.     </xsl:template>
  1092.     <xsl:template match="w:shadow">
  1093.         <xsl:attribute name="style:text-shadow">1pt 1pt</xsl:attribute>
  1094.         <xsl:attribute name="fo:text-shadow">1pt 1pt</xsl:attribute>
  1095.     </xsl:template>
  1096.     <xsl:template match="w:strike">
  1097.         <xsl:attribute name="style:text-crossing-out">single-line</xsl:attribute>
  1098.     </xsl:template>
  1099.     <xsl:template match="w:dstrike">
  1100.         <xsl:attribute name="style:text-crossing-out">double-line</xsl:attribute>
  1101.     </xsl:template>
  1102.     <xsl:template match="w:color[not(@w:val = 'auto')]">
  1103.         <xsl:attribute name="fo:color">#<xsl:value-of select="@w:val"/></xsl:attribute>
  1104.     </xsl:template>
  1105.     <xsl:template match="w:smallCaps">
  1106.         <xsl:attribute name="fo:font-variant">small-caps</xsl:attribute>
  1107.     </xsl:template>
  1108.     <xsl:template match="w:caps">
  1109.         <xsl:attribute name="fo:text-transform">uppercase</xsl:attribute>
  1110.     </xsl:template>
  1111.     <xsl:template match="w:imprint">
  1112.         <xsl:attribute name="style:font-relief">engraved</xsl:attribute>
  1113.     </xsl:template>
  1114.     <xsl:template match="w:emboss">
  1115.         <xsl:attribute name="style:font-relief">embossed</xsl:attribute>
  1116.     </xsl:template>
  1117.     <xsl:template match="w:outline">
  1118.         <xsl:attribute name="style:text-outline">true</xsl:attribute>
  1119.     </xsl:template>
  1120.     <xsl:template match="w:w[@w:val]">
  1121.         <xsl:attribute name="style:text-scale"><xsl:value-of select="@w:val"/></xsl:attribute>
  1122.     </xsl:template>
  1123.     <xsl:template match="w:em">
  1124.         <xsl:choose>
  1125.             <xsl:when test="@w:val = 'comma'">
  1126.                 <xsl:attribute name="style:text-emphasize">accent below</xsl:attribute>
  1127.             </xsl:when>
  1128.             <xsl:when test="@w:val = 'under-dot'">
  1129.                 <xsl:attribute name="style:text-emphasize">disc below</xsl:attribute>
  1130.             </xsl:when>
  1131.             <xsl:otherwise>
  1132.                 <xsl:attribute name="style:text-emphasize"><xsl:value-of select="concat( @w:val, ' below')"/></xsl:attribute>
  1133.             </xsl:otherwise>
  1134.         </xsl:choose>
  1135.     </xsl:template>
  1136.     <xsl:template match="w:spacing[parent::w:rPr]">
  1137.         <xsl:attribute name="fo:letter-spacing"><xsl:value-of select="concat( floor(number(@w:val div 1440) * 2540) div 1000, 'cm')"/></xsl:attribute>
  1138.     </xsl:template>
  1139.     <xsl:template match="w:effect[@w:val = 'blink-background']">
  1140.         <xsl:attribute name="style:text-blinking">true</xsl:attribute>
  1141.         <xsl:attribute name="style:text-background-color">#000000</xsl:attribute>
  1142.     </xsl:template>
  1143.     <xsl:template match="w:lang">
  1144.         <xsl:if test="@w:val">
  1145.             <xsl:attribute name="fo:language"><xsl:value-of select="substring-before( @w:val, '-')"/></xsl:attribute>
  1146.             <xsl:attribute name="fo:country"><xsl:value-of select="substring-after( @w:val, '-')"/></xsl:attribute>
  1147.         </xsl:if>
  1148.         <xsl:if test="@w:fareast">
  1149.             <xsl:attribute name="fo:language-asian"><xsl:value-of select="substring-before( @w:fareast, '-')"/></xsl:attribute>
  1150.             <xsl:attribute name="fo:country-asian"><xsl:value-of select="substring-after( @w:fareast, '-')"/></xsl:attribute>
  1151.         </xsl:if>
  1152.         <xsl:if test="@w:bidi">
  1153.             <xsl:attribute name="fo:language-complex"><xsl:value-of select="substring-before( @w:bidi, '-')"/></xsl:attribute>
  1154.             <xsl:attribute name="fo:country-complex"><xsl:value-of select="substring-after( @w:bidi, '-')"/></xsl:attribute>
  1155.         </xsl:if>
  1156.     </xsl:template>
  1157.     <xsl:template match="wx:font[not(parent::w:listPr)]">
  1158.         <xsl:attribute name="style:font-name"><xsl:value-of select="@wx:val"/></xsl:attribute>
  1159.         <xsl:attribute name="style:font-name-asian"><xsl:value-of select="@wx:val"/></xsl:attribute>
  1160.         <xsl:attribute name="style:font-name-complex"><xsl:value-of select="@wx:val"/></xsl:attribute>
  1161.     </xsl:template>
  1162.     <xsl:template match="wx:sect">
  1163.         <!-- We handle Columns as seperate Sections to allow for different numbers of columns on the same page-->
  1164.         <xsl:choose>
  1165.             <xsl:when test="descendant::w:sectPr[w:cols/@w:num > 1]">
  1166.                 <xsl:element name="text:section">
  1167.                     <xsl:attribute name="text:style-name">sect<xsl:value-of select="count(preceding::w:sectPr[w:cols/@w:num >1])"/></xsl:attribute>
  1168.                     <xsl:attribute name="text:name">sect<xsl:value-of select="count(preceding::w:sectPr[w:cols/@w:num >1])"/></xsl:attribute>
  1169.                     <xsl:apply-templates/>
  1170.                 </xsl:element>
  1171.             </xsl:when>
  1172.             <xsl:otherwise>
  1173.                 <xsl:apply-templates/>
  1174.             </xsl:otherwise>
  1175.         </xsl:choose>
  1176.     </xsl:template>
  1177.     <xsl:template name="paragraph-properties">
  1178.         <xsl:choose>
  1179.             <xsl:when test="descendant::w:ind[@w:left]">
  1180.                 <xsl:attribute name="fo:margin-left"><xsl:value-of select="number(((descendant::w:ind/@w:left)div 1440) *2.54)"/>cm</xsl:attribute>
  1181.             </xsl:when>
  1182.             <xsl:otherwise>
  1183.                 <xsl:attribute name="fo:margin-left">0cm</xsl:attribute>
  1184.             </xsl:otherwise>
  1185.         </xsl:choose>
  1186.         <xsl:choose>
  1187.             <xsl:when test="descendant::w:ind[@w:right]">
  1188.                 <xsl:attribute name="fo:margin-right"><xsl:value-of select="number(((descendant::w:ind/@w:right)div 1440) *2.54)"/>cm</xsl:attribute>
  1189.             </xsl:when>
  1190.             <xsl:otherwise>
  1191.                 <xsl:attribute name="fo:margin-right">0cm</xsl:attribute>
  1192.             </xsl:otherwise>
  1193.         </xsl:choose>
  1194.         <xsl:choose>
  1195.             <xsl:when test="descendant::w:ind[@w:first-line]">
  1196.                 <xsl:attribute name="fo:text-indent"><xsl:value-of select="number(((descendant::w:ind/@w:first-line)div 1440) *2.54)"/>cm</xsl:attribute>
  1197.             </xsl:when>
  1198.             <xsl:otherwise>
  1199.                 <xsl:attribute name="fo:text-indent">0cm</xsl:attribute>
  1200.             </xsl:otherwise>
  1201.         </xsl:choose>
  1202.         <xsl:call-template name="bidi"/>
  1203.         <!-- line spacing-->
  1204.         <xsl:if test="descendant::w:spacing">
  1205.             <xsl:choose>
  1206.                 <xsl:when test="descendant::w:spacing/@w:line-rule='at-least'">
  1207.                     <xsl:attribute name="style:line-height-at-least"><xsl:value-of select="number(((descendant::w:spacing/@w:line) div 1440)*2.54)"/>cm</xsl:attribute>
  1208.                 </xsl:when>
  1209.                 <xsl:when test="descendant::w:spacing/@w:line-rule='auto'">
  1210.                     <xsl:attribute name="fo:line-height"><xsl:value-of select="(number((descendant::w:spacing/@w:line) div 240) * 100)"/>%</xsl:attribute>
  1211.                 </xsl:when>
  1212.                 <xsl:when test="descendant::w:spacing/@w:line-rule='exact'">
  1213.                     <xsl:attribute name="fo:line-height"><xsl:value-of select="number(((descendant::w:spacing/@w:line) div 1440)*2.54)"/>cm</xsl:attribute>
  1214.                 </xsl:when>
  1215.             </xsl:choose>
  1216.             <xsl:if test="descendant::w:spacing/@w:before">
  1217.                 <xsl:attribute name="fo:margin-top"><xsl:value-of select="(number(descendant::w:spacing/@w:before) div 1440 )*2.54"/>cm</xsl:attribute>
  1218.             </xsl:if>
  1219.             <xsl:if test="descendant::w:spacing/@w:after">
  1220.                 <xsl:attribute name="fo:margin-bottom"><xsl:value-of select="(number(descendant::w:spacing/@w:after) div 1440 )*2.54"/>cm</xsl:attribute>
  1221.             </xsl:if>
  1222.         </xsl:if>
  1223.         <xsl:if test="descendant::w:shd">
  1224.             <xsl:variable name="background-color">
  1225.                 <xsl:choose>
  1226.                     <xsl:when test="string-length(descendant::w:shd/@w:fill) = 6">
  1227.                         <xsl:value-of select="concat('#', descendant::w:shd/@w:fill)"/>
  1228.                     </xsl:when>
  1229.                     <xsl:otherwise>#000000</xsl:otherwise>
  1230.                 </xsl:choose>
  1231.             </xsl:variable>
  1232.             <xsl:choose>
  1233.                 <xsl:when test="descendant::w:shd/@w:val = 'solid'">
  1234.                     <xsl:attribute name="fo:background-color"><xsl:value-of select="$background-color"/></xsl:attribute>
  1235.                 </xsl:when>
  1236.                 <!-- patterns are necessary in the future. glu -->
  1237.                 <xsl:otherwise/>
  1238.             </xsl:choose>
  1239.         </xsl:if>
  1240.         <!-- MS Word & Star Writer has different default font size, MS 10pt, Star 12pt. glu -->
  1241.         <xsl:attribute name="style:auto-text-indent">false</xsl:attribute>
  1242.         <xsl:if test="descendant::w:tabs">
  1243.             <xsl:element name="style:tab-stops">
  1244.                 <xsl:for-each select="descendant::w:tabs/w:tab">
  1245.                     <xsl:element name="style:tab-stop">
  1246.                         <xsl:attribute name="style:position"><xsl:value-of select="(number(@w:pos)div 1440)*2.54"/>cm</xsl:attribute>
  1247.                         <xsl:choose>
  1248.                             <xsl:when test="@w:val = 'decimal'">
  1249.                                 <xsl:attribute name="style:type">char</xsl:attribute>
  1250.                                 <xsl:attribute name="style:char"/>
  1251.                             </xsl:when>
  1252.                             <xsl:otherwise>
  1253.                                 <xsl:attribute name="style:type"><xsl:value-of select="@w:val"/></xsl:attribute>
  1254.                             </xsl:otherwise>
  1255.                         </xsl:choose>
  1256.                     </xsl:element>
  1257.                 </xsl:for-each>
  1258.             </xsl:element>
  1259.         </xsl:if>
  1260.     </xsl:template>
  1261.     <xsl:template name="bidi">
  1262.         <!-- bi-directional support-->
  1263.         <xsl:if test="descendant::w:bidi">
  1264.             <xsl:attribute name="style:writing-mode">rl-tb</xsl:attribute>
  1265.             <xsl:attribute name="fo:text-align">end</xsl:attribute>
  1266.         </xsl:if>
  1267.         <xsl:choose>
  1268.             <xsl:when test="descendant::w:jc[@w:val = 'center']">
  1269.                 <xsl:attribute name="fo:text-align">center</xsl:attribute>
  1270.             </xsl:when>
  1271.             <xsl:when test="descendant::w:jc[@w:val = 'left']">
  1272.                 <xsl:choose>
  1273.                     <xsl:when test="descendant::w:bidi">
  1274.                         <xsl:attribute name="fo:text-align">end</xsl:attribute>
  1275.                     </xsl:when>
  1276.                     <xsl:otherwise>
  1277.                         <xsl:attribute name="fo:text-align">start</xsl:attribute>
  1278.                     </xsl:otherwise>
  1279.                 </xsl:choose>
  1280.             </xsl:when>
  1281.             <xsl:when test="descendant::w:jc[@w:val = 'right']">
  1282.                 <xsl:choose>
  1283.                     <xsl:when test="descendant::w:bidi">
  1284.                         <xsl:attribute name="fo:text-align">start</xsl:attribute>
  1285.                     </xsl:when>
  1286.                     <xsl:otherwise>
  1287.                         <xsl:attribute name="fo:text-align">end</xsl:attribute>
  1288.                     </xsl:otherwise>
  1289.                 </xsl:choose>
  1290.             </xsl:when>
  1291.             <xsl:when test="descendant::w:jc[@w:val = 'both']">
  1292.                 <xsl:attribute name="fo:text-align">justify</xsl:attribute>
  1293.                 <xsl:attribute name="style:justify-single-word">false</xsl:attribute>
  1294.             </xsl:when>
  1295.         </xsl:choose>
  1296.     </xsl:template>
  1297.     <xsl:template match="w:pict">
  1298.         <xsl:choose>
  1299.             <xsl:when test="descendant::w:binData">
  1300.                 <!-- Cannot load zipped Wmf file. glu <xsl:if test="not(contains(w:binData/@w:name,'.wmz'))"> -->
  1301.                 <xsl:element name="draw:image">
  1302.                     <xsl:if test="v:shape/@style">
  1303.                         <xsl:if test="contains( v:shape/@style, 'margin-left:')">
  1304.                             <xsl:attribute name="svg:x"><xsl:value-of select="concat( number(substring-before( substring-after( v:shape/@style, 'margin-left:'), 'pt'))*0.0353, 'cm')"/></xsl:attribute>
  1305.                         </xsl:if>
  1306.                         <xsl:if test="contains( v:shape/@style, 'margin-top:')">
  1307.                             <xsl:attribute name="svg:y"><xsl:value-of select="concat( number(substring-before( substring-after( v:shape/@style, 'margin-top:'), 'pt'))*0.0353, 'cm')"/></xsl:attribute>
  1308.                         </xsl:if>
  1309.                         <xsl:attribute name="svg:width"><xsl:value-of select="concat( number(substring-before( substring-after( v:shape/@style, 'width:'), 'pt'))*0.0353, 'cm')"/></xsl:attribute>
  1310.                         <xsl:attribute name="svg:height"><xsl:value-of select="concat( number(substring-before( substring-after( v:shape/@style, 'height:'), 'pt'))*0.0353, 'cm')"/></xsl:attribute>
  1311.                         <xsl:variable name="anchor-type">
  1312.                             <xsl:if test="contains( v:shape/@style, 'mso-position-horizontal-relative')">
  1313.                                 <xsl:value-of select="substring-before( substring-after( v:shape/@style, 'mso-position-horizontal-relative:'), ';')"/>
  1314.                             </xsl:if>
  1315.                         </xsl:variable>
  1316.                         <xsl:choose>
  1317.                             <xsl:when test="$anchor-type = 'margin'">
  1318.                                 <xsl:attribute name="text:anchor-type">frame</xsl:attribute>
  1319.                             </xsl:when>
  1320.                             <xsl:when test="$anchor-type = 'page'">
  1321.                                 <xsl:attribute name="text:anchor-type">page</xsl:attribute>
  1322.                             </xsl:when>
  1323.                             <xsl:when test="$anchor-type = 'char'">
  1324.                                 <xsl:attribute name="text:anchor-type">as-char</xsl:attribute>
  1325.                             </xsl:when>
  1326.                             <xsl:otherwise>
  1327.                                 <xsl:attribute name="text:anchor-type">paragraph</xsl:attribute>
  1328.                             </xsl:otherwise>
  1329.                         </xsl:choose>
  1330.                         <xsl:if test="v:shape/v:imagedata/@o:title">
  1331.                             <xsl:attribute name="draw:name"><xsl:value-of select="v:shape/v:imagedata/@o:title"/></xsl:attribute>
  1332.                         </xsl:if>
  1333.                         <xsl:element name="office:binary-data">
  1334.                             <xsl:value-of select="w:binData"/>
  1335.                         </xsl:element>
  1336.                     </xsl:if>
  1337.                 </xsl:element>
  1338.             </xsl:when>
  1339.             <xsl:otherwise>
  1340.                 <xsl:apply-templates/>
  1341.             </xsl:otherwise>
  1342.         </xsl:choose>
  1343.     </xsl:template>
  1344.     <xsl:template match="w:binData">
  1345.         <xsl:element name="office:binary-data">
  1346.             <xsl:value-of select="."/>
  1347.         </xsl:element>
  1348.     </xsl:template>
  1349.     <xsl:template match="v:group">
  1350.         <xsl:apply-templates/>
  1351.     </xsl:template>
  1352.     <xsl:template match="v:oval">
  1353.         <xsl:element name="draw:ellipse">
  1354.             <xsl:variable name="style" select="@style"/>
  1355.             <xsl:variable name="position" select="substring-after($style,'position:')"/>
  1356.             <xsl:variable name="positionval" select="substring-before($position,';')"/>
  1357.             <xsl:variable name="left" select="substring-after($style,'left:')"/>
  1358.             <xsl:variable name="leftval" select="substring-before($left,';')"/>
  1359.             <xsl:variable name="top" select="substring-after($style,'top:')"/>
  1360.             <xsl:variable name="topval" select="substring-before($top,';')"/>
  1361.             <xsl:variable name="width" select="substring-after($style,'width:')"/>
  1362.             <xsl:variable name="widthval" select="substring-before($width,';')"/>
  1363.             <xsl:variable name="height" select="substring-after($style,'height:')"/>
  1364.             <xsl:variable name="heightval" select="$height"/>
  1365.             <xsl:if test="$positionval = 'absolute'">
  1366.                 <xsl:variable name="parentgroup" select="parent::v:group"/>
  1367.                 <xsl:variable name="origin" select="$parentgroup/@coordorigin"/>
  1368.                 <xsl:variable name="groupleft" select="substring-before($origin,',')"/>
  1369.                 <xsl:variable name="grouptop" select="substring-after($origin,',')"/>
  1370.                 <xsl:variable name="currsect" select="ancestor::wx:sect"/>
  1371.                 <xsl:variable name="currsectPr" select="$currsect/descendant::w:sectPr/w:pgMar"/>
  1372.                 <xsl:variable name="leftmar" select="$currsectPr/@w:left"/>
  1373.                 <xsl:variable name="topmar" select="$currsectPr/@w:top"/>
  1374.                 <xsl:attribute name="text:anchor-type">page</xsl:attribute>
  1375.                 <xsl:attribute name="svg:width"><xsl:value-of select="(number($widthval) div 1440)*2.54"/>cm</xsl:attribute>
  1376.                 <xsl:attribute name="svg:height"><xsl:value-of select="(number($heightval) div 1440)*2.54"/>cm</xsl:attribute>
  1377.                 <xsl:attribute name="svg:x"><xsl:value-of select="(number($topval + $topmar) div 1440)*2.54"/>cm</xsl:attribute>
  1378.                 <xsl:attribute name="svg:y"><xsl:value-of select="(number($leftval + $leftmar) div 1440)*2.54"/>cm</xsl:attribute>
  1379.             </xsl:if>
  1380.         </xsl:element>
  1381.     </xsl:template>
  1382.     <xsl:template match="v:rect">
  1383.         <xsl:element name="draw:rect">
  1384.             <xsl:variable name="style" select="@style"/>
  1385.             <xsl:variable name="position" select="substring-after($style,'position:')"/>
  1386.             <xsl:variable name="positionval" select="substring-before($position,';')"/>
  1387.             <xsl:variable name="left" select="substring-after($style,'left:')"/>
  1388.             <xsl:variable name="leftval" select="substring-before($left,';')"/>
  1389.             <xsl:variable name="top" select="substring-after($style,'top:')"/>
  1390.             <xsl:variable name="topval" select="substring-before($top,';')"/>
  1391.             <xsl:variable name="width" select="substring-after($style,'width:')"/>
  1392.             <xsl:variable name="widthval" select="substring-before($width,';')"/>
  1393.             <xsl:variable name="height" select="substring-after($style,'height:')"/>
  1394.             <xsl:variable name="heightval" select="$height"/>
  1395.             <xsl:if test="$positionval = 'absolute'">
  1396.                 <xsl:variable name="parentgroup" select="parent::v:group"/>
  1397.                 <xsl:variable name="origin" select="$parentgroup/@coordorigin"/>
  1398.                 <xsl:variable name="groupleft" select="substring-before($origin,',')"/>
  1399.                 <xsl:variable name="grouptop" select="substring-after($origin,',')"/>
  1400.                 <xsl:variable name="currsect" select="ancestor::wx:sect"/>
  1401.                 <xsl:variable name="currsectPr" select="$currsect/descendant::w:sectPr/w:pgMar"/>
  1402.                 <xsl:variable name="leftmar" select="$currsectPr/@w:left"/>
  1403.                 <xsl:variable name="topmar" select="$currsectPr/@w:top"/>
  1404.                 <xsl:attribute name="text:anchor-type">page</xsl:attribute>
  1405.                 <xsl:attribute name="svg:width"><xsl:value-of select="(number($widthval) div 1440)*2.54"/>cm</xsl:attribute>
  1406.                 <xsl:attribute name="svg:height"><xsl:value-of select="(number($heightval) div 1440)*2.54"/>cm</xsl:attribute>
  1407.                 <xsl:attribute name="svg:x"><xsl:value-of select="(number($topval + $topmar) div 1440)*2.54"/>cm</xsl:attribute>
  1408.                 <xsl:attribute name="svg:y"><xsl:value-of select="(number($leftval + $leftmar) div 1440)*2.54"/>cm</xsl:attribute>
  1409.             </xsl:if>
  1410.         </xsl:element>
  1411.     </xsl:template>
  1412.     <xsl:template match="w:tbl">
  1413.         <xsl:element name="table:table">
  1414.             <xsl:if test="w:tblPr">
  1415.                 <xsl:attribute name="table:style-name">Table<xsl:value-of select="count(preceding::w:tblPr)"/></xsl:attribute>
  1416.             </xsl:if>
  1417.             <xsl:apply-templates select="./*"/>
  1418.         </xsl:element>
  1419.     </xsl:template>
  1420.     <xsl:template match="w:tblPr">
  1421.         <!-- commented tempararily by glu -->
  1422.         <!-- <xsl:attribute name="table:style-name">Table<xsl:value-of select="count(preceding::w:tblPr)"/></xsl:attribute> -->
  1423.     </xsl:template>
  1424.     <xsl:template match="w:tblGrid">
  1425.         <xsl:apply-templates/>
  1426.     </xsl:template>
  1427.     <xsl:template match="w:gridCol">
  1428.         <xsl:element name="table:table-column">
  1429.             <xsl:attribute name="table:style-name">TColumn<xsl:value-of select="count(preceding::w:gridCol)"/></xsl:attribute>
  1430.         </xsl:element>
  1431.     </xsl:template>
  1432.     <xsl:template match="w:tr">
  1433.         <xsl:element name="table:table-row">
  1434.             <xsl:apply-templates/>
  1435.         </xsl:element>
  1436.     </xsl:template>
  1437.     <xsl:template match="w:tc">
  1438.         <xsl:element name="table:table-cell">
  1439.             <xsl:attribute name="table:style-name">TCell<xsl:value-of select="count(preceding::w:tcPr)"/></xsl:attribute>
  1440.             <xsl:if test="w:tcPr/w:gridSpan">
  1441.                 <xsl:attribute name="table:number-columns-spanned"><xsl:value-of select="w:tcPr/w:gridSpan/@w:val"/></xsl:attribute>
  1442.             </xsl:if>
  1443.             <xsl:apply-templates/>
  1444.         </xsl:element>
  1445.     </xsl:template>
  1446.     <xsl:template match="w:tcBorders">
  1447.         <xsl:apply-templates/>
  1448.     </xsl:template>
  1449.     <xsl:template match="w:top">
  1450.         <xsl:choose>
  1451.             <xsl:when test="@w:val='nil' ">
  1452.                 <xsl:attribute name="fo:border-top">none</xsl:attribute>
  1453.             </xsl:when>
  1454.             <xsl:when test="@wx:bdrwidth and @w:color">
  1455.                 <xsl:attribute name="fo:border-top"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/><xsl:text>cm </xsl:text><xsl:choose><xsl:when test="@w:color ='auto'"><xsl:text>solid #000000</xsl:text></xsl:when><xsl:otherwise><xsl:text>solid #</xsl:text><xsl:value-of select="@w:color"/></xsl:otherwise></xsl:choose></xsl:attribute>
  1456.             </xsl:when>
  1457.             <xsl:when test="@wx:bdrwidth">
  1458.                 <xsl:attribute name="fo:border-top"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/>cm</xsl:attribute>
  1459.             </xsl:when>
  1460.         </xsl:choose>
  1461.     </xsl:template>
  1462.     <xsl:template match="w:bottom">
  1463.         <xsl:choose>
  1464.             <xsl:when test="@w:val='nil' ">
  1465.                 <xsl:attribute name="fo:border-bottom">none</xsl:attribute>
  1466.             </xsl:when>
  1467.             <xsl:when test="@wx:bdrwidth and @w:color">
  1468.                 <xsl:attribute name="fo:border-bottom"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/><xsl:text>cm </xsl:text><xsl:choose><xsl:when test="@w:color ='auto'"><xsl:text>solid #000000</xsl:text></xsl:when><xsl:otherwise><xsl:text>solid #</xsl:text><xsl:value-of select="@w:color"/></xsl:otherwise></xsl:choose></xsl:attribute>
  1469.             </xsl:when>
  1470.             <xsl:when test="@wx:bdrwidth">
  1471.                 <xsl:attribute name="fo:border-bottom"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/>cm</xsl:attribute>
  1472.             </xsl:when>
  1473.         </xsl:choose>
  1474.     </xsl:template>
  1475.     <xsl:template match="w:left">
  1476.         <xsl:choose>
  1477.             <xsl:when test="@w:val='nil' ">
  1478.                 <xsl:attribute name="fo:border-left">none</xsl:attribute>
  1479.             </xsl:when>
  1480.             <xsl:when test="@wx:bdrwidth and @w:color">
  1481.                 <xsl:attribute name="fo:border-left"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/><xsl:text>cm </xsl:text><xsl:choose><xsl:when test="@w:color ='auto'"><xsl:text>solid #000000</xsl:text></xsl:when><xsl:otherwise><xsl:text>solid #</xsl:text><xsl:value-of select="@w:color"/></xsl:otherwise></xsl:choose></xsl:attribute>
  1482.             </xsl:when>
  1483.             <xsl:when test="@wx:bdrwidth">
  1484.                 <xsl:attribute name="fo:border-left"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/>cm</xsl:attribute>
  1485.             </xsl:when>
  1486.         </xsl:choose>
  1487.     </xsl:template>
  1488.     <xsl:template match="w:right">
  1489.         <xsl:choose>
  1490.             <xsl:when test="@w:val='nil' ">
  1491.                 <xsl:attribute name="fo:border-right">none</xsl:attribute>
  1492.             </xsl:when>
  1493.             <xsl:when test="@wx:bdrwidth and @w:color">
  1494.                 <xsl:attribute name="fo:border-right"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/><xsl:text>cm </xsl:text><xsl:choose><xsl:when test="@w:color ='auto'"><xsl:text>solid #000000</xsl:text></xsl:when><xsl:otherwise><xsl:text>solid #</xsl:text><xsl:value-of select="@w:color"/></xsl:otherwise></xsl:choose></xsl:attribute>
  1495.             </xsl:when>
  1496.             <xsl:when test="@wx:bdrwidth">
  1497.                 <xsl:attribute name="fo:border-right"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/>cm</xsl:attribute>
  1498.             </xsl:when>
  1499.         </xsl:choose>
  1500.     </xsl:template>
  1501.     <xsl:template match="w:tblBorders">
  1502.         <xsl:apply-templates/>
  1503.     </xsl:template>
  1504.     <xsl:template match="w:tcBorders">
  1505.         <xsl:apply-templates/>
  1506.     </xsl:template>
  1507.     <xsl:template match="w:tblInd">
  1508.         <!-- commented tempararily by glu -->
  1509.         <!-- <xsl:attribute name="fo:margin-left"><xsl:value-of select="(number(@w:w) div 1440)*2.54"/>cm</xsl:attribute> -->
  1510.     </xsl:template>
  1511.     <xsl:template match="w:tcPr"/>
  1512.     <xsl:template name="genlist">
  1513.         <xsl:variable name="currlistid" select="w:pPr/w:listPr/w:ilfo/@w:val"/>
  1514.         <xsl:variable name="currlistlvl" select="w:pPr/w:listPr/w:ilvl/@w:val"/>
  1515.         <xsl:variable name="firstoccur" select="/descendant::w:pPr[w:listPr/w:ilfo/@w:val = $currlistid][1]"/>
  1516.         <xsl:element name="text:ordered-list">
  1517.             <xsl:attribute name="text:style-name">List<xsl:value-of select="count($firstoccur/preceding::w:listPr)"/></xsl:attribute>
  1518.             <xsl:choose>
  1519.                 <xsl:when test="preceding::w:pPr/w:listPr/w:ilfo/@w:val = w:pPr/w:listPr/w:ilfo/@w:val">
  1520.                     <xsl:attribute name="text:continue-numbering">true</xsl:attribute>
  1521.                     <xsl:element name="text:list-item">
  1522.                         <xsl:call-template name="levels">
  1523.                             <xsl:with-param name="level" select="$currlistlvl"/>
  1524.                         </xsl:call-template>
  1525.                     </xsl:element>
  1526.                 </xsl:when>
  1527.                 <xsl:otherwise>
  1528.                     <xsl:element name="text:list-item">
  1529.                         <xsl:call-template name="levels">
  1530.                             <xsl:with-param name="level" select="$currlistlvl"/>
  1531.                         </xsl:call-template>
  1532.                     </xsl:element>
  1533.                 </xsl:otherwise>
  1534.             </xsl:choose>
  1535.         </xsl:element>
  1536.     </xsl:template>
  1537.     <xsl:template name="levels">
  1538.         <xsl:param name="level"/>
  1539.         <xsl:choose>
  1540.             <xsl:when test="$level = '0'">
  1541.                 <xsl:call-template name="commonParagraph"/>
  1542.             </xsl:when>
  1543.             <xsl:otherwise>
  1544.                 <xsl:element name="text:ordered-list">
  1545.                     <xsl:element name="text:list-item">
  1546.                         <xsl:call-template name="levels">
  1547.                             <xsl:with-param name="level" select="$level -1"/>
  1548.                         </xsl:call-template>
  1549.                     </xsl:element>
  1550.                 </xsl:element>
  1551.             </xsl:otherwise>
  1552.         </xsl:choose>
  1553.     </xsl:template>
  1554.     <xsl:template match="w:instrText"/>
  1555.     <xsl:template match="w:fldChar"/>
  1556. </xsl:stylesheet>
  1557.