home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 100 / CD-ROM 100.iso / aplic / oo1_1 / f_0386 / MsWordXMLImport.xsl
Encoding:
Extensible Markup Language  |  2003-06-04  |  81.6 KB  |  1,980 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- #  The Contents of this file are made available subject to the terms of
  3.  #  either of the following licenses
  4.  #
  5.  #         - GNU Lesser General Public License Version 2.1
  6.  #         - Sun Industry Standards Source License Version 1.1
  7.  #
  8.  #  Sun Microsystems Inc., October, 2000
  9.  #
  10.  #  GNU Lesser General Public License Version 2.1
  11.  #  =============================================
  12.  #  Copyright 2000 by Sun Microsystems, Inc.
  13.  #  901 San Antonio Road, Palo Alto, CA 94303, USA
  14.  #
  15.  #  This library is free software; you can redistribute it and/or
  16.  #  modify it under the terms of the GNU Lesser General Public
  17.  #  License version 2.1, as published by the Free Software Foundation.
  18.  #
  19.  #  This library is distributed in the hope that it will be useful,
  20.  #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  22.  #  Lesser General Public License for more details.
  23.  #
  24.  #  You should have received a copy of the GNU Lesser General Public
  25.  #  License along with this library; if not, write to the Free Software
  26.  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27.  #  MA  02111-1307  USA
  28.  #
  29.  #
  30.  #  Sun Industry Standards Source License Version 1.1
  31.  #  =================================================
  32.  #  The contents of this file are subject to the Sun Industry Standards
  33.  #  Source License Version 1.1 (the "License"); You may not use this file
  34.  #  except in compliance with the License. You may obtain a copy of the
  35.  #  License at http://www.openoffice.org/license.html.
  36.  #
  37.  #  Software provided under this License is provided on an "AS IS" basis,
  38.  #  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  39.  #  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  40.  #  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  41.  #  See the License for the specific provisions governing your rights and
  42.  #  obligations concerning the Software.
  43.  #
  44.  #  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  45.  #
  46.  #  Copyright: 2000 by Sun Microsystems, Inc.
  47.  #
  48.  #  All Rights Reserved.
  49.  #
  50.  #  Contributor(s): _______________________________________
  51.  #
  52.  #-->
  53. <xsl:stylesheet version="1.0" 
  54. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  55. xmlns:fo="http://www.w3.org/1999/XSL/Format" 
  56. xmlns:w="http://schemas.microsoft.com/office/word/2003/2/wordml" 
  57. xmlns:wx="http://schemas.microsoft.com/office/word/2003/2/auxHint" 
  58. xmlns:v="urn:schemas-microsoft-com:vml" 
  59. xmlns:w10="urn:schemas-microsoft-com:office:word" 
  60. xmlns:SL="http://schemas.microsoft.com/schemaLibrary/2003/2/core" 
  61. xmlns:aml="http://schemas.microsoft.com/aml/2001/core" 
  62. xmlns:o="urn:schemas-microsoft-com:office:office" 
  63. xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
  64. xmlns:office="http://openoffice.org/2000/office"
  65. xmlns:table="http://openoffice.org/2000/table" 
  66. xmlns:style="http://openoffice.org/2000/style" 
  67. xmlns:text="http://openoffice.org/2000/text" 
  68. xmlns:draw="http://openoffice.org/2000/drawing" 
  69. xmlns:xlink="http://www.w3.org/1999/xlink" 
  70. xmlns:number="http://openoffice.org/2000/datastyle" 
  71. xmlns:svg="http://www.w3.org/2000/svg" 
  72. xmlns:chart="http://openoffice.org/2000/chart" 
  73. xmlns:dr3d="http://openoffice.org/2000/dr3d" 
  74. xmlns:math="http://www.w3.org/1998/Math/MathML" 
  75. xmlns:form="http://openoffice.org/2000/form" 
  76. xmlns:script="http://openoffice.org/2000/script" 
  77. office:class="text" 
  78. office:version="1.0"
  79. >
  80. <xsl:output  method="xml" indent="no" omit-xml-declaration="no" encoding="UTF-8" version="1.0"/>
  81. <!--<xsl:include href="mstables.xsl"/>
  82. <xsl:include href="mslists.xsl"/>
  83. <xsl:include href="styles.xsl"/>
  84. <xsl:include href="graphics.xsl"/>
  85. <xsl:include href="fields.xsl"/>-->
  86.    
  87. <xsl:template match="w:wordDocument">
  88.     
  89.         <office:document 
  90.                         xmlns:office="http://openoffice.org/2000/office" 
  91.                         xmlns:style="http://openoffice.org/2000/style" 
  92.                         xmlns:text="http://openoffice.org/2000/text"
  93.                         xmlns:table="http://openoffice.org/2000/table" 
  94.                         xmlns:draw="http://openoffice.org/2000/drawing" 
  95.                         xmlns:fo="http://www.w3.org/1999/XSL/Format" 
  96.                         xmlns:xlink="http://www.w3.org/1999/xlink" 
  97.                         xmlns:number="http://openoffice.org/2000/datastyle" 
  98.                         xmlns:svg="http://www.w3.org/2000/svg" 
  99.                         xmlns:chart="http://openoffice.org/2000/chart" 
  100.                         xmlns:dr3d="http://openoffice.org/2000/dr3d" 
  101.                         xmlns:math="http://www.w3.org/1998/Math/MathML" 
  102.                         xmlns:form="http://openoffice.org/2000/form" 
  103.                         xmlns:script="http://openoffice.org/2000/script" 
  104.                         office:class="text" office:version="1.0">
  105.             
  106.         <xsl:apply-templates/>
  107.     </office:document>
  108. </xsl:template>
  109.  
  110. <xsl:template match="w:body">
  111.     <xsl:element name="office:body">
  112.         <xsl:apply-templates/>
  113.     </xsl:element>
  114. </xsl:template>
  115.  
  116. <xsl:template match="o:DocumentProperties">
  117. </xsl:template>
  118.  
  119. <xsl:template match="w:p[child::w:pPr/w:listPr]">
  120.         <xsl:call-template name="genlist"/>
  121. </xsl:template>
  122.  
  123.  
  124.  
  125. <xsl:template match="w:hlink">
  126.     <xsl:element name="text:a">
  127.         <xsl:attribute name="xlink:type">simple</xsl:attribute>
  128.         <xsl:attribute name="xlink:href"><xsl:value-of select="@w:dest"/></xsl:attribute>
  129.         <xsl:value-of select="descendant::w:t"/>
  130.     </xsl:element>
  131. </xsl:template>
  132.  
  133.  
  134. <xsl:template match="w:p">
  135.     <xsl:choose>
  136.         <!-- because word treats page breaks as separate tags, we must split some paragraphs up so that we can 
  137.             give the sub para a fo:break-before ="page" attribute
  138.         -->
  139.         <xsl:when test="child::w:r[child::w:br/@w:type='page']  "> 
  140.                <xsl:call-template name="processPageBreaks"/>
  141.         </xsl:when>
  142.         <xsl:otherwise>
  143.             <xsl:call-template name="commonPara"/>
  144.         </xsl:otherwise>
  145.     </xsl:choose>
  146.     <!--<xsl:apply-templates/>-->
  147. </xsl:template>
  148.  
  149. <xsl:template name="processPageBreaks">
  150.        <xsl:variable name="pageBreak" select="child::w:r[child::w:br/@w:type='page']"/>
  151.        <xsl:call-template name="createSubPara">
  152.            <xsl:with-param name="list"  select="$pageBreak[1]/preceding-sibling::w:r"/>
  153.            <xsl:with-param name="pageBreak"/>
  154.            <xsl:with-param name="needsPageBreak" >false</xsl:with-param>
  155.        </xsl:call-template>
  156.        <xsl:for-each select="$pageBreak">
  157.                <xsl:call-template name="createSubPara">
  158.                <xsl:with-param name="list" select="./following-sibling::w:r[preceding::w:r/child::w:br = '.']"/>
  159.                <xsl:with-param name="pageBreak" select="."/>
  160.                <xsl:with-param name="needsPageBreak">true</xsl:with-param>
  161.            </xsl:call-template>
  162.           </xsl:for-each>
  163. </xsl:template>
  164.  
  165.  
  166. <xsl:template name="createSubPara">
  167.     <xsl:param name="list"/>
  168.     <xsl:param name="pageBreak"/>
  169.     <xsl:param name="needsPageBreak"/>
  170.     <xsl:if test="(count($list) > 0) or ($needsPageBreak ='true') ">
  171.     <xsl:element name="text:p">
  172.         <xsl:choose>
  173.             <xsl:when test="$needsPageBreak = 'true'" >        
  174.                 <xsl:choose>
  175.                     <xsl:when test="ancestor::w:p/w:pPr">
  176.                             <xsl:attribute name="text:style-name">P<xsl:value-of select="count(ancestor::w:p/w:pPr/preceding::w:pPr)"/></xsl:attribute>
  177.                     </xsl:when>
  178.                     <xsl:otherwise>
  179.                             <xsl:attribute name="text:style-name">PageBreak</xsl:attribute>
  180.                     </xsl:otherwise>
  181.                 </xsl:choose>
  182.             </xsl:when>    
  183.             <xsl:otherwise>
  184.                 <xsl:attribute name="text:style-name">Normal</xsl:attribute>
  185.             </xsl:otherwise>
  186.         </xsl:choose>
  187.             
  188.         <xsl:if test="$pageBreak">
  189.             <xsl:apply-templates select="$pageBreak"/>
  190.         </xsl:if>
  191.         <xsl:apply-templates select="$list"/>
  192.     </xsl:element>
  193.     </xsl:if>
  194. </xsl:template>
  195.  
  196.  
  197. <xsl:template name="commonPara">
  198. <!-- Heading or normal para-->
  199.     <xsl:choose>
  200.         <xsl:when test="(child::w:pPr/w:pStyle/@w:val='Heading1') or (child::w:pPr/w:pStyle/@w:val='Heading2') or 
  201.                         (child::w:pPr/w:pStyle/@w:val='Heading3') or  (child::w:pPr/w:pStyle/@w:val='Heading4') or 
  202.                         (child::w:pPr/w:pStyle/@w:val='Heading5') or  (child::w:pPr/w:pStyle/@w:val='Heading6') or  
  203.                         (child::w:pPr/w:pStyle/@w:val='Heading7') or  (child::w:pPr/w:pStyle/@w:val='Heading8') or  
  204.                         (child::w:pPr/w:pStyle/@w:val='Heading9')">
  205.             <xsl:variable  name="styleid" select="child::w:pPr/w:pStyle/@w:val"/>
  206.             <xsl:element name="text:h">
  207.                 <xsl:variable name="outlinelevel" select="number(/descendant::w:style[@w:styleId = $styleid]/w:pPr/w:outlineLvl/@w:val)+1"/>
  208.                 <xsl:if test="$outlinelevel">
  209.                     <xsl:attribute name="text:level"><xsl:value-of select="$outlinelevel"/></xsl:attribute>
  210.                 </xsl:if>
  211.                   <xsl:call-template name="commonParaAttribs"/>
  212.                   
  213.             </xsl:element>
  214.         </xsl:when>
  215.         <xsl:otherwise>
  216.             <xsl:element name="text:p">
  217.                   <xsl:call-template name="commonParaAttribs"/>
  218.             </xsl:element>
  219.         </xsl:otherwise>
  220.     </xsl:choose>
  221. </xsl:template>
  222.  
  223. <xsl:template name="commonParaAttribs">
  224. <!-- Common  paragraph attributes-->
  225.         <xsl:choose>
  226.             <xsl:when test="child::w:pPr">
  227.                 <!--<xsl:choose>
  228.                     <xsl:when test="child::w:pPr/w:pStyle">
  229.                         <xsl:attribute name="text:style-name"><xsl:value-of select="child::w:pPr/w:pStyle/@w:val"/></xsl:attribute>
  230.                     </xsl:when>
  231.                     <xsl:otherwise>
  232.                         <xsl:attribute name="text:style-name">P<xsl:value-of select="count(preceding::w:pPr)"/></xsl:attribute>
  233.                     </xsl:otherwise>
  234.                 </xsl:choose>-->
  235.                 <xsl:attribute name="text:style-name">P<xsl:value-of select="count(preceding::w:pPr)"/></xsl:attribute>
  236.             </xsl:when>
  237.             <xsl:when test="not(child::w:pPr) and (descendant::w:br[@w:type = 'column'] or ancestor::wx:sect/descendant::w:sectPr[w:cols/@w:num > 1])">
  238.                 <xsl:attribute name="text:style-name">ColumnBreakPara</xsl:attribute>
  239.             </xsl:when>
  240.             <xsl:otherwise>
  241.                 <xsl:attribute name="text:style-name">Normal</xsl:attribute>
  242.             </xsl:otherwise>
  243.         </xsl:choose>
  244.         <xsl:apply-templates select="child::*"/>    
  245. </xsl:template>
  246.  
  247.  
  248. <xsl:template match="w:pPr">
  249. </xsl:template>
  250.  
  251. <xsl:template match="w:rPr">
  252. </xsl:template>
  253.  
  254. <xsl:template match="wx:sect">
  255.         <xsl:apply-templates/>
  256. </xsl:template>
  257.  
  258. <xsl:template match="wx:sub-section">
  259.         <xsl:apply-templates/>
  260. </xsl:template>
  261.  
  262.  
  263. <xsl:template match="w:t">
  264.     <xsl:choose>
  265.         <xsl:when test="string(.) = ' ' "><xsl:element name="text:s"/></xsl:when>
  266.         <xsl:when test="contains(.,'  ')">
  267.             <xsl:call-template name="replace-spaces" >
  268.                 <xsl:with-param name="curr-string" select="."/>
  269.             </xsl:call-template>
  270.         </xsl:when>
  271.         <xsl:otherwise>
  272.             <xsl:apply-templates/>
  273.         </xsl:otherwise>
  274.     </xsl:choose>
  275. </xsl:template>
  276.  
  277.  
  278. <xsl:template name="replace-spaces">
  279.     <xsl:param name="curr-string"/>
  280.     <xsl:if test="contains($curr-string,'  ')">
  281.         <xsl:value-of select="substring-before($curr-string,' ')"/>
  282.         <xsl:element name="text:s">
  283.             <xsl:attribute name="text:c">2</xsl:attribute>
  284.         </xsl:element>
  285.         <xsl:variable name="next-string" select="substring-after($curr-string,'  ')"/>
  286.         <xsl:choose>
  287.             <xsl:when test="contains($next-string, '  ')">
  288.                 <xsl:call-template name="replace-spaces" >
  289.                     <xsl:with-param name="curr-string" select="$next-string"/>
  290.                 </xsl:call-template>
  291.             </xsl:when>
  292.             <xsl:otherwise>
  293.                 <xsl:value-of select="$next-string"/>
  294.             </xsl:otherwise>
  295.         </xsl:choose>
  296.     </xsl:if>
  297. </xsl:template>
  298.  
  299.  
  300. <xsl:template match="w:tab">
  301.     <xsl:element name="text:tab-stop"/>
  302. </xsl:template>
  303.  
  304. <xsl:template match="w:hdr">
  305.     <!-- empty template to ignore inline processing of header
  306.         These are handled as part of the master style in styles.xsl
  307.     -->
  308. </xsl:template>
  309.  
  310. <xsl:template match="w:ftr">
  311.     <!-- empty template to ignore inline processing of header
  312.         These are handled as part of the master style in styles.xsl
  313.     -->
  314. </xsl:template>
  315.  
  316. <xsl:template match="w:docPr"></xsl:template>
  317.  
  318.  
  319. <xsl:template match="w:r">
  320.     <xsl:variable name="body" select="ancestor::w:body"/>
  321.     <xsl:if test="child::w:br[@w:type='text-wrapping'] or child::w:br[not(@w:type)]">
  322.         <xsl:element name="text:line-break"></xsl:element>
  323.     </xsl:if>
  324.     <xsl:choose>
  325.         <!--<xsl:when test="child::w:br[@w:type='text-wrapping'] and not(child::w:t)">
  326.             <xsl:element name="text:p"> 
  327.             </xsl:element>
  328.         </xsl:when>-->
  329.         <xsl:when test="child::w:rPr/w:vanish">
  330.             <xsl:element name="text:hidden-text">
  331.                 <xsl:attribute name="text:is-hidden">false</xsl:attribute>
  332.                 <xsl:attribute name="text:condition">hide==1</xsl:attribute>
  333.                 <xsl:attribute name="text:string-value"><xsl:value-of select="."/></xsl:attribute>
  334.                 <xsl:apply-templates/>
  335.             </xsl:element>        
  336.         </xsl:when>
  337.         <xsl:when test="(preceding-sibling::w:r) or (child::w:rPr)">
  338.                 <xsl:element name="text:span">
  339.                     <!--<xsl:if test="child::w:rPr">
  340.                             <xsl:attribute name="text:style-name">T<xsl:value-of select="count(preceding::w:rPr)"/></xsl:attribute>
  341.                     </xsl:if>        -->
  342.                     <xsl:choose>
  343.                         <xsl:when test="child::w:rPr/w:rStyle">
  344.                                 <xsl:attribute name="text:style-name"><xsl:value-of select="child::w:rPr/w:rStyle/@w:val"/></xsl:attribute>
  345.                         </xsl:when>
  346.                         <xsl:when test="child::w:rPr">
  347.                                 <xsl:attribute name="text:style-name">T<xsl:value-of select="count(preceding::w:rPr)"/></xsl:attribute>
  348.                         </xsl:when>
  349.                         <!--<xsl:when test="child::w:br/@w:type='page'">
  350.                                 <xsl:attribute name="text:style-name">PageBreak</xsl:attribute>
  351.                         </xsl:when>-->
  352.                     </xsl:choose>
  353.                     <!--<xsl:if test="not(child::w:rPr) and ((count($body/preceding::w:rPr) - count($body/descendant::w:rPr))> 0)">
  354.                             <xsl:attribute name="text:style-name">T<xsl:value-of select="count(preceding::w:rPr)"/></xsl:attribute>
  355.                     </xsl:if>-->
  356.                     <!--<xsl:apply-templates select="w:t"/>-->
  357.                     <xsl:apply-templates/>
  358.                 </xsl:element>
  359.         </xsl:when>
  360.         <xsl:otherwise>
  361.             <xsl:apply-templates/>
  362.         </xsl:otherwise>
  363.     </xsl:choose>
  364. </xsl:template>
  365.  
  366.  
  367. <xsl:template match="wx:sect">
  368.         <xsl:apply-templates/>
  369. </xsl:template>
  370.  
  371.  
  372.  
  373. <!-- Paragraph properties-->
  374.  
  375. <!--<xsl:template match="w:rPr[ancestor::w:body]">
  376.         <xsl:attribute name="text:style-name">T<xsl:value-of select="count(preceding::w:rPr)+count(preceding::w:pPr)+1"/></xsl:attribute>
  377.         <xsl:apply-templates select="descendant::*"/>
  378. </xsl:template>
  379.  
  380. <xsl:template match="w:pPr[ancestor::w:body]">
  381.         <xsl:attribute name="text:style-name">T<xsl:value-of select="count(preceding::w:rPr)+count(preceding::w:pPr)+1"/></xsl:attribute>
  382.         <xsl:apply-templates select="w:rPr"/>
  383. </xsl:template>-->
  384.  
  385. <xsl:template match="wx:font[ancestor::w:fonts]">
  386.     <xsl:if test="not(ancestor::w:p)">
  387.         <xsl:attribute name="style:font-name"><xsl:value-of select="@wx:val"/></xsl:attribute>    
  388.     <xsl:apply-templates/>
  389.     </xsl:if>
  390. </xsl:template>
  391.  
  392.  
  393. <xsl:template match="w:pStyle">
  394.     <xsl:if test="not(ancestor-or-self::w:styles)">
  395.         <xsl:choose>
  396.             <xsl:when test="not(@w:val = '')">
  397.                 <xsl:attribute name="text:style-name"><xsl:value-of select="@w:val"/></xsl:attribute>
  398.             </xsl:when>
  399.             <xsl:otherwise>
  400.                 <xsl:attribute name="text:style-name">Normal</xsl:attribute>
  401.             </xsl:otherwise>
  402.         </xsl:choose>
  403.         
  404.         <xsl:apply-templates/>
  405.     </xsl:if>
  406. </xsl:template>
  407.  
  408. <xsl:template match="w:sz">
  409.         <xsl:attribute name="fo:font-size"><xsl:value-of select="number(@w:val) div 2 "/>pt</xsl:attribute>
  410.     <xsl:apply-templates/>
  411. </xsl:template>
  412.  
  413. <xsl:template match="w:i">
  414.     <xsl:attribute name="fo:font-style">italic</xsl:attribute>
  415.       <xsl:apply-templates/>
  416.  
  417. </xsl:template>
  418.  
  419. <xsl:template match="w:b">
  420.         <xsl:attribute name="fo:font-weight">bold</xsl:attribute>
  421.         <xsl:apply-templates/>
  422. </xsl:template>
  423.  
  424. <xsl:template match="w:u">
  425.     <xsl:attribute name="style:text-underline"><xsl:value-of select="@w:val"/></xsl:attribute>
  426.     <xsl:if test="@w:color">
  427.         <xsl:attribute name="style:text-underline-color">#<xsl:value-of select="@w:color"/></xsl:attribute>
  428.     </xsl:if>
  429.     <xsl:apply-templates/>
  430. </xsl:template>
  431.  
  432. <xsl:template match="w:vertAlign">
  433.     <xsl:attribute name="style:text-position">
  434.         <xsl:choose>
  435.             <xsl:when test="@w:val = 'superscript'">super 58%</xsl:when>
  436.             <xsl:when test="@w:val = 'subscript'">sub 58%</xsl:when>
  437.         </xsl:choose>
  438.     </xsl:attribute>
  439.     <xsl:apply-templates/>
  440. </xsl:template>
  441.  
  442. <xsl:template match="w:shadow">
  443.     <xsl:attribute name="style:text-shadow">1pt 1pt</xsl:attribute>
  444.     <xsl:attribute name="fo:text-shadow">1pt 1pt</xsl:attribute> 
  445.     <xsl:apply-templates/>
  446. </xsl:template>
  447.  
  448.  
  449. <xsl:template match="w:strike">
  450.     <xsl:attribute name="style:text-crossing-out">single-line</xsl:attribute>
  451.     <xsl:apply-templates/>
  452. </xsl:template>
  453.  
  454. <xsl:template match="w:dstrike">
  455.     <xsl:attribute name="style:text-crossing-out">double-line</xsl:attribute>
  456.     <xsl:apply-templates/>
  457. </xsl:template>
  458.  
  459. <xsl:template match="w:color">
  460.     <xsl:attribute name="fo:color">#<xsl:value-of select="@w:val"/></xsl:attribute>
  461.     <xsl:apply-templates/>
  462. </xsl:template>
  463.  
  464. <xsl:template match="w:smallCaps">
  465.     <xsl:attribute name="fo:font-variant">small-caps</xsl:attribute>
  466.     <xsl:apply-templates/>
  467. </xsl:template>
  468.  
  469. <xsl:template match="w:caps">
  470.     <xsl:attribute name="fo:text-transform">uppercase</xsl:attribute>
  471.     <xsl:apply-templates/>
  472. </xsl:template>
  473.  
  474. <xsl:template match="w:imprint">
  475.     <xsl:attribute name="style:font-relief">engraved</xsl:attribute>
  476.     <xsl:apply-templates/>
  477. </xsl:template>
  478.  
  479. <xsl:template match="w:emboss">
  480.     <xsl:attribute name="style:font-relief">embossed</xsl:attribute>
  481.     <xsl:apply-templates/>
  482. </xsl:template>
  483.  
  484. <xsl:template match="w:outline">
  485.     <xsl:attribute name="style:text-outline">true</xsl:attribute>
  486.     <xsl:apply-templates/>
  487. </xsl:template>
  488.  
  489.  
  490. <xsl:template match="w:listPr/wx:font">
  491. </xsl:template>
  492.  
  493. <xsl:template match="wx:font">
  494.         <xsl:attribute name="style:font-name"><xsl:value-of select="@wx:val"/></xsl:attribute>    
  495.          <xsl:apply-templates/>
  496. </xsl:template>
  497.  
  498.  
  499. <!-- <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Normal">
  500.             <style:properties style:text-underline="single" style:text-underline-color="font-color"/>
  501.         </style:style>
  502.         <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Normal">
  503.             <style:properties fo:font-weight="bold"/>
  504.         </style:style>
  505.         <style:style style:name="P3" style:family="paragraph" style:parent-style-name="Normal">
  506.             <style:properties fo:font-style="italic"/>
  507.         </style:style>
  508.         <style:style style:name="P4" style:family="paragraph" style:parent-style-name="Normal">
  509.             <style:properties style:text-crossing-out="single-line"/> <w:strike/> <w:strike>
  510.         </style:style>
  511.         <style:style style:name="P5" style:family="paragraph" style:parent-style-name="Normal">
  512.             <style:properties style:text-position="super 58%"/>     <w:vertAlign w:val="superscript"/>
  513.         </style:style>
  514.         <style:style style:name="P6" style:family="paragraph" style:parent-style-name="Normal">
  515.             <style:properties style:text-position="sub 58%"/>         <w:vertAlign w:val="subscript"/>
  516.         </style:style>
  517.         <style:style style:name="P7" style:family="paragraph" style:parent-style-name="Normal">
  518.             <style:properties fo:text-shadow="1pt 1pt"/> <w:shadow>
  519.         </style:style>
  520.         <style:style style:name="P8" style:family="paragraph" style:parent-style-name="Normal">
  521.             <style:properties style:text-outline="true"/>
  522.         </style:style>
  523.         <style:style style:name="P9" style:family="paragraph" style:parent-style-name="Normal">
  524.             <style:properties fo:font-style="italic" fo:font-weight="bold"/>
  525.         </style:style>
  526.         <style:style style:name="P10" style:family="paragraph" style:parent-style-name="Normal">
  527.             <style:properties style:text-underline="double" style:text-underline-color="font-color"/>
  528.         </style:style>
  529. -->
  530.  
  531. <!-- <style:style style:name="Heading 2" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text body" style:class="text">
  532.             <style:properties fo:font-size="14pt" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="14pt" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="14pt" style:font-style-complex="italic" style:font-weight-complex="bold"  style:font-name-complex="Tahoma1"/>
  533.         </style:style>
  534.  
  535.  
  536.         
  537.         <w:style w:type="paragraph" w:default="on" w:styleId="Normal">
  538.             <w:name w:val="Normal"/>
  539.             <w:rsid w:val="CA2749"/>
  540.             <w:rPr>
  541.                 <wx:font wx:val="Times New Roman"/>
  542.                 <w:sz w:val="24"/>
  543.                 <w:sz-cs w:val="24"/>
  544.                 <w:lang w:val="EN-US" w:fareast="EN-US" w:bidi="AR-SA"/>
  545.             </w:rPr>
  546.         </w:style>
  547.  
  548.         
  549.         -->
  550.  
  551. <xsl:template match="w:fonts">
  552.     <xsl:element name="office:font-decls">
  553.           <style:font-decl style:name="Arial" fo:font-family="Arial" style:font-family-generic="roman" style:font-pitch="variable"/>
  554.           <style:font-decl style:name="Times New Roman" fo:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/>
  555.         <!-- <style:font-decl style:name="Microsoft Sans Serif" fo:font-family="'Microsoft Sans Serif'" style:font-family-generic="swiss" style:font-pitch="variable"/>-->
  556.          <style:font-decl style:name="Symbol" fo:font-family="Symbol" style:font-family-generic="roman" style:font-pitch="variable" style:font-charset="x-symbol"/>
  557.          <xsl:if test="not(/w:wordDocument/w:fonts/w:font[@w:name='StarSymbol'])">
  558.              <style:font-decl style:name="StarSymbol" fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
  559.          </xsl:if>
  560.               <style:font-decl style:name="Courier New" fo:font-family="'Courier New'" style:font-family-generic="modern" style:font-pitch="fixed"/>
  561.         <xsl:apply-templates/>
  562.     </xsl:element>
  563. </xsl:template>
  564.  
  565. <xsl:template match="w:font">
  566.     <xsl:element name="style:font-decl">
  567.         <xsl:attribute name="style:name"><xsl:value-of select="@w:name"/></xsl:attribute>
  568.         <xsl:attribute name="fo:font-family"><xsl:value-of select="@w:name"/></xsl:attribute>
  569.         <xsl:apply-templates/>
  570.     </xsl:element>
  571. </xsl:template>
  572.  
  573. <xsl:template match="w:family">
  574.     <xsl:attribute name="style:font-family-generic">
  575.     <xsl:choose>
  576.         <xsl:when test="@w:val = 'Swiss'">swiss</xsl:when>
  577.         <xsl:when test="@w:val='Modern'">modern</xsl:when>
  578.         <xsl:when test="@w:val='Roman'">roman</xsl:when>
  579.         <xsl:when test="@w:val='Script'">script</xsl:when>
  580.         <xsl:when test="@w:val='Decorative'">decorative</xsl:when>
  581.         <xsl:when test="@w:val='System'">system</xsl:when>
  582.     </xsl:choose>
  583.     </xsl:attribute>
  584. </xsl:template>
  585.  
  586. <xsl:template match="w:pitch">
  587.     <xsl:attribute name="style:font-pitch"><xsl:value-of select="@w:val"/></xsl:attribute>
  588. </xsl:template>
  589.  
  590. <!-- 
  591. <w:fonts>
  592.         <w:defaultFonts w:ascii="Times New Roman" w:fareast="Times New Roman" w:h-ansi="Times New Roman" w:cs="Times New Roman"/>
  593.         <w:font w:name="Tahoma">
  594.             <w:panose-1 w:val="020B0604030504040204"/>
  595.             <w:charset w:val="00"/>
  596.             <w:family w:val="Swiss"/>
  597.             <w:pitch w:val="variable"/>
  598.             <w:sig w:usb-0="61007A87" w:usb-1="80000000" w:usb-2="00000008" w:usb-3="00000000" w:csb-0="000101FF" w:csb-1="00000000"/>
  599.         </w:font>
  600.         <w:font w:name="Palatino">
  601.             <w:panose-1 w:val="00000000000000000000"/>
  602.             <w:charset w:val="00"/>
  603.             <w:family w:val="Roman"/>
  604.             <w:notTrueType/>
  605.             <w:pitch w:val="variable"/>
  606.             <w:sig w:usb-0="00000003" w:usb-1="00000000" w:usb-2="00000000" w:usb-3="00000000" w:csb-0="00000001" w:csb-1="00000000"/>
  607.         </w:font>
  608.     </w:fonts>
  609.     
  610.         <style:font-decl style:name="Andale Sans UI" fo:font-family="'Andale Sans UI'" style:font-pitch="variable"/>
  611.         <style:font-decl style:name="Thorndale" fo:font-family="Thorndale" style:font-family-generic="roman" style:font-pitch="variable"/>
  612.  
  613.     
  614. -->
  615.  
  616. <xsl:template match="wx:sect">
  617.     <!-- We handle Columns as seperate Sections to allow for different numbers of columns on the same page--> 
  618.     <xsl:choose>
  619.         <xsl:when test="descendant::w:sectPr[w:cols/@w:num > 1]">
  620.             <xsl:element name="text:section">
  621.                 <xsl:attribute name="text:style-name">sect<xsl:value-of select="count(preceding::w:sectPr[child::w:cols/@w:num >1])"/></xsl:attribute>
  622.                 <xsl:attribute name="text:name">sect<xsl:value-of select="count(preceding::w:sectPr[child::w:cols/@w:num >1])"/></xsl:attribute>
  623.                 <xsl:apply-templates/>
  624.             </xsl:element>
  625.         </xsl:when>
  626.         <xsl:otherwise>
  627.             <xsl:apply-templates/>
  628.         </xsl:otherwise>
  629.     </xsl:choose>
  630. </xsl:template>
  631.  
  632. <xsl:template match="*">
  633.     <xsl:apply-templates/>
  634. </xsl:template>
  635.  
  636.  
  637. <!-- 
  638.     Style Handling 
  639.  
  640. -->
  641.  
  642. <!--Styles-->
  643.  
  644. <xsl:template match="w:styles">
  645.     <xsl:element name="office:styles">
  646.         <style:style style:name="Numbering Symbols" style:family="text"/>
  647.         <style:style style:name="ColumnBreakPara" style:family="paragraph">
  648.             <style:properties  fo:break-after="column"/>
  649.         </style:style>
  650.         <xsl:element name="style:default-style">
  651.             <xsl:attribute name="style:family">paragraph</xsl:attribute>
  652.             <xsl:element name="style:properties">
  653.                 <xsl:attribute name="style:font-name">
  654.                 <xsl:choose><!--    <w:defaultFonts w:ascii="Times New Roman" w:fareast="Times New Roman" w:h-ansi="Times New Roman" w:cs="Times New Roman"/>
  655.  -->
  656.                     <xsl:when test="preceding::w:fonts/w:defaultFonts">
  657.                         <xsl:value-of select="preceding::w:fonts/w:defaultFonts/@w:ascii"/>
  658.                     </xsl:when>
  659.                     <xsl:otherwise>
  660.                         <xsl:text>Times New Roman</xsl:text>
  661.                     </xsl:otherwise>
  662.                 </xsl:choose>
  663.                 </xsl:attribute>
  664.                 <xsl:attribute name="style:tab-stop-distance"><xsl:value-of select="(number(/descendant::w:docPr/w:defaultTabStop/@w:val)div 1440)*2.54"/>cm</xsl:attribute>
  665.             </xsl:element>
  666.         </xsl:element>
  667.         <xsl:apply-templates/>
  668.         <style:style style:name="Bullet Symbols" style:family="text">
  669.             <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"/>
  670.         </style:style>
  671.     </xsl:element>
  672.     <xsl:element name="office:automatic-styles">
  673.         <xsl:element name="style:style">
  674.             <xsl:attribute name="style:name">PageBreak</xsl:attribute>
  675.             <xsl:attribute name="style:family">paragraph</xsl:attribute>
  676.             <xsl:attribute name="style:parent-style-name">Normal</xsl:attribute>
  677.             <xsl:element name="style:properties">
  678.                 <xsl:attribute name="fo:break-before">page</xsl:attribute>
  679.             </xsl:element>
  680.         </xsl:element>
  681.     
  682.         <xsl:for-each select="/descendant::w:rPr">
  683.             <style:style>
  684.                 <xsl:attribute name="style:name">T<xsl:value-of select="count(preceding::w:rPr)"/></xsl:attribute>
  685.                 <xsl:choose>
  686.                        <xsl:when test="@w:type">
  687.                            <xsl:choose>
  688.                             <xsl:when test="@w:type = 'character' ">
  689.                                 <xsl:attribute name="style:family">text</xsl:attribute>
  690.                             </xsl:when>
  691.                             <xsl:when test="@w:type = 'list' ">
  692.                                 <xsl:attribute name="style:family">text</xsl:attribute>
  693.                             </xsl:when>
  694.                             <xsl:otherwise>
  695.                                 <xsl:attribute name="style:family"><xsl:value-of select="@w:type"/></xsl:attribute>
  696.                             </xsl:otherwise>
  697.                         </xsl:choose>
  698.                        </xsl:when>
  699.                        <xsl:when test="ancestor::w:pPr">
  700.                            <xsl:attribute name="style:family">paragraph</xsl:attribute>
  701.                        </xsl:when>
  702.                        <xsl:otherwise>
  703.                            <xsl:attribute name="style:family">text</xsl:attribute>
  704.                        </xsl:otherwise>        
  705.                 </xsl:choose>
  706.                 <xsl:choose>
  707.                     <xsl:when test="child::w:rStyle">
  708.                         <xsl:attribute name="style:parent-style-name"><xsl:value-of select="child::w:rStyle/@w:val"/></xsl:attribute>
  709.                     </xsl:when>
  710.                     <xsl:otherwise>
  711.                         <xsl:attribute name="style:parent-style-name">Normal</xsl:attribute>
  712.                     </xsl:otherwise>
  713.                 </xsl:choose>        
  714.                 <xsl:element name="style:properties">
  715.                     <xsl:apply-templates select="child::*"/>
  716.                    </xsl:element>    
  717.             </style:style>
  718.         </xsl:for-each>
  719.         
  720.         <xsl:for-each select="/descendant::w:pPr">
  721.             <style:style>
  722.                 <xsl:attribute name="style:name">P<xsl:value-of select="count(preceding::w:pPr)"/></xsl:attribute>
  723.                 <xsl:choose>
  724.                        <xsl:when test="@w:type">
  725.                            <xsl:choose>
  726.                             <xsl:when test="@w:type = 'character' ">
  727.                                 <xsl:attribute name="style:family">text</xsl:attribute>
  728.                             </xsl:when>
  729.                             <xsl:when test="@w:type = 'list' ">
  730.                                 <xsl:attribute name="style:family">text</xsl:attribute>
  731.                             </xsl:when>
  732.                             <xsl:otherwise>
  733.                                 <xsl:attribute name="style:family"><xsl:value-of select="@w:type"/></xsl:attribute>
  734.                             </xsl:otherwise>
  735.                         </xsl:choose>
  736.                        </xsl:when>
  737.                        <xsl:when test="parent::w:p">
  738.                            <xsl:attribute name="style:family">paragraph</xsl:attribute>
  739.                        </xsl:when>
  740.                        <xsl:otherwise>
  741.                            <xsl:attribute name="style:family">text</xsl:attribute>
  742.                        </xsl:otherwise>        
  743.                 </xsl:choose>
  744.                 <xsl:choose>
  745.                     <xsl:when test="child::w:pStyle">
  746.                         <xsl:attribute name="style:parent-style-name"><xsl:value-of select="child::w:pStyle/@w:val"/></xsl:attribute>
  747.                     </xsl:when>
  748.                     <xsl:otherwise>
  749.                         <xsl:attribute name="style:parent-style-name">Normal</xsl:attribute>
  750.                     </xsl:otherwise>
  751.                 </xsl:choose>        
  752.                 <!-- We don't want to change the page style if there are columns being created. 
  753.                     The Columns will be handled by using in-line sections.-->
  754.                 <xsl:if test="not(ancestor::wx:sect[1]/descendant::w:sectPr/w:cols[@w:num > 1])">
  755.                     <xsl:variable name="parentpara" select="parent::w:p"/>                
  756.                     <xsl:if test="generate-id(ancestor::wx:sect/descendant::w:p[1]) = generate-id($parentpara)">                    
  757.                         <xsl:choose>
  758.                             <xsl:when test="not(count(preceding::wx:sect) > 0)">
  759.                                 <xsl:attribute name="style:master-page-name">Standard</xsl:attribute>
  760.                             </xsl:when>
  761.                             <xsl:otherwise>
  762.                                 <xsl:attribute name="style:master-page-name">Standard<xsl:value-of select="number(count(preceding::wx:sect) )"/></xsl:attribute>
  763.                             </xsl:otherwise>
  764.                         </xsl:choose>
  765.                     </xsl:if>
  766.                 </xsl:if>
  767.                 <xsl:variable name="rootPara" select="parent::w:p"/>
  768.                 <xsl:if test="$rootPara/descendant::w:br[@w:type = 'page']">
  769.         <!--<w:br w:type="page"/>
  770.         <style:properties fo:margin-left="0.026cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" fo:break-before="page"/>
  771.                                 -->
  772.                     <xsl:if test="not(ancestor::wx:sect[1]/descendant::w:sectPr/w:cols[@w:num > 1]) and not($rootPara/descendant::w:br/@w:type='text-wrapping')">
  773.  
  774.                     <xsl:variable name="parentsect" select="ancestor::wx:sect"/>
  775.                     <xsl:choose>
  776.                         <xsl:when test="following::w:sectPr">        
  777.                             <xsl:choose>
  778.                                 <xsl:when test="not(count(preceding::wx:sect) > 0)">
  779.                                     <xsl:attribute name="style:master-page-name">Standard</xsl:attribute>
  780.                                 </xsl:when>
  781.                                 <xsl:otherwise>
  782.                                     <xsl:attribute name="style:master-page-name">Standard<xsl:value-of select="number(count(preceding::wx:sect) )"/></xsl:attribute>
  783.                                 </xsl:otherwise>
  784.                             </xsl:choose>
  785.                                  </xsl:when>
  786.                         <xsl:otherwise>
  787.                             <xsl:attribute name="fo:break-before"><xsl:value-of select="$rootPara/descendant::w:br/@w:type"/></xsl:attribute>            
  788.                         </xsl:otherwise>
  789.                     </xsl:choose>
  790.                     </xsl:if>
  791.              </xsl:if>                
  792.                 
  793.                 
  794.                 
  795.     
  796.                 
  797.                 <xsl:element name="style:properties">
  798.                     <xsl:if test="parent::w:p">
  799.                         <!-- Initial indent values-->
  800.                         <!--<xsl:attribute name="fo:margin-left">0cm</xsl:attribute>
  801.                         <xsl:attribute name="fo:margin-right">0cm</xsl:attribute>
  802.                         <xsl:attribute name="fo:text-indent">0cm</xsl:attribute>-->
  803.                         <xsl:call-template name="paragraph-alignment"/>
  804.                     </xsl:if>
  805.                     <xsl:if test="not(ancestor::wx:sect = following::w:pPr/ancestor::wx:sect)">
  806.                                 <!--<xsl:attribute name="fo:break-after">page</xsl:attribute>-->
  807.                     </xsl:if>
  808.                     <xsl:apply-templates select="parent::w:p/child::w:rPr/*[not(name() = 'w:tabs')]"/>
  809.                        <xsl:apply-templates select="child::*[not(name() = 'w:tabs')]"/>
  810.                        
  811.                    </xsl:element>    
  812.             </style:style>
  813.         </xsl:for-each>
  814.  
  815.         
  816.         <xsl:for-each select="/descendant::w:gridCol ">
  817.             <style:style>
  818.                 <xsl:variable name="tableRoot" select="ancestor::w:tbl"/>
  819.                 <xsl:attribute name="style:name">TColumn<xsl:value-of select="count(preceding::w:gridCol)"/></xsl:attribute>    
  820.                 <xsl:attribute name="style:family">table-column</xsl:attribute>
  821.                 <xsl:element name="style:properties">
  822.                     <xsl:attribute name="style:column-width">
  823.                     <xsl:choose>
  824.                         <xsl:when test="$tableRoot/w:tblPr/w:tblW/@w:type = 'pct'">
  825.                             <xsl:variable name="pageSize" select="number(/descendant::w:body/wx:sect/w:sectPr/w:pgSz/@w:w)"/>
  826.                             <xsl:variable name="pageLeftMar" select="number(/descendant::w:body/wx:sect/w:sectPr/w:pgMar/@w:left)"/>
  827.                             <xsl:variable name="pageRightMar" select="number(/descendant::w:body/wx:sect/w:sectPr/w:pgMar/@w:right)"/>
  828.                             <xsl:variable name="pctTotal" select="$tableRoot/w:tblPr/w:tblW/@w:w"/>
  829.                             <xsl:variable name="prevCols" select="count(preceding-sibling::w:gridCol)"/>
  830.                             <xsl:variable name="relSize" select="$tableRoot/w:tr[1]/w:tc[$prevCols+1]/w:tcPr/w:tcW/@w:w"/>
  831.                             <!--<xsl:value-of select="$relSize"/>
  832.                             <xsl:text> </xsl:text>
  833.                             <xsl:value-of select="$pctTotal"/>
  834.                             <xsl:text> </xsl:text>
  835.                             <xsl:value-of select="$pageSize"/>
  836.                             <xsl:text> </xsl:text>-->
  837.                             <xsl:value-of select="(number(($relSize div $pctTotal) * ($pageSize - ($pageLeftMar + $pageRightMar))) div 1440) *2.54"/>
  838.                         <!-- 
  839.                                 <w:tblPr>
  840.                     <w:tblStyle w:val="TableGrid"/>
  841.                     <w:tblW w:w="0" w:type="auto"/>
  842.                     <w:tblLook w:val="000001E0"/>
  843.                 </w:tblPr>
  844.  
  845.                         
  846.                             <xsl:variable name="percentTotal" select="child::w:tblW/@w:w"/>
  847.                             <xsl:variable name="aRow" select="following-sibling::w:tr[1]/w:tc/w:tcPr/w:tcW/@w:w"/>
  848.                             <xsl:for-each select="$aRow">
  849.                         
  850.                                 -->
  851.                         </xsl:when>
  852.                         <xsl:otherwise>
  853.                             <xsl:value-of select="(number(@w:w) div 1440) *2.54"/>
  854.                         </xsl:otherwise>
  855.                     </xsl:choose>
  856.                     <xsl:text>cm</xsl:text>
  857.                     </xsl:attribute>
  858.                  </xsl:element>    
  859.             </style:style>
  860.         </xsl:for-each>
  861.         <xsl:for-each select="/descendant::w:tblPr">
  862.             <xsl:element name="style:style">
  863.                 <xsl:attribute name="style:name">TTable<xsl:value-of select="count(preceding::w:tblPr)"/></xsl:attribute>    
  864.                 <xsl:attribute name="style:family">table</xsl:attribute>
  865.                 <xsl:element name="style:properties">
  866.                 
  867.                     <!-- Hard coded to be over-ridden later-->
  868.                     
  869.                     <xsl:attribute name="table:align">left</xsl:attribute>
  870.                      <xsl:attribute name="style:writing-mode">lr-tb</xsl:attribute>
  871.                     <!-- <w:tblW w:w="5000" w:type="pct"/>-->
  872.                     
  873.                     <!-- Setting table margins using cell padding-->
  874.                     <xsl:if test="child::w:tblStyle/@w:val">
  875.                         <xsl:variable name="rootStyle" select="child::w:tblStyle/@w:val"/>
  876.                         <xsl:variable name="rootStyleNode" select="/descendant::w:style[@w:styleId = $rootStyle]"/>
  877.                         <xsl:variable name="paddingleft"><xsl:value-of select="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:left/@w:w"/></xsl:variable>    
  878.                         <xsl:variable name="paddingright"><xsl:value-of select="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:right/@w:w"/></xsl:variable>    
  879.                         <xsl:variable name="paddingtop"><xsl:value-of select="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:top/@w:w"/></xsl:variable>    
  880.                         <xsl:variable name="paddingbottom"><xsl:value-of select="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:bottom/@w:w"/></xsl:variable>    
  881.                     
  882.                         <xsl:if test="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:left">
  883.                                 <xsl:attribute name="fo:margin-left">-<xsl:value-of select="(number($paddingleft) div 1440) *2.54"/>cm</xsl:attribute>
  884.                         </xsl:if>
  885.                         <!--
  886.                         <xsl:if test="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:right">
  887.                             <xsl:attribute name="fo:margin-right">-<xsl:value-of select="(number($paddingright) div 1440) *2.54"/>cm</xsl:attribute>
  888.                         </xsl:if>
  889.                         -->
  890.             
  891.                     </xsl:if>
  892.                     
  893.                     
  894.                     
  895.                     <xsl:choose>
  896.                         <xsl:when test="child::w:tblW/@w:type ='pct'">
  897.                                 <xsl:variable name="sectPr" select="/descendant::wx:sect/w:sectPr"/>    
  898.                                 <xsl:variable name="pageSize" select="number($sectPr/w:pgSz/@w:w)"/>
  899.                                 <xsl:variable name="pageLeftMar" select="number($sectPr/w:pgMar/@w:left)"/>
  900.                                 <xsl:variable name="pageRightMar" select="number($sectPr/w:pgMar/@w:right)"/>
  901.                                 
  902.                                 <xsl:attribute name="style:width">    
  903.                                     <xsl:value-of select="((    (number($sectPr/w:pgSz/@w:w) - number($pageLeftMar + $pageRightMar)  +(113 *2))div 1440)*2.54)*(number(child::w:tblW/@w:w) div 5000)"/>
  904.                                     <xsl:text>cm</xsl:text>
  905.                                 </xsl:attribute>    
  906.                         </xsl:when>
  907.                         <xsl:otherwise>
  908.                             
  909.                             <xsl:variable name="colwidth" select="parent::w:tbl"/>
  910.                             <xsl:variable name="gridcols" select="$colwidth/w:tblGrid/w:gridCol"/>
  911.                             <xsl:variable name="tblsize" select="sum($gridcols/@w:w)"/>
  912.                             <xsl:if test="not($tblsize='0')">
  913.                                 <xsl:attribute name="style:width">
  914.                                     <xsl:choose>
  915.                                         <xsl:when test="child::w:tblInd">
  916.                                             <xsl:value-of select="(number($tblsize -  child::w:tblInd/@w:w) div 1440)*2.54"/>
  917.                                         </xsl:when>
  918.                                         <xsl:otherwise>
  919.                                             <xsl:value-of select="(number($tblsize  ) div 1440)*2.54"/>
  920.                                         </xsl:otherwise>
  921.                                     </xsl:choose>
  922.                                     <xsl:text>cm</xsl:text>
  923.                                 </xsl:attribute>
  924.                             </xsl:if>
  925.                             <!-- If previous w:p has a page break, the table must have
  926.                                  the page break attribute applied to it
  927.                             -->
  928.                             
  929.                             <!-- May need this for tables starting on new pages-->
  930.                             <!--<xsl:if test="parent::w:tbl/preceding-sibling::w:p[1][descendant::w:br/@w:type='page']">
  931.                                 <xsl:attribute name="fo:break-before">page</xsl:attribute>
  932.                             </xsl:if>-->
  933.                         </xsl:otherwise>
  934.                     </xsl:choose>
  935.                     <!-- initial values for tables-->
  936.                           <!--<xsl:attribute name="fo:border-left">0.002cm solid #000000</xsl:attribute>
  937.                            <xsl:attribute name="fo:border-right">0.002cm solid #000000</xsl:attribute>
  938.                         <xsl:attribute name="fo:border-top">0.002cm solid #000000</xsl:attribute>
  939.                         <xsl:attribute name="fo:border-bottom">0.002cm solid #000000</xsl:attribute>
  940.                         <xsl:attribute name="fo:vertical-align">top</xsl:attribute>
  941.                         <xsl:attribute name="fo:padding-left">0.191cm</xsl:attribute>
  942.                         <xsl:attribute name="fo:padding-right">0.191cm</xsl:attribute>
  943.                         <xsl:attribute name="fo:padding-top">0cm</xsl:attribute>
  944.                         <xsl:attribute name="fo:padding-bottom">0cm</xsl:attribute>-->
  945.                         <xsl:apply-templates/>
  946.                    </xsl:element>    
  947.             </xsl:element>
  948.         </xsl:for-each>
  949.         <xsl:for-each select="/descendant::w:tcPr">
  950.             <style:style>
  951.                 <xsl:attribute name="style:name">TCell<xsl:value-of select="count(preceding::w:tcPr)"/></xsl:attribute>    
  952.                 <xsl:attribute name="style:family">table-cell</xsl:attribute>
  953.                 <xsl:element name="style:properties">
  954.                     <!-- Hard coded initial borders-->
  955.                         <xsl:if test="ancestor::w:tbl/w:tblPr/w:tblStyle/@w:val">
  956.                             <xsl:variable name="rootStyle" select="ancestor::w:tbl/w:tblPr/w:tblStyle/@w:val"/>
  957.                             <xsl:variable name="rootStyleNode" select="/descendant::w:style[@w:styleId = $rootStyle]"/>
  958.                             <xsl:if test="$rootStyleNode/w:tcPr/w:shd/@wx:bgcolor">
  959.                                 <xsl:attribute name="fo:background-color">#<xsl:value-of select="$rootStyleNode/w:tcPr/w:shd/@wx:bgcolor"/></xsl:attribute>
  960.                             </xsl:if>
  961.                             <xsl:variable name="paddingleft"><xsl:value-of select="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:left/@w:w"/></xsl:variable>    
  962.                             <xsl:variable name="paddingright"><xsl:value-of select="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:right/@w:w"/></xsl:variable>    
  963.                             <xsl:variable name="paddingtop"><xsl:value-of select="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:top/@w:w"/></xsl:variable>    
  964.                             <xsl:variable name="paddingbottom"><xsl:value-of select="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:bottom/@w:w"/></xsl:variable>    
  965.                     
  966.                             
  967.                             <xsl:if test="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:left">
  968.                                 <xsl:attribute name="fo:padding-left"><xsl:value-of select="(number($paddingleft) div 1440) *2.54"/>cm</xsl:attribute>
  969.                             </xsl:if>
  970.                             <xsl:if test="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:right">
  971.                                 <xsl:attribute name="fo:padding-right"><xsl:value-of select="(number($paddingright) div 1440) *2.54"/>cm</xsl:attribute>
  972.                             </xsl:if>
  973.                             <xsl:if test="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:top">
  974.                                 <xsl:attribute name="fo:padding-top"><xsl:value-of select="(number($paddingtop) div 1440) *2.54"/>cm</xsl:attribute>
  975.                             </xsl:if>
  976.                             <xsl:if test="$rootStyleNode/child::w:tblPr/w:tblCellMar/w:bottom">
  977.                                 <xsl:attribute name="fo:padding-bottom"><xsl:value-of select="(number($paddingbottom) div 1440) *2.54"/>cm</xsl:attribute>
  978.                             </xsl:if>
  979.                         </xsl:if>
  980.                         
  981.                         
  982.                         <xsl:variable name="cellbefore"><xsl:value-of select="count(ancestor::w:tc/preceding-sibling::w:tc)"/></xsl:variable>
  983.                         <xsl:variable name="cellafter"><xsl:value-of select="count(ancestor::w:tc/following-sibling::w:tc)"/></xsl:variable>
  984.                         <xsl:variable name="rowbefore"><xsl:value-of select="count(ancestor::w:tr/preceding-sibling::w:tr)"/></xsl:variable>
  985.                         <xsl:variable name="table" select="ancestor::w:tbl/w:tblPr"/>
  986.                         <xsl:choose>    
  987.                             <xsl:when test="$table/w:tblBorders">
  988.                                 <!--<w:top w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  989.                         <w:left w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  990.                         <w:bottom w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  991.                         <w:right w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  992.                         <w:insideH w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  993.                         <w:insideV w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>-->
  994.                                 <xsl:variable name="Borders" select="$table/w:tblBorders"/>
  995.                                 <xsl:attribute name="fo:border-top">
  996.                                     <xsl:choose>
  997.                                             <xsl:when test="number($rowbefore) > 0">
  998.                                                     <xsl:text>none</xsl:text>                                                                                    </xsl:when>                    
  999.                                             <xsl:otherwise>
  1000.                                                 <xsl:value-of select="(number($Borders/w:top/@wx:bdrwidth)div 1440)*2.54"/>
  1001.                                                 <xsl:text>cm </xsl:text>
  1002.                                             </xsl:otherwise>
  1003.                                     </xsl:choose>
  1004.                                     <xsl:if test="not(number($rowbefore) > 0)">
  1005.                                         <xsl:choose>
  1006.                                             <xsl:when test="$Borders/w:top/@w:color ='auto'">
  1007.                                                 <xsl:text>solid #000000</xsl:text>
  1008.                                             </xsl:when>
  1009.                                             <xsl:otherwise>
  1010.                                                 <xsl:text>solid #</xsl:text><xsl:value-of select="$Borders/w:top/@w:color"/>
  1011.                                             </xsl:otherwise>
  1012.                                         </xsl:choose>
  1013.                                     </xsl:if>
  1014.                                 </xsl:attribute>
  1015.                                 <xsl:attribute name="fo:border-bottom">
  1016.                                     <xsl:value-of select="(number($Borders/w:bottom/@wx:bdrwidth)div 1440)*2.54"/>
  1017.                                     <xsl:text>cm </xsl:text>
  1018.                                     <xsl:choose>
  1019.                                         <xsl:when test="$Borders/w:bottom/@w:color ='auto'">
  1020.                                             <xsl:text>solid #000000</xsl:text>
  1021.                                         </xsl:when>
  1022.                                         <xsl:otherwise>
  1023.                                             <xsl:text>solid #</xsl:text><xsl:value-of select="$Borders/w:bottom/@w:color"/>
  1024.                                         </xsl:otherwise>
  1025.                                     </xsl:choose>
  1026.                                 </xsl:attribute>
  1027.                                 <xsl:attribute name="text:aidan"><xsl:value-of select="$cellafter"/></xsl:attribute>
  1028.                                 <xsl:attribute name="fo:border-right">
  1029.                                       <xsl:choose>
  1030.                                         <xsl:when test="number($cellafter) > 0">
  1031.                                                 <xsl:text>none</xsl:text>                                                                                    </xsl:when>                    
  1032.                                         <xsl:otherwise>
  1033.                                               <xsl:value-of select="(number($Borders/w:right/@wx:bdrwidth)div 1440)*2.54"/>
  1034.                                               <xsl:text>cm </xsl:text>
  1035.                                         </xsl:otherwise>
  1036.                                     </xsl:choose>
  1037.                                     <xsl:if test="not(number($cellafter) > 0)">
  1038.                                     <xsl:choose>
  1039.                                         <xsl:when test="$Borders/w:right/@w:color ='auto'">
  1040.                                             <xsl:text>solid #000000</xsl:text>
  1041.                                         </xsl:when>
  1042.                                         <xsl:otherwise>
  1043.                                             <xsl:text>solid #</xsl:text><xsl:value-of select="$Borders/w:right/@w:color"/>
  1044.                                         </xsl:otherwise>
  1045.                                     </xsl:choose>
  1046.                                     </xsl:if>
  1047.                                 </xsl:attribute>
  1048.                                     <xsl:attribute name="fo:border-left">
  1049.                                     <xsl:value-of select="(number($Borders/w:left/@wx:bdrwidth)div 1440)*2.54"/>
  1050.                                     <xsl:text>cm </xsl:text>
  1051.                                     <xsl:choose>
  1052.                                         <xsl:when test="$Borders/w:left/@w:color ='auto'">
  1053.                                             <xsl:text>solid #000000</xsl:text>
  1054.                                         </xsl:when>
  1055.                                         <xsl:otherwise>
  1056.                                             <xsl:text>solid #</xsl:text><xsl:value-of select="$Borders/w:left/@w:color"/>
  1057.                                         </xsl:otherwise>
  1058.                                     </xsl:choose>
  1059.                                 </xsl:attribute>
  1060.                             </xsl:when>
  1061.                             <xsl:otherwise>
  1062.                                 <xsl:attribute name="fo:border-right">
  1063.                                 <xsl:choose>
  1064.                                         <xsl:when test="number($cellafter) > 0">
  1065.                                                 <xsl:text>none</xsl:text>                                                                                    </xsl:when>                    
  1066.                                         <xsl:otherwise>
  1067.                                               <xsl:text>0.002cm solid #000000</xsl:text>
  1068.                                         </xsl:otherwise>
  1069.                                 </xsl:choose>
  1070.                                 </xsl:attribute>
  1071.                                 <xsl:attribute name="fo:border-left">
  1072.                                           <xsl:text>0.002cm solid #000000</xsl:text>
  1073.                                 </xsl:attribute>
  1074.                                 <xsl:attribute name="fo:border-top">
  1075.                                     <xsl:choose>
  1076.                                             <xsl:when test="number($rowbefore) > 0">
  1077.                                                     <xsl:text>none</xsl:text>                                                                                    </xsl:when>                    
  1078.                                             <xsl:otherwise>
  1079.                                                   <xsl:text>0.002cm solid #000000</xsl:text>
  1080.                                             </xsl:otherwise>
  1081.                                     </xsl:choose>
  1082.                                 </xsl:attribute>
  1083.                                 <xsl:attribute name="fo:border-bottom">0.002cm solid #000000</xsl:attribute>
  1084.                             </xsl:otherwise>
  1085.                         </xsl:choose>
  1086.                         <xsl:attribute name="fo:vertical-align">top</xsl:attribute>
  1087.                         <!--<xsl:attribute name="fo:padding-left">0.191cm</xsl:attribute>
  1088.                         <xsl:attribute name="fo:padding-right">0.191cm</xsl:attribute>
  1089.                         <xsl:attribute name="fo:padding-top">0cm</xsl:attribute>
  1090.                         <xsl:attribute name="fo:padding-bottom">0cm</xsl:attribute>-->
  1091.                           <xsl:apply-templates/>
  1092.                    </xsl:element>        
  1093.             </style:style>
  1094.         </xsl:for-each>
  1095.         <xsl:for-each select="/descendant::w:listPr">
  1096.             <xsl:variable name="currlistid" select="child::w:ilfo/@w:val"/>
  1097.             <xsl:variable name="currlist" select="."/>
  1098.             <xsl:variable name="rootlistmap" select="/descendant::w:list[child::w:ilst/@w:val=$currlistid]"/>
  1099.             <xsl:variable name="rootlistid" select="/descendant::w:list[@w:ilfo=$currlistid]/w:ilst/@w:val"/>
  1100.             <xsl:variable name="rootlist"  select="/descendant::w:listDef[@w:listDefId =$rootlistid ]"/>
  1101.         
  1102.             <xsl:if test="not(ancestor::w:p/preceding-sibling::w:p[1]/w:pPr/w:listPr/w:ilfo/@w:val= $currlistid) ">
  1103.             <xsl:element name="text:list-style">
  1104.                 <xsl:attribute name="style:name">TList<xsl:value-of select="count(preceding::w:listPr)"/></xsl:attribute>
  1105.                 <xsl:variable name="currlevel" select="number(child::w:ilvl/@w:val)"/>
  1106.                 <xsl:for-each select="$rootlist/child::w:lvl">
  1107.                     <!--<xsl:variable name="listtype" select="$rootlist/w:lvl[@w:ilvl= $currlevel]/w:nfc/@w:val"/>-->
  1108.                 <xsl:variable name="listtype" select="w:nfc/@w:val"/>
  1109.                     <!--<xsl:value-of select="$currlistid"/>
  1110.                     maps to<xsl:value-of select="$rootlistid"/>-->
  1111.                     <xsl:choose>
  1112.                         <xsl:when test="$listtype =2">
  1113.                             <xsl:element name="text:list-level-style-number">
  1114.                                 <xsl:call-template name="list-styles-common">
  1115.                                     <xsl:with-param name="listtype" select="$listtype"/>
  1116.                                     <xsl:with-param name="rootlist" select="$rootlist"/>
  1117.                                     <xsl:with-param name="currlist" select="$currlist"/>
  1118.                                 </xsl:call-template>
  1119.                             </xsl:element>
  1120.                         </xsl:when>
  1121.                             <xsl:when test="$listtype =23">
  1122.                             <xsl:element name="text:list-level-style-bullet"><!-- should be bullet?-->
  1123.                                 <xsl:call-template name="list-styles-common">
  1124.                                     <xsl:with-param name="listtype" select="$listtype"/>
  1125.                                     <xsl:with-param name="rootlist" select="$rootlist"/>
  1126.                                     <xsl:with-param name="currlist" select="$currlist"/>
  1127.                                 </xsl:call-template>
  1128.                             </xsl:element>
  1129.                         </xsl:when>
  1130.                         <xsl:otherwise>
  1131.                             <xsl:element name="text:list-level-style-number"><!-- should be bullet?-->
  1132.                                 <xsl:call-template name="list-styles-common">
  1133.                                     <xsl:with-param name="listtype" select="$listtype"/>
  1134.                                     <xsl:with-param name="rootlist" select="$rootlist"/>
  1135.                                     <xsl:with-param name="currlist" select="$currlist"/>
  1136.                                 </xsl:call-template>
  1137.                             </xsl:element>
  1138.                         </xsl:otherwise>
  1139.                     </xsl:choose>    
  1140.                 </xsl:for-each>
  1141.             </xsl:element>
  1142.             </xsl:if>
  1143.         </xsl:for-each>
  1144.         <!--<style:page-master style:name="pm1">
  1145.             <style:properties fo:page-width="21.59cm" fo:page-height="27.94cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
  1146.                 <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
  1147.             </style:properties>
  1148.             <style:header-style/>
  1149.             <style:footer-style/>
  1150.         </style:page-master>
  1151.         
  1152.         <w:sectPr>
  1153.                 <w:pgSz w:w="12240" w:h="15840"/>
  1154.                 <w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="708" w:footer="708" w:gutter="0"/>
  1155.                 <w:cols w:space="708"/>
  1156.                 <w:docGrid w:line-pitch="360"/>
  1157.             </w:sectPr>
  1158.         </wx:sect>
  1159.  
  1160.  -->
  1161.          <xsl:variable name="sectPr" select="/descendant::w:sectPr"/>
  1162.         <xsl:for-each select="$sectPr">
  1163.             <xsl:element name="style:page-master">
  1164.                 <xsl:attribute name="style:name">pm<xsl:value-of select="count(preceding::w:sectPr)"/></xsl:attribute>
  1165.                 <xsl:element name="style:properties">
  1166.                     <xsl:attribute name="fo:page-width"><xsl:value-of select="(number(w:pgSz/@w:w) div 1440)*2.54"/>cm</xsl:attribute>
  1167.                     <xsl:attribute name="fo:page-height"><xsl:value-of select="(number(w:pgSz/@w:h) div 1440)*2.54"/>cm</xsl:attribute>
  1168.                     <xsl:attribute name="fo:margin-top"><xsl:value-of select="(number(w:pgMar/@w:top) div 1440)*2.54"/>cm</xsl:attribute>
  1169.                     <xsl:attribute name="fo:margin-bottom"><xsl:value-of select="(number(w:pgMar/@w:bottom) div 1440)*2.54"/>cm</xsl:attribute>
  1170.                     <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>
  1171.                     <xsl:attribute name="fo:margin-right"><xsl:value-of select="(number(w:pgMar/@w:right) div 1440)*2.54"/>cm</xsl:attribute>
  1172.                     <xsl:attribute name="style:footnote-max-height"><xsl:value-of select="(number(w:pgMar/@w:footer) div 1440)*2.54"/></xsl:attribute>
  1173.                     <xsl:if test="w:pgSz/@w:orient">
  1174.                         <xsl:attribute name="style:print-orientation"><xsl:value-of select="w:pgSz/@w:orient"/></xsl:attribute>
  1175.                     </xsl:if>
  1176.             
  1177.                     <xsl:if test="w:cols/@w:num">
  1178.                         <!-- needs to be fixed -->
  1179.                         <!--<xsl:element name="style:columns">
  1180.                             <xsl:attribute name="fo:column-count"><xsl:value-of select="number(w:cols/@w:num)"/></xsl:attribute>
  1181.                             <xsl:attribute name="fo:column-gap"><xsl:value-of select="(number(w:cols/@w:space)div 1440)*2.54"/></xsl:attribute>
  1182.                         </xsl:element>-->
  1183.                     </xsl:if>
  1184.                 </xsl:element>
  1185.             </xsl:element>    
  1186.             <xsl:if test="w:cols/@w:num">
  1187.             <!-- create sction property-->
  1188.                 <xsl:element name="style:style">
  1189.                     <xsl:attribute name="style:name">sect<xsl:value-of select="count(preceding::w:sectPr[child::w:cols/@w:num])"/></xsl:attribute>
  1190.                     <xsl:attribute name="style:family">section</xsl:attribute>
  1191.                     <xsl:element name="style:properties">
  1192.                         <xsl:element name="style:columns">
  1193.                             <xsl:attribute name="fo:column-count"><xsl:value-of select="number(w:cols/@w:num)"/></xsl:attribute>
  1194.                             <xsl:attribute name="fo:column-gap"><xsl:value-of select="(number(w:cols/@w:space)div 1440)*2.54"/>cm</xsl:attribute>
  1195.                         </xsl:element>
  1196.                     </xsl:element>
  1197.                 </xsl:element>
  1198.             </xsl:if>
  1199.         </xsl:for-each>
  1200.     </xsl:element>
  1201.     <office:master-styles>
  1202.         <xsl:variable name="sectPr" select="/descendant::w:sectPr"/>
  1203.         <xsl:for-each select="$sectPr">
  1204.         <!-- style:page-master style:style-->
  1205.             <xsl:element name="style:master-page">
  1206.                 <xsl:choose>
  1207.                     <xsl:when test="not (count(preceding::w:sectPr) > 0 )">
  1208.                         <xsl:attribute name="style:name">Standard</xsl:attribute>
  1209.                     </xsl:when>
  1210.                     <xsl:otherwise>
  1211.                         <xsl:attribute name="style:name">Standard<xsl:value-of select="count(preceding::w:sectPr)"/></xsl:attribute>
  1212.                     </xsl:otherwise>
  1213.                 </xsl:choose>
  1214.                 <xsl:attribute name="style:page-master-name">pm<xsl:value-of select="count(preceding::w:sectPr)"/></xsl:attribute>
  1215.                 <xsl:if test="following::w:sectPr">
  1216.                     <xsl:attribute name="style:next-style-name">Standard<xsl:value-of select="count(preceding::w:sectPr)+1"/></xsl:attribute>
  1217.                 </xsl:if>
  1218.         
  1219.         <!-- Headers and footers-->
  1220.             <xsl:element name="style:header-style">
  1221.                 <xsl:element name="style:properties">
  1222.                     <xsl:attribute  name="fo:min-height"><xsl:value-of select="(number(child::w:pgMar/@w:header)div 1440)*2.54"/>cm</xsl:attribute>
  1223.                     <xsl:attribute  name="fo:margin-bottom">0.792cm</xsl:attribute>
  1224.                     <xsl:attribute  name="style:dynamic-spacing">true</xsl:attribute>
  1225.                 </xsl:element>
  1226.             </xsl:element>
  1227.             <xsl:element name="style:footer-style">
  1228.                 <xsl:element name="style:properties">
  1229.                     <xsl:attribute  name="fo:min-height"><xsl:value-of select="(number(child::w:pgMar/@w:footer)div 1440)*2.54"/>cm</xsl:attribute>
  1230.                     <xsl:attribute  name="fo:margin-top">0.792cm</xsl:attribute>
  1231.                     <xsl:attribute  name="style:dynamic-spacing">true</xsl:attribute>
  1232.                 </xsl:element>
  1233.             </xsl:element>
  1234.  
  1235.             <xsl:if test="child::w:hdr">
  1236.                 <xsl:element name="style:header">
  1237.                     <xsl:apply-templates select="child::w:hdr[@w:type='odd']/*"/>
  1238.                 </xsl:element>
  1239.                 <xsl:element name="style:header-left">
  1240.                     <xsl:apply-templates select="child::w:hdr[@w:type='even']/*"/>
  1241.                 </xsl:element>
  1242.             </xsl:if>
  1243.             <xsl:if test="child::w:ftr">
  1244.                 <xsl:element name="style:footer">
  1245.                     <xsl:apply-templates select="child::w:ftr[@w:type='odd']/*"/>
  1246.                 </xsl:element>
  1247.                 <xsl:element name="style:footer-left">
  1248.                     <xsl:apply-templates select="child::w:ftr[@w:type='even']/*"/>
  1249.                 </xsl:element>
  1250.             </xsl:if>
  1251.             </xsl:element>        
  1252.         </xsl:for-each>
  1253.         <!--<style:master-page style:name="Standard" style:page-master-name="pm1" style:next-style-name="Sandard1"/>
  1254.         <style:master-page style:name="Standard1" style:page-master-name="pm2"/>-->
  1255.     </office:master-styles>
  1256. </xsl:template>
  1257.  
  1258. <xsl:template name="paragraph-alignment">
  1259. <!-- template for setting indents and alignment-->    
  1260.     <xsl:choose>
  1261.         <xsl:when test="descendant::w:ind[@w:left]">
  1262.             <xsl:attribute name="fo:margin-left"><xsl:value-of select="number(((descendant::w:ind/@w:left)div 1440) *2.54)"/>cm</xsl:attribute>
  1263.         </xsl:when>            
  1264.         <xsl:otherwise>
  1265.             <xsl:attribute name="fo:margin-left">0cm</xsl:attribute>
  1266.         </xsl:otherwise>
  1267.     </xsl:choose>
  1268.     
  1269.     <xsl:choose>
  1270.         <xsl:when test="descendant::w:ind[@w:right]">
  1271.             <xsl:attribute name="fo:margin-right"><xsl:value-of select="number(((descendant::w:ind/@w:right)div 1440) *2.54)"/>cm</xsl:attribute>
  1272.         </xsl:when>            
  1273.         <xsl:otherwise>
  1274.             <xsl:attribute name="fo:margin-right">0cm</xsl:attribute>
  1275.         </xsl:otherwise>    
  1276.     </xsl:choose>
  1277.     
  1278.     <xsl:choose>
  1279.         <xsl:when test="descendant::w:ind[@w:first-line]">
  1280.             <xsl:attribute name="fo:text-indent"><xsl:value-of select="number(((descendant::w:ind/@w:first-line)div 1440) *2.54)"/>cm</xsl:attribute>
  1281.         </xsl:when>            
  1282.         <xsl:otherwise>
  1283.             <xsl:attribute name="fo:text-indent">0cm</xsl:attribute>
  1284.         </xsl:otherwise>        
  1285.     </xsl:choose>            
  1286.                     
  1287.     <xsl:call-template name="bidi"/>
  1288.  
  1289.     <!--<w:tabs>
  1290.                         <w:tab w:val="left" w:pos="284"/>
  1291.                         <w:tab w:val="left" w:pos="709"/>
  1292.                         <w:tab w:val="left" w:pos="1134"/>
  1293.                         <w:tab w:val="left" w:pos="1985"/>
  1294.                     </w:tabs>-->
  1295.     <xsl:if test="descendant::w:tabs">
  1296.         <xsl:element name="style:tab-stops">
  1297.             <xsl:for-each select="descendant::w:tabs/w:tab">
  1298.                 <xsl:element name="style:tab-stop">
  1299.                     <xsl:attribute name="style:position"><xsl:value-of select="(number(@w:pos)div 1440)*2.54"/>cm</xsl:attribute>
  1300.                     <xsl:choose>
  1301.                         <xsl:when test="@w:val = 'decimal'">
  1302.                             <xsl:attribute name="style:type">char</xsl:attribute>
  1303.                             <xsl:attribute name="style:char"> </xsl:attribute>
  1304.                         </xsl:when>
  1305.                         <xsl:otherwise>
  1306.                             <xsl:attribute name="style:type"><xsl:value-of select="@w:val"/></xsl:attribute>
  1307.                         </xsl:otherwise>
  1308.                     </xsl:choose>
  1309.                 </xsl:element>
  1310.             </xsl:for-each>
  1311.         </xsl:element>
  1312.     </xsl:if>
  1313.  
  1314.     
  1315. <!-- line spacing--> 
  1316.     <xsl:if test="descendant::w:spacing">
  1317.             <!--<xsl:attribute name="fo:line-height"><xsl:value-of select="number(((descendant::w:spacing/@w:line) div 1440)*2.54)"/>cm</xsl:attribute>-->
  1318.             <!--<w:spacing w:before="240" w:after="120"/>-->
  1319.             <xsl:choose>
  1320.                 <xsl:when test="descendant::w:spacing/@w:line-rule='at-least'">    
  1321.                     <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>
  1322.                 </xsl:when>
  1323.                 <xsl:when test="descendant::w:spacing/@w:line-rule='auto'">
  1324.                     <xsl:attribute name="fo:line-height"><xsl:value-of select="(number((descendant::w:spacing/@w:line) div 240) * 100)"/>%</xsl:attribute>
  1325.                 </xsl:when>
  1326.                 <xsl:when test="descendant::w:spacing/@w:line-rule='exact'">
  1327.                         <xsl:attribute name="fo:line-height"><xsl:value-of select="number(((descendant::w:spacing/@w:line) div 1440)*2.54)"/>cm</xsl:attribute>
  1328.                 </xsl:when>
  1329.             </xsl:choose>
  1330.             <xsl:if test="descendant::w:spacing/@w:before">
  1331.                     <xsl:attribute name="fo:margin-top"><xsl:value-of select="(number(descendant::w:spacing/@w:before) div 1440 )*2.54"/>cm</xsl:attribute>
  1332.             </xsl:if>
  1333.             <xsl:if test="descendant::w:spacing/@w:after">
  1334.                 <xsl:attribute name="fo:margin-bottom"><xsl:value-of select="(number(descendant::w:spacing/@w:after) div 1440 )*2.54"/>cm</xsl:attribute>
  1335.             </xsl:if>
  1336.     </xsl:if>        
  1337.  
  1338.     <xsl:attribute name="style:auto-text-indent">false</xsl:attribute>
  1339.     
  1340. </xsl:template>
  1341.  
  1342.  
  1343. <xsl:template name="bidi">
  1344.                     
  1345.     <!-- bi-directional support-->
  1346.     <xsl:if test="descendant::w:bidi">
  1347.         <xsl:attribute name="style:writing-mode">rl-tb</xsl:attribute>
  1348.         <xsl:attribute name="fo:text-align">end</xsl:attribute>
  1349.     </xsl:if>
  1350.  
  1351. <xsl:choose>    
  1352.         <xsl:when test="descendant::w:jc[@w:val = 'center']">
  1353.             <xsl:attribute name="fo:text-align">center</xsl:attribute>
  1354.         </xsl:when>        
  1355.         <xsl:when test="descendant::w:jc[@w:val = 'left']">
  1356.             <xsl:choose>
  1357.                 <xsl:when test="descendant::w:bidi">
  1358.                     <xsl:attribute name="fo:text-align">end</xsl:attribute>
  1359.                 </xsl:when>
  1360.                 <xsl:otherwise>
  1361.                     <xsl:attribute name="fo:text-align">start</xsl:attribute>
  1362.                 </xsl:otherwise>
  1363.             </xsl:choose>
  1364.         </xsl:when>        
  1365.         <xsl:when test="descendant::w:jc[@w:val = 'right']">
  1366.             <xsl:choose>
  1367.                 <xsl:when test="descendant::w:bidi">
  1368.                     <xsl:attribute name="fo:text-align">start</xsl:attribute>
  1369.                 </xsl:when>
  1370.                 <xsl:otherwise>
  1371.                         <xsl:attribute name="fo:text-align">end</xsl:attribute>
  1372.                 </xsl:otherwise>
  1373.             </xsl:choose>
  1374.         </xsl:when>
  1375.         <xsl:when test="descendant::w:jc[@w:val = 'both']">
  1376.             <xsl:attribute name="fo:text-align">justify</xsl:attribute>
  1377.             <xsl:attribute name="style:justify-single-word">false</xsl:attribute>
  1378.         </xsl:when>
  1379.     </xsl:choose>    
  1380. </xsl:template>
  1381.  
  1382.  
  1383.  
  1384. <xsl:template name="list-styles-common">
  1385.     <xsl:param name="listtype"/>
  1386.     <xsl:param name="rootlist"/>
  1387.     <xsl:param name="currlist"/>
  1388.     <xsl:variable name="currlevel" select="number(@w:ilvl)"/>
  1389.     <xsl:variable name="startval" select="child::w:start/@w:val"/>
  1390.     <xsl:variable name="outline" select="substring-after(child::w:lvlText/@w:val, '%')"/>
  1391.     <xsl:attribute name="text:level"><xsl:value-of select="$currlevel+1"/></xsl:attribute>
  1392.     <xsl:attribute name="text:min-label-width">0.499cm</xsl:attribute>
  1393.         <xsl:choose>
  1394.             <xsl:when test="$listtype = 23">
  1395.                 <xsl:attribute name="text:style-name">
  1396.                     <xsl:text>Bullet Symbols</xsl:text>
  1397.                 </xsl:attribute>
  1398.                 <!--<xsl:attribute name="style:num-format"><xsl:value-of select="child::wx:t/@wx:val"/></xsl:attribute>-->
  1399.                 <!--<xsl:attribute name="text:bullet-char"><xsl:value-of select="$currlist/child::wx:t/@wx:val"/></xsl:attribute>-->
  1400.                 <xsl:attribute name="text:bullet-char"><xsl:value-of select="child::w:lvlText/@w:val"/></xsl:attribute>
  1401.                 <!-- Font to be used is set further down-->
  1402.                 <!--<xsl:choose>
  1403.                     <xsl:when test="$currlist/child::wx:t/@wx:val = '┬╖' ">
  1404.                         <xsl:attribute name="text:bullet-char">ΓùÅ</xsl:attribute>
  1405.                     </xsl:when>
  1406.                     <xsl:otherwise>
  1407.                         <xsl:attribute name="text:bullet-char"><xsl:value-of select="$currlist/child::wx:t/@wx:val"/></xsl:attribute>
  1408.                     </xsl:otherwise>
  1409.                 </xsl:choose>-->
  1410.                 
  1411.             </xsl:when>
  1412.             <xsl:when test="($listtype > 0) and ($listtype < 6)">
  1413.                 <xsl:if test="$startval">
  1414.                     <xsl:attribute name="text:start-value"><xsl:value-of select="$startval"/></xsl:attribute>
  1415.                 </xsl:if>
  1416.                 <xsl:if test="contains($outline,'%')">
  1417.                     <xsl:call-template name="displaylevels">
  1418.                         <xsl:with-param name="displaylevelsvalue"><xsl:value-of select="number(2)"/></xsl:with-param>
  1419.                         <xsl:with-param name="displaylevelsstring" select="$outline"/>
  1420.                     </xsl:call-template>
  1421.                 </xsl:if>
  1422.                 <xsl:attribute name="text:style-name">
  1423.                     <xsl:text>Numbering Symbols</xsl:text>
  1424.                 </xsl:attribute>
  1425.                 <xsl:attribute name="style:num-format">
  1426.                     <!--<xsl:value-of select="child::wx:t/@wx:val"/>-->
  1427.                     <xsl:choose>
  1428.                         <xsl:when test="$listtype = 1">I</xsl:when>
  1429.                         <xsl:when test="$listtype = 2">i</xsl:when>
  1430.                         <xsl:when test="$listtype = 3">A</xsl:when>
  1431.                         <xsl:when test="$listtype = 4">a</xsl:when>
  1432.                         <xsl:when test="$listtype = 5">1</xsl:when>
  1433.                     </xsl:choose>
  1434.                 </xsl:attribute>    
  1435.  
  1436.             </xsl:when>
  1437.             <xsl:otherwise>
  1438.                 <xsl:if test="$startval">
  1439.                     <xsl:attribute name="text:start-value"><xsl:value-of select="$startval"/></xsl:attribute>
  1440.                 </xsl:if>
  1441.                 <xsl:if test="contains($outline,'%')">
  1442.                     <xsl:call-template name="displaylevels">
  1443.                         <xsl:with-param name="displaylevelsvalue"><xsl:value-of select="number(2)"/></xsl:with-param>
  1444.                         <xsl:with-param name="displaylevelsstring" select="$outline"/>
  1445.                     </xsl:call-template>
  1446.                 </xsl:if>
  1447.                 <xsl:attribute name="text:style-name">
  1448.                     <xsl:text>Numbering Symbols</xsl:text>
  1449.                 </xsl:attribute>
  1450.                 <xsl:attribute name="style:num-format">1</xsl:attribute>    
  1451.             </xsl:otherwise>
  1452.         </xsl:choose>
  1453.             
  1454.         <xsl:attribute name="style:num-suffix">.</xsl:attribute>
  1455.         <!--<xsl:value-of select="$currlevel"/>-->
  1456.         <xsl:element name="style:properties"> 
  1457.             <!-- Find the node that corresponds to the level being processed. We can use this to determine the indentation to be used-->
  1458.             <xsl:variable name="currNode" select="/descendant::w:listPr[child::w:ilvl/@w:val = $currlevel][child::w:ilfo/@w:val = $currlist/w:ilfo/@w:val]"/>
  1459.             <xsl:choose>
  1460.                 <xsl:when test="$currNode/wx:t/@wx:wTabBefore and $currNode/wx:t/@wx:wTabAfter ">
  1461.                     <xsl:attribute name="text:space-before"><xsl:value-of select="((number($currNode/wx:t/@wx:wTabBefore) div 1440)*2.54)"/>cm</xsl:attribute>
  1462.                     <xsl:attribute name="text:min-label-distance"><xsl:value-of select="(number($currlist/wx:t/@wx:wTabAfter) div 1440)*2.54"/>cm</xsl:attribute>
  1463.                 </xsl:when>
  1464.                 <xsl:otherwise>
  1465.                     <xsl:attribute name="text:space-before"><xsl:value-of select="((number(child::w:pPr/w:ind/@w:left)  div 1440)*2.54) "/>cm</xsl:attribute>                                <xsl:attribute name="text:min-label-distance"><xsl:value-of select="(number($currlist/wx:t/@wx:wTabAfter) div 1440)*2.54"/>cm</xsl:attribute>
  1466.                 </xsl:otherwise>
  1467.             </xsl:choose>
  1468.             <xsl:if test="descendant::w:rFonts/@w:ascii">
  1469.                 <!--<xsl:attribute name="style:font-name"><xsl:value-of select="$currlist/wx:font/@wx:val"/></xsl:attribute>-->
  1470.                 <xsl:attribute name="style:font-name"><xsl:value-of select="descendant::w:rFonts/@w:ascii"/></xsl:attribute>
  1471.             </xsl:if>
  1472.         </xsl:element>
  1473. </xsl:template>
  1474.  
  1475.  
  1476. <xsl:template name="displaylevels">
  1477.     <xsl:param name="displaylevelsvalue"/>
  1478.     <xsl:param name="displaylevelsstring"/>
  1479.     <xsl:attribute name="text:display-levels"><xsl:value-of select="$displaylevelsvalue"/></xsl:attribute>
  1480.     <xsl:variable name="outline" select="substring-after($displaylevelsstring, '%')"/>
  1481.                 <xsl:if test="contains($outline,'%')">
  1482.                     <xsl:call-template name="displaylevels">
  1483.                         <xsl:with-param name="displaylevelsvalue"><xsl:value-of select="number($displaylevelsvalue +1)"/></xsl:with-param>
  1484.                         <xsl:with-param name="displaylevelsstring" select="$outline"/>
  1485.                     </xsl:call-template>
  1486.                 </xsl:if>
  1487. </xsl:template>
  1488.  
  1489. <xsl:template match="w:style">
  1490.    <xsl:element name="style:style">
  1491.            <xsl:attribute name="style:name"><xsl:value-of select="@w:styleId"/></xsl:attribute>
  1492.            <xsl:if test="child::w:basedOn">
  1493.                <xsl:attribute name="style:parent-style-name"><xsl:value-of select="child::w:basedOn/@w:val"/></xsl:attribute>
  1494.            </xsl:if>
  1495.            <xsl:if test="child::w:next">
  1496.                <xsl:attribute name="style:next-style-name"><xsl:value-of select="child::w:next/@w:val"/></xsl:attribute>
  1497.            </xsl:if>
  1498.            <!--<xsl:attribute name="style:class"></xsl:attribute>-->
  1499.            <xsl:choose>
  1500.                <xsl:when test="@w:type">
  1501.                        <xsl:choose>
  1502.                         <xsl:when test="@w:type = 'character' ">
  1503.                             <xsl:attribute name="style:family">text</xsl:attribute>
  1504.                         </xsl:when>
  1505.                         <xsl:when test="@w:type = 'list' ">
  1506.                             <xsl:attribute name="style:family">text</xsl:attribute>
  1507.                         </xsl:when>
  1508.                         <xsl:otherwise>
  1509.                             <xsl:attribute name="style:family"><xsl:value-of select="@w:type"/></xsl:attribute>
  1510.                         </xsl:otherwise>
  1511.                     </xsl:choose>
  1512.                </xsl:when>
  1513.                <xsl:when test="ancestor::w:pPr">
  1514.                    <xsl:attribute name="style:family">paragraph</xsl:attribute>
  1515.                </xsl:when>
  1516.                <xsl:otherwise>
  1517.                    <xsl:attribute name="style:family">text</xsl:attribute>
  1518.                </xsl:otherwise>        
  1519.         </xsl:choose>
  1520.         <xsl:element name="style:properties">
  1521.             <xsl:call-template name="paragraph-alignment"/>
  1522.                <xsl:apply-templates select="child::w:rPr/*"/>
  1523.                <xsl:apply-templates select="child::w:pPr/*"/>
  1524.            </xsl:element>
  1525.            <xsl:apply-templates/>
  1526.     </xsl:element>
  1527. </xsl:template>
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533. <!-- 
  1534.     Graphics Handling 
  1535.  
  1536. -->
  1537.  
  1538.  
  1539. <xsl:template match="w:pict">
  1540. <!--    <draw:image draw:style-name="fr1" draw:name="Graphic2" text:anchor-type="paragraph" svg:width="2.1965inch" svg:height="0.7402inch" draw:z-index="0">-->
  1541. <!-- <v:shape id="_x0000_i1026" type="#_x0000_t75" style="width:158.25pt;height:53.25pt">
  1542.                             <v:imagedata src="http://01000002.gif" o:title="logonew"/>
  1543.                         </v:shape>
  1544. -->
  1545.  
  1546.     <!-- Cannot load zipped Wmf file-->
  1547.     <xsl:choose>
  1548.         <xsl:when test="descendant::w:binData">
  1549.             <xsl:if test="not(contains(child::w:binData/@w:name,'.wmz'))">   
  1550.                 <xsl:element name="draw:image">
  1551.                      <xsl:if test="child::v:shape/@style">
  1552.                          <xsl:variable name="widthandheight" select="child::v:shape/@style"/>
  1553.                          <xsl:variable name="widthstr" select="substring-before($widthandheight,';')"/>
  1554.                          <xsl:variable name="heightstr" select="substring-after($widthandheight,';')"/>
  1555.                          <xsl:variable name="widthpt" select="substring-after($widthstr,':')"/>
  1556.                          <xsl:variable name="heightpt" select="substring-after($heightstr,':')"/>
  1557.                          <xsl:variable name="width" select="substring-before($widthpt,'pt')"/>
  1558.                          <xsl:variable name="height" select="substring-before($heightpt,'pt')"/>
  1559.                          <xsl:variable name="widthcm" select="number($width)*0.0353"/>
  1560.                          <xsl:variable name="heightcm" select="number($height)*0.0353"/>
  1561.                          <!--<xsl:value-of select="$widthcm"/><xsl:text>cm</xsl:text><xsl:value-of select="$heightcm"/> -->
  1562.                          <xsl:attribute name="svg:width"><xsl:value-of select="$widthcm"/><xsl:text>cm</xsl:text></xsl:attribute>
  1563.                          <xsl:attribute name="svg:height"><xsl:value-of select="$heightcm"/><xsl:text>cm</xsl:text></xsl:attribute>
  1564.                          <xsl:attribute name="text:anchor-type">paragraph</xsl:attribute>
  1565.                          <xsl:if test="child::v:shape/v:imagedata/@o:title">
  1566.                              <xsl:attribute name="draw:name"><xsl:value-of select="child::v:shape/v:imagedata/@o:title"/></xsl:attribute>
  1567.                          </xsl:if>
  1568.                          <xsl:apply-templates/>
  1569.                      </xsl:if>
  1570.                 </xsl:element>
  1571.             </xsl:if>
  1572.         </xsl:when>
  1573.         <xsl:otherwise>
  1574.             <xsl:apply-templates/>
  1575.         </xsl:otherwise>
  1576.     </xsl:choose>
  1577.     
  1578. </xsl:template>
  1579.  
  1580. <xsl:template match="w:binData">
  1581. <!--office:binary-data-->
  1582.     <xsl:element name="office:binary-data">
  1583.         <xsl:value-of select="."/>
  1584.     </xsl:element>
  1585. </xsl:template>
  1586.  
  1587. <xsl:template match="v:group">
  1588.     <xsl:apply-templates/>
  1589. </xsl:template>
  1590.  
  1591.  
  1592. <!--     <v:oval id="_x0000_s1030" style="position:absolute;left:3352;top:2911;width:1975;height:1863" fillcolor="red"/>
  1593.        <v:rect id="_x0000_s1031" style="position:absolute;left:3952;top:3074;width:2838;height:1912" fillcolor="yellow" strokecolor="blue"/>
  1594.  
  1595. <draw:rect text:anchor-type="paragraph" draw:z-index="1" draw:style-name="gr1" draw:text-style-name="P1" svg:width="2.0634inch" svg:height="1.1362inch" svg:x="0.5953inch" svg:y="0.222inch"/>
  1596.             <draw:ellipse text:anchor-type="paragraph" draw:z-index="2" draw:style-name="gr1" draw:text-style-name="P1" svg:width="1.9382inch" svg:height="1.0425inch" svg:x="1.2098inch" svg:y="0.4827inch" draw:kind="section" draw:start-angle="338.51" draw:end-angle="241.21"/>
  1597.  
  1598. -->
  1599. <xsl:template match="v:oval">
  1600.     <xsl:element name="draw:ellipse">
  1601.              <xsl:variable name="style" select="@style"/>
  1602.              <xsl:variable name="position" select="substring-after($style,'position:')"/>
  1603.              <xsl:variable name="positionval" select="substring-before($position,';')"/>
  1604.              <xsl:variable name="left" select="substring-after($style,'left:')"/>
  1605.              <xsl:variable name="leftval" select="substring-before($left,';')"/>
  1606.              <xsl:variable name="top" select="substring-after($style,'top:')"/>
  1607.              <xsl:variable name="topval" select="substring-before($top,';')"/>
  1608.              <xsl:variable name="width" select="substring-after($style,'width:')"/>
  1609.              <xsl:variable name="widthval" select="substring-before($width,';')"/>
  1610.              <xsl:variable name="height" select="substring-after($style,'height:')"/>
  1611.              <xsl:variable name="heightval" select="$height"/>
  1612.              <!--<xsl:if test="parent::v:group">
  1613.              
  1614.             <xsl:variable name="parentgroup" select="parent::v:group"/>
  1615.             <xsl:variable name="origin" select="$coordorigin"/>
  1616.             <xsl:variable name="groupleft" select="substring-before($origin,',')"/>
  1617.             <xsl:variable name="grouptop" select="substring-after($origin,',')"/>
  1618.              </xsl:if>         -->    
  1619.              <xsl:if test="$positionval = 'absolute'">
  1620.                  <xsl:variable name="parentgroup" select="parent::v:group"/>
  1621.             <xsl:variable name="origin" select="$parentgroup/@coordorigin"/>
  1622.             <xsl:variable name="groupleft" select="substring-before($origin,',')"/>
  1623.             <xsl:variable name="grouptop" select="substring-after($origin,',')"/>
  1624.  
  1625.             <xsl:variable name="currsect" select="ancestor::wx:sect"/>
  1626.             <xsl:variable name="currsectPr" select="$currsect/descendant::w:sectPr/w:pgMar"/>
  1627.             <xsl:variable name="leftmar" select="$currsectPr/@w:left"/>
  1628.             <xsl:variable name="topmar" select="$currsectPr/@w:top"/>
  1629.  
  1630.                  <!--<xsl:attribute name="text:anchor-type">page</xsl:attribute>-->
  1631.                  <xsl:attribute name="text:anchor-type">page</xsl:attribute>
  1632.                  <xsl:attribute name="svg:width"><xsl:value-of select="(number($widthval) div 1440)*2.54"/>cm</xsl:attribute>
  1633.                  
  1634.                  <xsl:attribute name="svg:height"><xsl:value-of select="(number($heightval) div 1440)*2.54"/>cm</xsl:attribute>
  1635.                  <xsl:attribute name="svg:x"><xsl:value-of select="(number($topval + $topmar) div 1440)*2.54"/>cm</xsl:attribute>
  1636.                  <xsl:attribute name="svg:y"><xsl:value-of select="(number($leftval + $leftmar) div 1440)*2.54"/>cm</xsl:attribute>
  1637.                  <!--<xsl:attribute name="svg:y"><xsl:value-of select="((number($leftval + $leftmar) -$widthval) div 1440)*2.54"/>cm</xsl:attribute>-->
  1638.              </xsl:if>
  1639.     </xsl:element>
  1640. </xsl:template>
  1641.  
  1642. <xsl:template match="v:rect">
  1643.     <xsl:element name="draw:rect">
  1644.              <xsl:variable name="style" select="@style"/>
  1645.              <xsl:variable name="position" select="substring-after($style,'position:')"/>
  1646.              <xsl:variable name="positionval" select="substring-before($position,';')"/>
  1647.              <xsl:variable name="left" select="substring-after($style,'left:')"/>
  1648.              <xsl:variable name="leftval" select="substring-before($left,';')"/>
  1649.              <xsl:variable name="top" select="substring-after($style,'top:')"/>
  1650.              <xsl:variable name="topval" select="substring-before($top,';')"/>
  1651.              <xsl:variable name="width" select="substring-after($style,'width:')"/>
  1652.              <xsl:variable name="widthval" select="substring-before($width,';')"/>
  1653.              <xsl:variable name="height" select="substring-after($style,'height:')"/>
  1654.              <xsl:variable name="heightval" select="$height"/>
  1655.              <xsl:if test="$positionval = 'absolute'">
  1656.                  <xsl:variable name="parentgroup" select="parent::v:group"/>
  1657.             <xsl:variable name="origin" select="$parentgroup/@coordorigin"/>
  1658.             <xsl:variable name="groupleft" select="substring-before($origin,',')"/>
  1659.             <xsl:variable name="grouptop" select="substring-after($origin,',')"/>
  1660.  
  1661.                  <xsl:variable name="currsect" select="ancestor::wx:sect"/>
  1662.             <xsl:variable name="currsectPr" select="$currsect/descendant::w:sectPr/w:pgMar"/>
  1663.             <xsl:variable name="leftmar" select="$currsectPr/@w:left"/>
  1664.             <xsl:variable name="topmar" select="$currsectPr/@w:top"/>
  1665.  
  1666.                  <!--<xsl:attribute name="text:anchor-type">page</xsl:attribute>-->
  1667.                   <xsl:attribute name="text:anchor-type">page</xsl:attribute>
  1668.                  <xsl:attribute name="svg:width"><xsl:value-of select="(number($widthval) div 1440)*2.54"/>cm</xsl:attribute>
  1669.                  
  1670.                  <xsl:attribute name="svg:height"><xsl:value-of select="(number($heightval) div 1440)*2.54"/>cm</xsl:attribute>
  1671.                  <xsl:attribute name="svg:x"><xsl:value-of select="(number($topval + $topmar) div 1440)*2.54"/>cm</xsl:attribute>
  1672.                  <xsl:attribute name="svg:y"><xsl:value-of select="(number($leftval + $leftmar) div 1440)*2.54"/>cm</xsl:attribute>
  1673.                  <!--<xsl:attribute name="svg:y"><xsl:value-of select="((number($leftval + $leftmar) -$widthval) div 1440)*2.54"/>cm</xsl:attribute>-->
  1674.               </xsl:if>
  1675.     </xsl:element>
  1676. </xsl:template>
  1677.  
  1678.  
  1679.  
  1680.  
  1681. <!-- 
  1682.     tables Handling 
  1683.  
  1684. -->
  1685.  
  1686.  
  1687. <xsl:template match="w:tbl">
  1688.     <xsl:element name="table:table">
  1689.         <!--<xsl:if test="child::w:tblPr/w:tblStyle">
  1690.             <xsl:attribute name="table:style-name"><xsl:value-of select="child::w:tblPr/w:tblStyle/@w:val"/></xsl:attribute>
  1691.         </xsl:if>-->
  1692.         <xsl:apply-templates select="./*"/>
  1693.     </xsl:element>
  1694. </xsl:template>
  1695.  
  1696.  
  1697. <xsl:template match="w:tblPr">
  1698.     <xsl:attribute name="table:style-name">TTable<xsl:value-of select="count(preceding::w:tblPr)"/></xsl:attribute>
  1699. </xsl:template>
  1700.  
  1701.  
  1702. <xsl:template match="w:tblGrid">
  1703.         <!--<xsl:attribute name="table:number-columns-repeated">
  1704.             <xsl:value-of select="count(child::w:gridCol)"/>
  1705.         </xsl:attribute>-->
  1706.     <xsl:apply-templates/>
  1707. </xsl:template>
  1708.  
  1709. <xsl:template match="w:gridCol">
  1710.     <xsl:element name="table:table-column">
  1711.         <xsl:attribute name="table:style-name">TColumn<xsl:value-of select="count(preceding::w:gridCol)"/></xsl:attribute>
  1712.     </xsl:element>
  1713. </xsl:template>
  1714.  
  1715. <!--<w:tblGrid>
  1716.         <w:gridCol w:w="1771"/>
  1717.         <w:gridCol w:w="1771"/>
  1718.         <w:gridCol w:w="1771"/>
  1719.         <w:gridCol w:w="1771"/>
  1720.         <w:gridCol w:w="1772"/>
  1721.         </w:tblGrid>
  1722. -->
  1723.  
  1724. <xsl:template match="w:tr">
  1725.     <xsl:element name="table:table-row">
  1726.         <xsl:apply-templates/>
  1727.     </xsl:element>
  1728. </xsl:template>
  1729.  
  1730. <xsl:template match="w:tc">
  1731.     <xsl:element name="table:table-cell">
  1732.         <xsl:attribute name="table:style-name">TCell<xsl:value-of select="count(preceding::w:tcPr)"/></xsl:attribute>
  1733.         <xsl:if test="child::w:tcPr/w:gridSpan">
  1734.             <xsl:attribute name="table:number-columns-spanned"><xsl:value-of select="child::w:tcPr/w:gridSpan/@w:val"/></xsl:attribute>
  1735.         </xsl:if>
  1736.         <xsl:apply-templates/>
  1737.     </xsl:element>
  1738. </xsl:template>
  1739.  
  1740.  
  1741. <xsl:template match="w:tcBorders">
  1742.     <xsl:apply-templates/>
  1743. </xsl:template>
  1744.  
  1745. <xsl:template match="w:top">
  1746.         <xsl:choose>
  1747.         <xsl:when test="@w:val='nil' ">
  1748.             <xsl:attribute name="fo:border-top">none</xsl:attribute>
  1749.         </xsl:when>        
  1750.         <xsl:when test="@wx:bdrwidth and @w:color">
  1751.                 <xsl:attribute name="fo:border-top"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/><xsl:text>cm </xsl:text>
  1752.                 <!--<xsl:attribute name="fo:border-top"><xsl:value-of select="(number(@wx:bdrwidth) div 240 )*100"/><xsl:text>cm </xsl:text>-->
  1753.                 <xsl:choose>
  1754.                     <xsl:when test="@w:color ='auto'">
  1755.                         <xsl:text>solid #000000</xsl:text>
  1756.                     </xsl:when>
  1757.                     <xsl:otherwise>
  1758.                         <xsl:text>solid #</xsl:text><xsl:value-of select="@w:color"/>
  1759.                     </xsl:otherwise>
  1760.                 </xsl:choose>
  1761.                 </xsl:attribute>
  1762.         </xsl:when>
  1763.         <xsl:otherwise>
  1764.             <xsl:if test="@wx:bdrwidth">
  1765.                 <xsl:attribute name="fo:border-top"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/>cm</xsl:attribute>
  1766.                 <!--<xsl:attribute name="fo:border-top"><xsl:value-of select="(number(@wx:bdrwidth) div 240 )*100"/>cm</xsl:attribute>-->
  1767.             </xsl:if>
  1768.         </xsl:otherwise>
  1769.     </xsl:choose>    
  1770. </xsl:template>
  1771.  
  1772. <xsl:template match="w:bottom">
  1773.     <xsl:choose>
  1774.         <xsl:when test="@w:val='nil' ">
  1775.             <xsl:attribute name="fo:border-bottom">none</xsl:attribute>
  1776.         </xsl:when>
  1777.         <xsl:when test="@wx:bdrwidth and @w:color">
  1778.                 <xsl:attribute name="fo:border-bottom"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/><xsl:text>cm </xsl:text>
  1779.                 <!--<xsl:attribute name="fo:border-bottom"><xsl:value-of select="(number(@wx:bdrwidth) div 240 )*100"/><xsl:text>cm </xsl:text>-->
  1780.                 <xsl:choose>
  1781.                     <xsl:when test="@w:color ='auto'">
  1782.                         <xsl:text>solid #000000</xsl:text>
  1783.                     </xsl:when>
  1784.                     <xsl:otherwise>
  1785.                         <xsl:text>solid #</xsl:text><xsl:value-of select="@w:color"/>
  1786.                     </xsl:otherwise>
  1787.                 </xsl:choose>
  1788.                 </xsl:attribute>
  1789.         </xsl:when>
  1790.  
  1791.         <xsl:otherwise>
  1792.             <xsl:if test="@wx:bdrwidth">
  1793.                 <xsl:attribute name="fo:border-bottom"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/>cm</xsl:attribute>
  1794.                 <!--<xsl:attribute name="fo:border-bottom"><xsl:value-of select="(number(@wx:bdrwidth) div 240 )*100"/>cm</xsl:attribute>-->
  1795.             </xsl:if>
  1796.         </xsl:otherwise>
  1797.     </xsl:choose>        
  1798. </xsl:template>
  1799.  
  1800. <xsl:template match="w:left">
  1801.     <xsl:choose>
  1802.         <xsl:when test="@w:val='nil' ">
  1803.             <xsl:attribute name="fo:border-left">none</xsl:attribute>
  1804.         </xsl:when>
  1805.         <xsl:when test="@wx:bdrwidth and @w:color">
  1806.                 <xsl:attribute name="fo:border-left"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/><xsl:text>cm </xsl:text>
  1807.                 <!--<xsl:attribute name="fo:border-right"><xsl:value-of select="(number(@wx:bdrwidth) div 240 )*100"/><xsl:text>cm </xsl:text>-->
  1808.                 <xsl:choose>
  1809.                     <xsl:when test="@w:color ='auto'">
  1810.                         <xsl:text>solid #000000</xsl:text>
  1811.                     </xsl:when>
  1812.                     <xsl:otherwise>
  1813.                         <xsl:text>solid #</xsl:text><xsl:value-of select="@w:color"/>
  1814.                     </xsl:otherwise>
  1815.                 </xsl:choose>
  1816.                 </xsl:attribute>
  1817.         </xsl:when>
  1818.  
  1819.         <xsl:otherwise>
  1820.             <xsl:if test="@wx:bdrwidth">
  1821.                 <xsl:attribute name="fo:border-left"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/>cm</xsl:attribute>
  1822.                     <!--<xsl:attribute name="fo:border-left"><xsl:value-of select="(number(@wx:bdrwidth) div 240 )*100"/>cm</xsl:attribute>-->
  1823.             </xsl:if>
  1824.         </xsl:otherwise>
  1825.     </xsl:choose>    
  1826. </xsl:template>
  1827.  
  1828. <xsl:template match="w:right">
  1829.     <xsl:choose>
  1830.         <xsl:when test="@w:val='nil' ">
  1831.             <xsl:attribute name="fo:border-right">none</xsl:attribute>
  1832.         </xsl:when>
  1833.         <xsl:when test="@wx:bdrwidth and @w:color">
  1834.                 <xsl:attribute name="fo:border-right"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/><xsl:text>cm </xsl:text>
  1835.                 <!--<xsl:attribute name="fo:border-right"><xsl:value-of select="(number(@wx:bdrwidth) div 240 )*100"/><xsl:text>cm </xsl:text>-->
  1836.                 <xsl:choose>
  1837.                     <xsl:when test="@w:color ='auto'">
  1838.                         <xsl:text>solid #000000</xsl:text>
  1839.                     </xsl:when>
  1840.                     <xsl:otherwise>
  1841.                         <xsl:text>solid #</xsl:text><xsl:value-of select="@w:color"/>
  1842.                     </xsl:otherwise>
  1843.                 </xsl:choose>
  1844.                 </xsl:attribute>
  1845.         </xsl:when>
  1846.         <xsl:otherwise>
  1847.             <xsl:if test="@wx:bdrwidth">
  1848.                 <xsl:attribute name="fo:border-right"><xsl:value-of select="(number(@wx:bdrwidth) div 1440 )*2.54"/>cm</xsl:attribute>
  1849.                 <!--<xsl:attribute name="fo:border-right"><xsl:value-of select="(number(@wx:bdrwidth) div 240 )*100"/>cm</xsl:attribute>-->
  1850.             </xsl:if>
  1851.         </xsl:otherwise>
  1852.     </xsl:choose>    
  1853. </xsl:template>
  1854.  
  1855.  
  1856. <xsl:template match="w:tblBorders">
  1857.     <xsl:apply-templates/>
  1858. </xsl:template>
  1859.  
  1860. <xsl:template match="w:tcBorders">
  1861.     <xsl:apply-templates/>
  1862. </xsl:template>
  1863.  
  1864.  
  1865. <xsl:template match="w:tblInd">
  1866.     <xsl:attribute name="fo:margin-left"><xsl:value-of select="(number(@w:w) div 1440)*2.54"/>cm</xsl:attribute>
  1867. </xsl:template>
  1868.  
  1869. <!-- Table borders
  1870.  
  1871.  <style:properties fo:vertical-align="top" fo:padding-left="0.191cm" fo:padding-right="0.191cm" fo:padding-top="0cm" fo:padding-bottom="0cm" fo:border-left="0.088cm solid #000000" fo:border-right="none" fo:border-top="0.088cm solid #000000" fo:border-bottom="0.088cm solid #000000"/>
  1872.  
  1873. <w:tblPr>
  1874.                     <w:tblStyle w:val="TableGrid"/>
  1875.                     <w:tblW w:w="0" w:type="auto"/>
  1876.                     <w:tblInd w:w="567" w:type="dxa"/>
  1877.                     <w:tblBorders>
  1878.                         <w:top w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  1879.                         <w:left w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  1880.                         <w:bottom w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  1881.                         <w:right w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  1882.                         <w:insideH w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  1883.                         <w:insideV w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="auto"/>
  1884.                     </w:tblBorders>
  1885.                     <w:tblLook w:val="000001E0"/>
  1886.                 </w:tblPr>
  1887.  
  1888.  
  1889. -->
  1890.  
  1891.  
  1892. <!-- <style:style style:name="Tabelle7.B1" style:family="table-cell">
  1893.             <style:properties fo:vertical-align="top" fo:padding-left="0.191cm" fo:padding-right="0.191cm" fo:padding-top="0cm" fo:padding-bottom="0cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/>
  1894.         </style:style>
  1895.  
  1896.     <w:tcPr>
  1897.                             <w:tcW w:w="1771" w:type="dxa"/>
  1898.                             <w:tcBorders>
  1899.                                 <w:top w:val="nil"/>
  1900.                                 <w:right w:val="nil"/>
  1901.                             </w:tcBorders>
  1902.  
  1903.  
  1904. -->
  1905.  
  1906. <!--<xsl:template match="w:gridSpan">
  1907.     <xsl:attribute name=""></xsl:attribute>
  1908.     <xsl:apply-templates/>
  1909. </xsl:template>-->
  1910.  
  1911. <!--Table, Cell and Row Properties  -->
  1912.  
  1913. <xsl:template match="w:tcPr">
  1914. </xsl:template>
  1915.  
  1916. <!--<style:properties style:width="10.008cm" fo:margin-left="3.791cm" fo:margin-right="3.791cm" table:align="margins"/>-->
  1917.  
  1918.  
  1919.  
  1920.  
  1921. <!-- 
  1922.     list Handling 
  1923.  
  1924. -->
  1925.  
  1926. <xsl:template name="genlist">
  1927.     <xsl:variable name="currlistid" select="child::w:pPr/w:listPr/w:ilfo/@w:val"/>
  1928.     <xsl:variable name="prevPara" select="preceding-sibling::w:p"/>
  1929.     <xsl:variable name="followingPara" select="following-sibling::w:p"/>
  1930.     <xsl:variable name="prevlistid" select="$prevPara/child::w:pPr/w:listPr/w:ilfo/@w:val"/>
  1931.     <xsl:variable name="currlistlvl" select="child::w:pPr/w:listPr/w:ilvl/@w:val"/>
  1932.       <xsl:variable name="firstoccur" select="/descendant::w:pPr[w:listPr/w:ilfo/@w:val = $currlistid][1]"/>
  1933.     <xsl:element name="text:ordered-list">
  1934.         <xsl:attribute name="text:style-name">TList<xsl:value-of select="count($firstoccur/preceding::w:listPr)"/></xsl:attribute>   
  1935.     <xsl:choose>
  1936.         <xsl:when test="preceding::w:pPr/w:listPr/w:ilfo/@w:val = child::w:pPr/w:listPr/w:ilfo/@w:val">
  1937.             <xsl:attribute name="text:continue-numbering">true</xsl:attribute>        
  1938.             <xsl:element name="text:list-item">
  1939.                 <xsl:call-template name="levels"     ><xsl:with-param name="level" select="$currlistlvl"/></xsl:call-template>
  1940.             </xsl:element>
  1941.         </xsl:when>
  1942.         <xsl:otherwise>
  1943.             <xsl:element name="text:list-item">
  1944.                 <xsl:call-template name="levels" ><xsl:with-param name="level" select="$currlistlvl"/></xsl:call-template>
  1945.             </xsl:element>
  1946.         </xsl:otherwise>
  1947.     </xsl:choose>
  1948.     </xsl:element>
  1949. </xsl:template>
  1950.  
  1951. <xsl:template name="levels">
  1952.     <xsl:param name="level"/>
  1953.     <xsl:choose>
  1954.         <xsl:when test="$level = '0'">
  1955.             <xsl:call-template name="commonPara"/>
  1956.         </xsl:when>
  1957.         <xsl:otherwise>
  1958.             <xsl:element name="text:ordered-list">
  1959.                     <xsl:element name="text:list-item">
  1960.                         <xsl:call-template name="levels"     ><xsl:with-param name="level" select="$level -1"/></xsl:call-template>
  1961.                     </xsl:element>
  1962.             </xsl:element>
  1963.         </xsl:otherwise>
  1964.     </xsl:choose>
  1965. </xsl:template>
  1966.  
  1967.  
  1968. <!-- 
  1969.     Ms Field Handling
  1970. -->
  1971.  
  1972. <xsl:template match="w:instrText">
  1973. </xsl:template>
  1974.  
  1975. <xsl:template match="w:fldChar">
  1976. </xsl:template>
  1977.  
  1978.  
  1979. </xsl:stylesheet>
  1980.