home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 December / CHIP_CD_2004-12.iso / bonus / oo / OOo_1.1.3_ru_RU_infra_WinIntel_install.exe / $PLUGINSDIR / f_0391 / MsExcelXMLImport.xsl
Extensible Markup Language  |  2004-10-09  |  306KB  |  6,266 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  #  The Contents of this file are made available subject to the terms of
  4.  #  either of the following licenses
  5.  #
  6.  #         - GNU Lesser General Public License Version 2.1
  7.  #         - Sun Industry Standards Source License Version 1.1
  8.  #
  9.  #  Sun Microsystems Inc., October, 2000
  10.  #
  11.  #  GNU Lesser General Public License Version 2.1
  12.  #  =============================================
  13.  #  Copyright 2000 by Sun Microsystems, Inc.
  14.  #  901 San Antonio Road, Palo Alto, CA 94303, USA
  15.  #
  16.  #  This library is free software; you can redistribute it and/or
  17.  #  modify it under the terms of the GNU Lesser General Public
  18.  #  License version 2.1, as published by the Free Software Foundation.
  19.  #
  20.  #  This library is distributed in the hope that it will be useful,
  21.  #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22.  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  23.  #  Lesser General Public License for more details.
  24.  #
  25.  #  You should have received a copy of the GNU Lesser General Public
  26.  #  License along with this library; if not, write to the Free Software
  27.  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28.  #  MA  02111-1307  USA
  29.  #
  30.  #
  31.  #  Sun Industry Standards Source License Version 1.1
  32.  #  =================================================
  33.  #  The contents of this file are subject to the Sun Industry Standards
  34.  #  Source License Version 1.1 (the "License"); You may not use this file
  35.  #  except in compliance with the License. You may obtain a copy of the
  36.  #  License at http://www.openoffice.org/license.html.
  37.  #
  38.  #  Software provided under this License is provided on an "AS IS" basis,
  39.  #  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  40.  #  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  41.  #  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  42.  #  See the License for the specific provisions governing your rights and
  43.  #  obligations concerning the Software.
  44.  #
  45.  #  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  46.  #
  47.  #  Copyright: 2000 by Sun Microsystems, Inc.
  48.  #
  49.  #  All Rights Reserved.
  50.  #
  51.  #  Contributor(s): _______________________________________
  52.  #
  53.  #
  54.  -->
  55. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:SL="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:office="http://openoffice.org/2000/office" xmlns:table="http://openoffice.org/2000/table" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" office:class="spreadsheet" office:version="1.0" xmlns:meta="http://openoffice.org/2000/meta" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:config="http://openoffice.org/2001/config" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
  56.     <xsl:output indent="no" version="1.0" encoding="UTF-8" method="xml"/>
  57.     <xsl:template match="/">
  58.         <office:document xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" xmlns:script="http://openoffice.org/2000/script" xmlns:config="http://openoffice.org/2001/config" office:class="spreadsheet" office:version="1.0">
  59.             <xsl:apply-templates select="ss:Workbook/o:DocumentProperties"/>
  60.             <xsl:apply-templates select="ss:Workbook/x:ExcelWorkbook"/>
  61.             <xsl:call-template name="font-declaration"/>
  62.             <xsl:apply-templates select="ss:Workbook/ss:Styles"/>
  63.             <xsl:element name="office:body">
  64.                 <xsl:call-template name="set-calculation"/>
  65.                 <xsl:apply-templates select="ss:Workbook/ss:Worksheet"/>
  66.                 <xsl:call-template name="Names"/>
  67.                 <xsl:element name="table:database-ranges">
  68.                     <xsl:apply-templates select="ss:Workbook/ss:Worksheet/x:AutoFilter"/>
  69.                 </xsl:element>
  70.             </xsl:element>
  71.         </office:document>
  72.     </xsl:template>
  73.     <xsl:template match="o:DocumentProperties">
  74.         <office:meta>
  75.             <meta:generator>Microsoft Excel 2003</meta:generator>
  76.             <dc:title>
  77.                 <xsl:value-of select="o:Title"/>
  78.             </dc:title>
  79.             <dc:description>
  80.                 <xsl:value-of select="o:Description"/>
  81.             </dc:description>
  82.             <dc:subject>
  83.                 <xsl:value-of select="o:Subject"/>
  84.             </dc:subject>
  85.             <meta:initial-creator>
  86.                 <xsl:value-of select="o:Author"/>
  87.             </meta:initial-creator>
  88.             <meta:creation-date>
  89.                 <xsl:value-of select="substring-before( o:Created, 'Z')"/>
  90.             </meta:creation-date>
  91.             <dc:creator>
  92.                 <xsl:value-of select="o:LastAuthor"/>
  93.             </dc:creator>
  94.             <dc:date>
  95.                 <xsl:value-of select="substring-before( o:LastSaved, 'Z')"/>
  96.             </dc:date>
  97.             <meta:printed-by/>
  98.             <meta:print-date/>
  99.             <meta:keywords>
  100.                 <meta:keyword>
  101.                     <xsl:value-of select="o:Keywords"/>
  102.                 </meta:keyword>
  103.             </meta:keywords>
  104.             <dc:language/>
  105.             <meta:editing-cycles>
  106.                 <xsl:value-of select="o:Revision"/>
  107.             </meta:editing-cycles>
  108.             <meta:editing-duration>
  109.                 <xsl:if test="o:TotalTime">
  110.                     <xsl:value-of select="concat('PT', floor(o:TotalTime div 60), 'H', o:TotalTime mod 60, 'M0S')"/>
  111.                 </xsl:if>
  112.             </meta:editing-duration>
  113.             <meta:user-defined meta:name="Category">
  114.                 <xsl:value-of select="o:Category"/>
  115.             </meta:user-defined>
  116.             <meta:user-defined meta:name="Manager">
  117.                 <xsl:value-of select="o:Manager"/>
  118.             </meta:user-defined>
  119.             <meta:user-defined meta:name="Company">
  120.                 <xsl:value-of select="o:Company"/>
  121.             </meta:user-defined>
  122.             <meta:user-defined meta:name="Version">
  123.                 <xsl:value-of select="o:Version"/>
  124.             </meta:user-defined>
  125.             <meta:user-defined meta:name="HyperlinkBase">
  126.                 <xsl:value-of select="o:HyperlinkBase"/>
  127.             </meta:user-defined>
  128.             <xsl:apply-templates select="../o:CustomDocumentProperties"/>
  129.             <meta:document-statistic/>
  130.         </office:meta>
  131.     </xsl:template>
  132.     <xsl:template match="o:CustomDocumentProperties">
  133.         <xsl:for-each select="node()[@dt:dt]">
  134.             <meta:user-defined meta:name="{name()}">
  135.                 <xsl:value-of select="."/>
  136.             </meta:user-defined>
  137.         </xsl:for-each>
  138.     </xsl:template>
  139.     <xsl:template match="x:ExcelWorkbook">
  140.         <office:settings>
  141.             <config:config-item-set config:name="view-settings">
  142.                 <config:config-item config:name="VisibleAreaTop" config:type="int">
  143.                     <xsl:value-of select="x:WindowTopY"/>
  144.                 </config:config-item>
  145.                 <config:config-item config:name="VisibleAreaLeft" config:type="int">
  146.                     <xsl:value-of select="x:WindowTopX"/>
  147.                 </config:config-item>
  148.                 <config:config-item config:name="VisibleAreaWidth" config:type="int">
  149.                     <xsl:value-of select="x:WindowWidth"/>
  150.                 </config:config-item>
  151.                 <config:config-item config:name="VisibleAreaHeight" config:type="int">
  152.                     <xsl:value-of select="x:WindowHeight"/>
  153.                 </config:config-item>
  154.                 <xsl:variable name="ratio" select="15"/>
  155.                 <config:config-item-map-indexed config:name="Views">
  156.                     <config:config-item-map-entry>
  157.                         <config:config-item config:name="ViewId" config:type="string">View1</config:config-item>
  158.                         <config:config-item-map-named config:name="Tables">
  159.                             <!--  The panes of a table is like 3   |   1   or  3 |  1, or   3 , while 3 is the default one. glu
  160.                                                                                                                - - - -        - - -
  161.                                                                                                               2  |  0         2    -->
  162.                             <xsl:for-each select="../ss:Worksheet">
  163.                                 <config:config-item-map-entry config:name="{@ss:Name}">
  164.                                     <xsl:variable name="active-pane">
  165.                                         <xsl:choose>
  166.                                             <xsl:when test="x:WorksheetOptions/x:ActivePane">
  167.                                                 <xsl:value-of select="x:WorksheetOptions/x:ActivePane"/>
  168.                                             </xsl:when>
  169.                                             <xsl:otherwise/>
  170.                                         </xsl:choose>
  171.                                     </xsl:variable>
  172.                                     <xsl:if test="not( $active-pane = '' ) and ( x:WorksheetOptions/x:SplitVertical or x:WorksheetOptions/x:SplitHorizontal )">
  173.                                         <config:config-item config:name="ActiveSplitRange" config:type="short">
  174.                                             <xsl:choose>
  175.                                                 <xsl:when test="x:WorksheetOptions/x:SplitVertical and not(x:WorksheetOptions/x:SplitHorizontal)">
  176.                                                     <!-- wierd enough !! :( glu -->
  177.                                                     <xsl:value-of select="'3'"/>
  178.                                                 </xsl:when>
  179.                                                 <xsl:otherwise>
  180.                                                     <xsl:value-of select="$active-pane"/>
  181.                                                 </xsl:otherwise>
  182.                                             </xsl:choose>
  183.                                         </config:config-item>
  184.                                     </xsl:if>
  185.                                     <xsl:choose>
  186.                                         <xsl:when test="not( $active-pane = '')">
  187.                                             <config:config-item config:name="CursorPositionX" config:type="int">
  188.                                                 <xsl:value-of select="x:WorksheetOptions/x:Panes/x:Pane[x:Number = $active-pane ]/x:ActiveCol"/>
  189.                                             </config:config-item>
  190.                                             <config:config-item config:name="CursorPositionY" config:type="int">
  191.                                                 <xsl:value-of select="x:WorksheetOptions/x:Panes/x:Pane[x:Number = $active-pane ]/x:ActiveRow"/>
  192.                                             </config:config-item>
  193.                                         </xsl:when>
  194.                                         <xsl:otherwise>
  195.                                             <config:config-item config:name="CursorPositionX" config:type="int">
  196.                                                 <xsl:value-of select="x:WorksheetOptions/x:Panes/x:Pane/x:ActiveCol"/>
  197.                                             </config:config-item>
  198.                                             <config:config-item config:name="CursorPositionY" config:type="int">
  199.                                                 <xsl:value-of select="x:WorksheetOptions/x:Panes/x:Pane/x:ActiveRow"/>
  200.                                             </config:config-item>
  201.                                         </xsl:otherwise>
  202.                                     </xsl:choose>
  203.                                     <xsl:variable name="position-left">
  204.                                         <xsl:choose>
  205.                                             <xsl:when test="x:WorksheetOptions/x:LeftColumnVisible">
  206.                                                 <xsl:value-of select="x:WorksheetOptions/x:LeftColumnVisible"/>
  207.                                             </xsl:when>
  208.                                             <xsl:otherwise>0</xsl:otherwise>
  209.                                         </xsl:choose>
  210.                                     </xsl:variable>
  211.                                     <config:config-item config:name="PositionLeft" config:type="int">
  212.                                         <xsl:value-of select="$position-left"/>
  213.                                     </config:config-item>
  214.                                     <xsl:variable name="position-top">
  215.                                         <xsl:choose>
  216.                                             <xsl:when test="x:WorksheetOptions/x:TopRowVisible">
  217.                                                 <xsl:value-of select="x:WorksheetOptions/x:TopRowVisible"/>
  218.                                             </xsl:when>
  219.                                             <xsl:otherwise>0</xsl:otherwise>
  220.                                         </xsl:choose>
  221.                                     </xsl:variable>
  222.                                     <xsl:choose>
  223.                                         <xsl:when test="x:WorksheetOptions/x:SplitVertical and not(x:WorksheetOptions/x:SplitHorizontal)">
  224.                                             <!-- wierd enough !! :( glu -->
  225.                                             <config:config-item config:name="PositionBottom" config:type="int">
  226.                                                 <xsl:value-of select="$position-top"/>
  227.                                             </config:config-item>
  228.                                         </xsl:when>
  229.                                         <xsl:otherwise>
  230.                                             <config:config-item config:name="PositionTop" config:type="int">
  231.                                                 <xsl:value-of select="$position-top"/>
  232.                                             </config:config-item>
  233.                                         </xsl:otherwise>
  234.                                     </xsl:choose>
  235.                                     <xsl:choose>
  236.                                         <xsl:when test="x:WorksheetOptions/x:SplitVertical">
  237.                                             <config:config-item config:name="HorizontalSplitMode" config:type="short">
  238.                                                 <xsl:choose>
  239.                                                     <xsl:when test="x:WorksheetOptions/x:FreezePanes">2</xsl:when>
  240.                                                     <xsl:otherwise>1</xsl:otherwise>
  241.                                                 </xsl:choose>
  242.                                             </config:config-item>
  243.                                             <config:config-item config:name="HorizontalSplitPosition" config:type="int">
  244.                                                 <xsl:choose>
  245.                                                     <xsl:when test="x:WorksheetOptions/x:FreezePanes">
  246.                                                         <xsl:value-of select="x:WorksheetOptions/x:SplitVertical + $position-left"/>
  247.                                                     </xsl:when>
  248.                                                     <xsl:otherwise>
  249.                                                         <xsl:value-of select="floor( x:WorksheetOptions/x:SplitVertical div $ratio )"/>
  250.                                                     </xsl:otherwise>
  251.                                                 </xsl:choose>
  252.                                             </config:config-item>
  253.                                             <config:config-item config:name="PositionRight" config:type="int">
  254.                                                 <xsl:value-of select="x:WorksheetOptions/x:LeftColumnRightPane"/>
  255.                                             </config:config-item>
  256.                                         </xsl:when>
  257.                                         <xsl:otherwise>
  258.                                             <config:config-item config:name="HorizontalSplitMode" config:type="short">0</config:config-item>
  259.                                         </xsl:otherwise>
  260.                                     </xsl:choose>
  261.                                     <xsl:choose>
  262.                                         <xsl:when test="x:WorksheetOptions/x:SplitHorizontal">
  263.                                             <config:config-item config:name="VerticalSplitMode" config:type="short">
  264.                                                 <xsl:choose>
  265.                                                     <xsl:when test="x:WorksheetOptions/x:FreezePanes">2</xsl:when>
  266.                                                     <xsl:otherwise>1</xsl:otherwise>
  267.                                                 </xsl:choose>
  268.                                             </config:config-item>
  269.                                             <config:config-item config:name="VerticalSplitPosition" config:type="int">
  270.                                                 <xsl:choose>
  271.                                                     <xsl:when test="x:WorksheetOptions/x:FreezePanes">
  272.                                                         <xsl:value-of select="x:WorksheetOptions/x:SplitHorizontal + $position-top"/>
  273.                                                     </xsl:when>
  274.                                                     <xsl:otherwise>
  275.                                                         <xsl:value-of select="floor( x:WorksheetOptions/x:SplitHorizontal div $ratio )"/>
  276.                                                     </xsl:otherwise>
  277.                                                 </xsl:choose>
  278.                                             </config:config-item>
  279.                                             <config:config-item config:name="PositionBottom" config:type="int">
  280.                                                 <xsl:value-of select="x:WorksheetOptions/x:TopRowBottomPane"/>
  281.                                             </config:config-item>
  282.                                         </xsl:when>
  283.                                         <xsl:otherwise>
  284.                                             <config:config-item config:name="VerticalSplitMode" config:type="short">0</config:config-item>
  285.                                         </xsl:otherwise>
  286.                                     </xsl:choose>
  287.                                 </config:config-item-map-entry>
  288.                             </xsl:for-each>
  289.                         </config:config-item-map-named>
  290.                         <xsl:if test="x:ActiveSheet">
  291.                             <config:config-item config:name="ActiveTable" config:type="string">
  292.                                 <xsl:value-of select="../ss:Worksheet[/ss:Workbook/x:ExcelWorkbook/x:ActiveSheet+1]/@ss:Name"/>
  293.                             </config:config-item>
  294.                         </xsl:if>
  295.                         <config:config-item config:name="HorizontalScrollbarWidth" config:type="int">555</config:config-item>
  296.                         <!-- following are some table setting from Excel, but transformed to global setting, due to limit of Calc. glu -->
  297.                         <xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:ShowPageBreakZoom">
  298.                             <config:config-item config:name="ShowPageBreakPreview" config:type="boolean">true</config:config-item>
  299.                         </xsl:if>
  300.                         <xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:PageBreakZoom">
  301.                             <config:config-item config:name="PageViewZoomValue" config:type="int">
  302.                                 <xsl:value-of select="../ss:Worksheet/x:WorksheetOptions/x:PageBreakZoom"/>
  303.                             </config:config-item>
  304.                         </xsl:if>
  305.                         <xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:Zoom">
  306.                             <config:config-item config:name="ZoomValue" config:type="int">
  307.                                 <xsl:value-of select="../ss:Worksheet/x:WorksheetOptions/x:Zoom"/>
  308.                             </config:config-item>
  309.                         </xsl:if>
  310.                         <xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:DoNotDisplayGridlines">
  311.                             <config:config-item config:name="ShowGrid" config:type="boolean">false</config:config-item>
  312.                         </xsl:if>
  313.                         <xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:GridlineColor">
  314.                             <config:config-item config:name="GridColor" config:type="long">
  315.                                 <xsl:variable name="temp-code" select="substring-after(normalize-space(../ss:Worksheet/x:WorksheetOptions/x:GridlineColor), '#')"/>
  316.                                 <xsl:variable name="temp-value">
  317.                                     <xsl:call-template name="hex2decimal">
  318.                                         <xsl:with-param name="hex-number" select="$temp-code"/>
  319.                                         <xsl:with-param name="index" select="1"/>
  320.                                         <xsl:with-param name="str-length" select="string-length($temp-code)"/>
  321.                                         <xsl:with-param name="last-value" select="0"/>
  322.                                     </xsl:call-template>
  323.                                 </xsl:variable>
  324.                                 <xsl:value-of select="$temp-value"/>
  325.                             </config:config-item>
  326.                         </xsl:if>
  327.                         <xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:DoNotDisplayHeadings">
  328.                             <config:config-item config:name="HasColumnRowHeaders" config:type="boolean">false</config:config-item>
  329.                         </xsl:if>
  330.                         <xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:DoNotDisplayZeros">
  331.                             <config:config-item config:name="ShowZeroValues" config:type="boolean">false</config:config-item>
  332.                         </xsl:if>
  333.                         <xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:DoNotDisplayOutline">
  334.                             <config:config-item config:name="IsOutlineSymbolsSet" config:type="boolean">false</config:config-item>
  335.                         </xsl:if>
  336.                         <xsl:if test="x:HideWorkbookTabs">
  337.                             <config:config-item config:name="HasSheetTabs" config:type="boolean">false</config:config-item>
  338.                         </xsl:if>
  339.                         <!-- several properties are not saved in Calc XML but setting, whereas vice versa. :( So just to be expanded, glu. -->
  340.                     </config:config-item-map-entry>
  341.                 </config:config-item-map-indexed>
  342.             </config:config-item-set>
  343.             <!-- printer setting, not finished yet. glu             
  344.             <config:config-item-set config:name="configuration-settings"/>
  345.             -->
  346.         </office:settings>
  347.     </xsl:template>
  348.     <xsl:template name="font-declaration">
  349.         <office:font-decls>
  350.             <xsl:if test="/ss:Workbook/ss:Styles/ss:Style/ss:Font">
  351.                 <xsl:for-each select="/ss:Workbook/ss:Styles/ss:Style/ss:Font">
  352.                     <xsl:element name="style:font-decl">
  353.                         <xsl:attribute name="style:name"><xsl:value-of select="@ss:FontName"/></xsl:attribute>
  354.                         <xsl:attribute name="fo:font-family"><xsl:value-of select="@ss:FontName"/></xsl:attribute>
  355.                         <xsl:attribute name="style:font-family-generic"><xsl:call-template name="translate-font-family-generic"><xsl:with-param name="family" select="@x:Family"/></xsl:call-template></xsl:attribute>
  356.                     </xsl:element>
  357.                 </xsl:for-each>
  358.             </xsl:if>
  359.             <xsl:if test="/ss:Workbook/ss:Worksheet/ss:Table/ss:Row/ss:Cell/descendant::html:Font[@html:Face]">
  360.                 <xsl:for-each select="/ss:Workbook/ss:Worksheet/ss:Table/ss:Row/ss:Cell/descendant::html:Font[@html:Face]">
  361.                     <xsl:element name="style:font-decl">
  362.                         <xsl:attribute name="style:name"><xsl:value-of select="@html:Face"/></xsl:attribute>
  363.                         <xsl:attribute name="fo:font-family"><xsl:value-of select="@html:Face"/></xsl:attribute>
  364.                         <xsl:attribute name="style:font-family-generic"><xsl:call-template name="translate-font-family-generic"><xsl:with-param name="family" select="@x:Family"/></xsl:call-template></xsl:attribute>
  365.                     </xsl:element>
  366.                 </xsl:for-each>
  367.             </xsl:if>
  368.         </office:font-decls>
  369.     </xsl:template>
  370.     <xsl:template name="translate-font-family-generic">
  371.         <xsl:param name="family"/>
  372.         <xsl:choose>
  373.             <xsl:when test="$family = 'Swiss'">swiss</xsl:when>
  374.             <xsl:when test="$family='Modern'">modern</xsl:when>
  375.             <xsl:when test="$family='Roman'">roman</xsl:when>
  376.             <xsl:when test="$family='Script'">script</xsl:when>
  377.             <xsl:when test="$family='Decorative'">decorative</xsl:when>
  378.             <!-- change 'System' to 'Automatic' for Excel. glu -->
  379.             <xsl:when test="$family='Automatic'">system</xsl:when>
  380.             <xsl:otherwise>system</xsl:otherwise>
  381.         </xsl:choose>
  382.     </xsl:template>
  383.     <xsl:template match="ss:Styles">
  384.         <office:styles>
  385.             <xsl:apply-templates select="ss:Style[@ss:Name]"/>
  386.             <xsl:apply-templates select="ss:Style/ss:NumberFormat[@ss:Format]"/>
  387.             <!-- if ConditionalFormatting exists,it should generate some styles for style:style.tom chen -->
  388.             <xsl:if test="../ss:Worksheet/x:ConditionalFormatting">
  389.                 <xsl:call-template name="CondFormat_office_style"/>
  390.             </xsl:if>
  391.         </office:styles>
  392.         <office:automatic-styles>
  393.             <xsl:apply-templates select="../ss:Worksheet/ss:Table"/>
  394.             <xsl:apply-templates select="ss:Style[not(@ss:Name)]"/>
  395.             <xsl:apply-templates select="ss:Style/ss:Font[@ss:VerticalAlign]"/>
  396.             <xsl:apply-templates select="../ss:Worksheet/ss:Table/ss:Row/ss:Cell/ss:Data[descendant-or-self::*[namespace-uri()='http://www.w3.org/TR/REC-html40']]"/>
  397.             <xsl:apply-templates select="../ss:Worksheet/x:WorksheetOptions/x:PageSetup//@x:Data"/>
  398.             <!-- if ConditionalFormatting exists,transforing the styles.tom chen -->
  399.             <xsl:if test="../ss:Worksheet/x:ConditionalFormatting">
  400.                 <xsl:call-template name="CondFormat_automatic_style"/>
  401.             </xsl:if>
  402.             <xsl:call-template name="create-page-master">
  403.                 <xsl:with-param name="worksheetoptions" select="../ss:Worksheet/x:WorksheetOptions"/>
  404.             </xsl:call-template>
  405.         </office:automatic-styles>
  406.         <office:master-styles>
  407.             <xsl:call-template name="create-master-styles">
  408.                 <xsl:with-param name="worksheetoptions" select="../ss:Worksheet/x:WorksheetOptions"/>
  409.             </xsl:call-template>
  410.         </office:master-styles>
  411.     </xsl:template>
  412.     <xsl:template name="CondFormat_office_style">
  413.         <!-- translate the ConditionalFormatting style,including font,size,color,etc.tom chen -->
  414.         <xsl:for-each select="../ss:Worksheet/x:ConditionalFormatting">
  415.             <xsl:variable name="table-pos" select="count(../preceding-sibling::ss:Worksheet)+1"/>
  416.             <xsl:variable name="conditions" select="count(preceding-sibling::x:ConditionalFormatting)+1"/>
  417.             <xsl:for-each select="x:Condition">
  418.                 <xsl:variable name="condition-number" select="count(preceding-sibling::x:Condition)+1"/>
  419.                 <style:style style:name="{concat('Excel_CondFormat_',$table-pos,'_',$conditions,'_',$condition-number)}" style:family="table-cell" style:parent-style-name="Default">
  420.                     <xsl:element name="style:properties">
  421.                         <xsl:choose>
  422.                             <xsl:when test="./x:Format/@Style">
  423.                                 <xsl:variable name="stylevalue" select="./x:Format/@Style"/>
  424.                                 <xsl:call-template name="recursion-condformat-style">
  425.                                     <xsl:with-param name="style-value-t">
  426.                                         <xsl:choose>
  427.                                             <xsl:when test="substring($stylevalue,string-length($stylevalue),1) != ';'">
  428.                                                 <xsl:value-of select="concat($stylevalue,';')"/>
  429.                                             </xsl:when>
  430.                                             <xsl:otherwise>
  431.                                                 <xsl:value-of select="$stylevalue"/>
  432.                                             </xsl:otherwise>
  433.                                         </xsl:choose>
  434.                                     </xsl:with-param>
  435.                                 </xsl:call-template>
  436.                             </xsl:when>
  437.                             <xsl:otherwise>
  438.                                 <xsl:attribute name="fo:font-style"><xsl:value-of select="'italic'"/></xsl:attribute>
  439.                                 <xsl:attribute name="style:text-underline"><xsl:value-of select="'single'"/></xsl:attribute>
  440.                                 <xsl:attribute name="style:text-underline-color"><xsl:value-of select="'font-color'"/></xsl:attribute>
  441.                                 <xsl:attribute name="fo:font-weight"><xsl:value-of select="'bold'"/></xsl:attribute>
  442.                             </xsl:otherwise>
  443.                         </xsl:choose>
  444.                     </xsl:element>
  445.                 </style:style>
  446.             </xsl:for-each>
  447.         </xsl:for-each>
  448.     </xsl:template>
  449.     <xsl:template name="recursion-condformat-style">
  450.         <!-- generates style:style for ConditionalFormatting,tom chen -->
  451.         <xsl:param name="style-value-t"/>
  452.         <xsl:variable name="style-value" select="normalize-space($style-value-t)"/>
  453.         <xsl:choose>
  454.             <xsl:when test="starts-with($style-value,'color')">
  455.                 <xsl:attribute name="fo:color"><xsl:call-template name="translate-color-style"><xsl:with-param name="source-str" select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/></xsl:call-template></xsl:attribute>
  456.             </xsl:when>
  457.             <xsl:when test="starts-with($style-value,'font-style')">
  458.                 <xsl:attribute name="fo:font-style"><xsl:value-of select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/></xsl:attribute>
  459.             </xsl:when>
  460.             <xsl:when test="starts-with($style-value,'background')">
  461.                 <xsl:choose>
  462.                     <xsl:when test="contains($style-value,'mso-pattern')">
  463.                         <xsl:variable name="color-value">
  464.                             <xsl:call-template name="translate-color-style">
  465.                                 <xsl:with-param name="source-str" select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/>
  466.                             </xsl:call-template>
  467.                         </xsl:variable>
  468.                         <xsl:variable name="mso-value">
  469.                             <xsl:call-template name="translate-color-style">
  470.                                 <xsl:with-param name="source-str" select="normalize-space(substring-after($style-value,'mso-pattern'))"/>
  471.                             </xsl:call-template>
  472.                         </xsl:variable>
  473.                         <xsl:variable name="mso-color" select="substring-after($mso-value,'#')"/>
  474.                         <xsl:variable name="pattern-color-value" select="substring($mso-color,1,6)"/>
  475.                         <xsl:variable name="pattern" select="concat('0.',normalize-space(substring-before(substring-after($mso-color,'gray-'),';')))"/>
  476.                         <xsl:variable name="pattern-color">
  477.                             <xsl:call-template name="cell-pattern-color">
  478.                                 <xsl:with-param name="pattern" select="$pattern"/>
  479.                                 <xsl:with-param name="color-value" select="$color-value"/>
  480.                                 <xsl:with-param name="pattern-color-value" select="concat('#',$pattern-color-value)"/>
  481.                             </xsl:call-template>
  482.                         </xsl:variable>
  483.                         <xsl:attribute name="fo:background-color"><xsl:value-of select="normalize-space($pattern-color)"/></xsl:attribute>
  484.                     </xsl:when>
  485.                     <xsl:otherwise>
  486.                         <xsl:attribute name="fo:background-color"><xsl:call-template name="translate-color-style"><xsl:with-param name="source-str" select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/></xsl:call-template></xsl:attribute>
  487.                     </xsl:otherwise>
  488.                 </xsl:choose>
  489.             </xsl:when>
  490.             <xsl:when test="starts-with($style-value,'font-weight')">
  491.                 <xsl:variable name="font-weight" select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/>
  492.                 <xsl:attribute name="fo:font-weight"><xsl:choose><xsl:when test="($font-weight > 300) and ($font-weight < 500)"><xsl:value-of select="'normal'"/></xsl:when><xsl:when test="($font-weight > 500) or ($font-weight = 500)"><xsl:value-of select="'bold'"/></xsl:when><xsl:otherwise><xsl:value-of select="'0'"/></xsl:otherwise></xsl:choose></xsl:attribute>
  493.             </xsl:when>
  494.             <xsl:when test="starts-with($style-value,'border')">
  495.                 <xsl:attribute name="fo:border"><xsl:value-of select="'0.002cm solid #000000'"/></xsl:attribute>
  496.             </xsl:when>
  497.             <xsl:when test="starts-with($style-value,'text-underline-style')">
  498.                 <xsl:attribute name="style:text-underline"><xsl:value-of select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/></xsl:attribute>
  499.                 <xsl:attribute name="style:text-underline-color"><xsl:value-of select="'#000000'"/></xsl:attribute>
  500.             </xsl:when>
  501.         </xsl:choose>
  502.         <xsl:if test="contains($style-value,':')">
  503.             <xsl:call-template name="recursion-condformat-style">
  504.                 <xsl:with-param name="style-value-t" select="substring-after($style-value,';')"/>
  505.             </xsl:call-template>
  506.         </xsl:if>
  507.     </xsl:template>
  508.     <xsl:template name="translate-color-style">
  509.         <!-- translate the word of color to hex code of color.tom chen -->
  510.         <xsl:param name="source-str"/>
  511.         <xsl:choose>
  512.             <xsl:when test="starts-with($source-str,'#')">
  513.                 <xsl:value-of select="$source-str"/>
  514.             </xsl:when>
  515.             <xsl:otherwise>
  516.                 <xsl:choose>
  517.                     <xsl:when test="starts-with($source-str,'black')">
  518.                         <xsl:value-of select="'#000000'"/>
  519.                     </xsl:when>
  520.                     <xsl:when test="starts-with($source-str,'maroon')">
  521.                         <xsl:value-of select="'#800000'"/>
  522.                     </xsl:when>
  523.                     <xsl:when test="starts-with($source-str,'red')">
  524.                         <xsl:value-of select="'#FF0000'"/>
  525.                     </xsl:when>
  526.                     <xsl:when test="starts-with($source-str,'fuchsia')">
  527.                         <xsl:value-of select="'#FF00FF'"/>
  528.                     </xsl:when>
  529.                     <xsl:when test="starts-with($source-str,'olive')">
  530.                         <xsl:value-of select="'#808000'"/>
  531.                     </xsl:when>
  532.                     <xsl:when test="starts-with($source-str,'yellow')">
  533.                         <xsl:value-of select="'#FFFF00'"/>
  534.                     </xsl:when>
  535.                     <xsl:when test="starts-with($source-str,'green')">
  536.                         <xsl:value-of select="'#008000'"/>
  537.                     </xsl:when>
  538.                     <xsl:when test="starts-with($source-str,'lime')">
  539.                         <xsl:value-of select="'#00FF00'"/>
  540.                     </xsl:when>
  541.                     <xsl:when test="starts-with($source-str,'teal')">
  542.                         <xsl:value-of select="'#008080'"/>
  543.                     </xsl:when>
  544.                     <xsl:when test="starts-with($source-str,'aqua')">
  545.                         <xsl:value-of select="'#00FFFF'"/>
  546.                     </xsl:when>
  547.                     <xsl:when test="starts-with($source-str,'navy')">
  548.                         <xsl:value-of select="'#000080'"/>
  549.                     </xsl:when>
  550.                     <xsl:when test="starts-with($source-str,'blue')">
  551.                         <xsl:value-of select="'#0000FF'"/>
  552.                     </xsl:when>
  553.                     <xsl:when test="starts-with($source-str,'purple')">
  554.                         <xsl:value-of select="'#800080'"/>
  555.                     </xsl:when>
  556.                     <xsl:when test="starts-with($source-str,'gray')">
  557.                         <xsl:value-of select="'#808080'"/>
  558.                     </xsl:when>
  559.                     <xsl:when test="starts-with($source-str,'silver')">
  560.                         <xsl:value-of select="'#C0C0C0'"/>
  561.                     </xsl:when>
  562.                     <xsl:when test="starts-with($source-str,'white')">
  563.                         <xsl:value-of select="'#FFFFFF'"/>
  564.                     </xsl:when>
  565.                     <xsl:otherwise>
  566.                         <xsl:value-of select="'#FFFFFF'"/>
  567.                     </xsl:otherwise>
  568.                 </xsl:choose>
  569.             </xsl:otherwise>
  570.         </xsl:choose>
  571.     </xsl:template>
  572.     <xsl:template name="CondFormat_automatic_style">
  573.         <!-- translate the ConditionalFormatting condition,including map,formalu,etc.tom chen -->
  574.         <xsl:for-each select="../ss:Worksheet/x:ConditionalFormatting">
  575.             <xsl:variable name="table-pos" select="count(../preceding-sibling::ss:Worksheet)+1"/>
  576.             <xsl:variable name="conditions" select="count(preceding-sibling::x:ConditionalFormatting)+1"/>
  577.             <style:style style:name="{concat('ce',$table-pos,'-',$conditions)}" style:family="table-cell" style:parent-style-name="Default">
  578.                 <xsl:for-each select="x:Condition">
  579.                     <xsl:variable name="condition-number" select="count(preceding-sibling::x:Condition)+1"/>
  580.                     <xsl:variable name="base-address">
  581.                         <xsl:choose>
  582.                             <xsl:when test="contains(../x:Range,',')">
  583.                                 <xsl:choose>
  584.                                     <xsl:when test="contains(substring-before(../x:Range,','),':')">
  585.                                         <xsl:value-of select="substring-before(substring-after(../x:Range,':'),',')"/>
  586.                                     </xsl:when>
  587.                                     <xsl:otherwise>
  588.                                         <xsl:value-of select="substring-before(../x:Range,',')"/>
  589.                                     </xsl:otherwise>
  590.                                 </xsl:choose>
  591.                             </xsl:when>
  592.                             <xsl:otherwise>
  593.                                 <xsl:value-of select="../x:Range"/>
  594.                             </xsl:otherwise>
  595.                         </xsl:choose>
  596.                     </xsl:variable>
  597.                     <xsl:variable name="base-cell-address">
  598.                         <xsl:call-template name="translate-unit">
  599.                             <xsl:with-param name="column-number" select="substring-before(substring-after($base-address,'R'),'C')"/>
  600.                             <xsl:with-param name="row-number" select="substring-after($base-address,'C')"/>
  601.                             <xsl:with-param name="column-pos-style" select="absolute"/>
  602.                             <xsl:with-param name="row-pos-style" select="absolute"/>
  603.                         </xsl:call-template>
  604.                     </xsl:variable>
  605.                     <xsl:variable name="condition-value">
  606.                         <xsl:call-template name="translate-condition">
  607.                         </xsl:call-template>
  608.                     </xsl:variable>
  609.                     <xsl:element name="style:map">
  610.                         <xsl:attribute name="style:condition"><xsl:value-of select="$condition-value"/></xsl:attribute>
  611.                         <xsl:attribute name="style:apply-style-name"><xsl:value-of select="concat('Excel_CondFormat_',$table-pos,'_',$conditions,'_',$condition-number)"/></xsl:attribute>
  612.                         <xsl:attribute name="style:base-cell-address"><xsl:value-of select="concat(../../@ss:Name,'.',$base-cell-address)"/></xsl:attribute>
  613.                     </xsl:element>
  614.                 </xsl:for-each>
  615.             </style:style>
  616.         </xsl:for-each>
  617.     </xsl:template>
  618.     <xsl:template name="translate-condition">
  619.         <!-- translates the condition to generate formula.tom chen -->
  620.         <xsl:variable name="address-value">
  621.             <xsl:call-template name="translate-expression">
  622.                 <xsl:with-param name="cell-row-pos" select="0"/>
  623.                 <xsl:with-param name="cell-column-pos" select="0"/>
  624.                 <xsl:with-param name="expression" select="x:Value1"/>
  625.             </xsl:call-template>
  626.         </xsl:variable>
  627.         <xsl:choose>
  628.             <xsl:when test="x:Qualifier">
  629.                 <xsl:variable name="qualifier" select="x:Qualifier"/>
  630.                 <xsl:variable name="first-value" select="x:Value1"/>
  631.                 <xsl:choose>
  632.                     <xsl:when test="$qualifier = 'Equal'">
  633.                         <xsl:choose>
  634.                             <xsl:when test="starts-with($first-value,'"')">
  635.                                 <xsl:value-of select="concat('cell-content()=',$address-value)"/>
  636.                             </xsl:when>
  637.                             <xsl:otherwise>
  638.                                 <xsl:value-of select="concat('cell-content()=[',$address-value,']')"/>
  639.                             </xsl:otherwise>
  640.                         </xsl:choose>
  641.                     </xsl:when>
  642.                     <xsl:when test="$qualifier = 'Less'">
  643.                         <xsl:value-of select="concat('cell-content()<[',$address-value,']')"/>
  644.                     </xsl:when>
  645.                     <xsl:when test="$qualifier = 'Greater'">
  646.                         <xsl:value-of select="concat('cell-content()>[',$address-value,']')"/>
  647.                     </xsl:when>
  648.                     <xsl:when test="$qualifier = 'LessOrEqual'">
  649.                         <xsl:value-of select="concat('cell-content()<=[',$address-value,']')"/>
  650.                     </xsl:when>
  651.                     <xsl:when test="$qualifier = 'GreaterOrEqual'">
  652.                         <xsl:value-of select="concat('cell-content()>=[',$address-value,']')"/>
  653.                     </xsl:when>
  654.                     <xsl:when test="$qualifier = 'NotEqual'">
  655.                         <xsl:value-of select="concat('cell-content()!=[',$address-value,']')"/>
  656.                     </xsl:when>
  657.                     <xsl:when test="$qualifier = 'Between'">
  658.                         <xsl:variable name="second-value">
  659.                             <xsl:call-template name="translate-expression">
  660.                                 <xsl:with-param name="cell-row-pos" select="0"/>
  661.                                 <xsl:with-param name="cell-column-pos" select="0"/>
  662.                                 <xsl:with-param name="expression" select="x:Value2"/>
  663.                             </xsl:call-template>
  664.                         </xsl:variable>
  665.                         <xsl:value-of select="concat('cell-content-is-between([',$address-value,'],[',$second-value,'])')"/>
  666.                     </xsl:when>
  667.                     <xsl:when test="$qualifier = 'NotBetween'">
  668.                         <xsl:variable name="second-value">
  669.                             <xsl:call-template name="translate-expression">
  670.                                 <xsl:with-param name="cell-row-pos" select="0"/>
  671.                                 <xsl:with-param name="cell-column-pos" select="0"/>
  672.                                 <xsl:with-param name="expression" select="x:Value2"/>
  673.                             </xsl:call-template>
  674.                         </xsl:variable>
  675.                         <xsl:value-of select="concat('cell-content-is-not-between([',$address-value,'],[',$second-value,'])')"/>
  676.                     </xsl:when>
  677.                 </xsl:choose>
  678.             </xsl:when>
  679.             <xsl:otherwise>
  680.                 <xsl:value-of select="concat('is-true-formula(',$address-value,')')"/>
  681.             </xsl:otherwise>
  682.         </xsl:choose>
  683.     </xsl:template>
  684.     <xsl:template match="ss:NumberFormat">
  685.         <xsl:variable name="unit-count" select="string-length(@ss:Format) - string-length(translate(@ss:Format,';','')) + 1"/>
  686.         <xsl:variable name="proto-style-id" select="../@ss:ID"/>
  687.         <xsl:call-template name="process-number-format-unit">
  688.             <xsl:with-param name="number-format-unit" select="@ss:Format"/>
  689.             <xsl:with-param name="style-id" select="concat($proto-style-id,'F')"/>
  690.             <xsl:with-param name="format-type" select="//ss:Cell[@ss:StyleID = $proto-style-id]/ss:Data/@ss:Type"/>
  691.             <xsl:with-param name="total-unit" select="$unit-count"/>
  692.             <xsl:with-param name="current-unit" select="0"/>
  693.         </xsl:call-template>
  694.     </xsl:template>
  695.     <xsl:template name="process-number-format-unit">
  696.         <xsl:param name="number-format-unit"/>
  697.         <xsl:param name="style-id"/>
  698.         <xsl:param name="format-type"/>
  699.         <xsl:param name="total-unit"/>
  700.         <xsl:param name="current-unit"/>
  701.         <xsl:choose>
  702.             <!-- if total-unit > 1 and the last unit is just @, delete it. glu -->
  703.             <xsl:when test="$current-unit = 0 and $total-unit > 1 and substring( $number-format-unit, string-length($number-format-unit) - 1) = ';@'">
  704.                 <xsl:call-template name="process-number-format-unit">
  705.                     <xsl:with-param name="number-format-unit" select="substring( $number-format-unit, 1, string-length($number-format-unit) - 2)"/>
  706.                     <xsl:with-param name="style-id" select="$style-id"/>
  707.                     <xsl:with-param name="format-type" select="$format-type"/>
  708.                     <xsl:with-param name="total-unit" select="$total-unit - 1"/>
  709.                     <xsl:with-param name="current-unit" select="0"/>
  710.                 </xsl:call-template>
  711.             </xsl:when>
  712.             <!-- $number-format-unit enum values: General, General Number, General Date, Long Date, Medium Date, Short Date, Long Time,
  713.              Medium Time, Short Time, Currency, Euro Currency, Fixed, Standard, Percent, Scientific, Yes/No, True/False, On/Off. glu -->
  714.             <xsl:when test="$number-format-unit = 'Currency'">
  715.                 <number:number-style style:name="{concat( $style-id, 'P1')}" style:family="data-style" style:volatile="true">
  716.                     <number:text>$</number:text>
  717.                     <number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
  718.                 </number:number-style>
  719.                 <number:number-style style:name="{$style-id}" style:family="data-style">
  720.                     <style:properties fo:color="#ff0000"/>
  721.                     <number:text>$-</number:text>
  722.                     <number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
  723.                     <style:map style:condition="value()>=0" style:apply-style-name="{concat( $style-id, 'P1')}"/>
  724.                 </number:number-style>
  725.             </xsl:when>
  726.             <xsl:when test="$number-format-unit = 'Euro Currency'">
  727.                 <number:currency-style style:name="{concat( $style-id, 'P1')}" style:family="data-style" style:volatile="true">
  728.                     <number:text>Γé¼</number:text>
  729.                     <number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
  730.                 </number:currency-style>
  731.                 <number:currency-style style:name="{$style-id}" style:family="data-style">
  732.                     <style:properties fo:color="#ff0000"/>
  733.                     <number:text>(Γé¼</number:text>
  734.                     <number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
  735.                     <number:text>)</number:text>
  736.                     <style:map style:condition="value()>=0" style:apply-style-name="{concat( $style-id, 'P1')}"/>
  737.                 </number:currency-style>
  738.             </xsl:when>
  739.             <xsl:when test="$number-format-unit = 'Yes/No' or $number-format-unit = 'True/False' or $number-format-unit = 'On/Off'">
  740.                 <xsl:variable name="left-code" select="substring-before( $number-format-unit, '/')"/>
  741.                 <xsl:variable name="right-code" select="substring-after( $number-format-unit, '/')"/>
  742.                 <number:number-style style:name="{concat( $style-id, 'P1')}" style:family="data-style" style:volatile="true">
  743.                     <number:text>
  744.                         <xsl:value-of select="$left-code"/>
  745.                     </number:text>
  746.                 </number:number-style>
  747.                 <number:number-style style:name="{concat( $style-id, 'P2')}" style:family="data-style" style:volatile="true">
  748.                     <number:text>
  749.                         <xsl:value-of select="$left-code"/>
  750.                     </number:text>
  751.                 </number:number-style>
  752.                 <number:number-style style:name="{$style-id}" style:family="data-style">
  753.                     <number:text>
  754.                         <xsl:value-of select="$right-code"/>
  755.                     </number:text>
  756.                     <style:map style:condition="value()>0" style:apply-style-name="{concat( $style-id, 'P1')}"/>
  757.                     <style:map style:condition="value()<0" style:apply-style-name="{concat( $style-id, 'P2')}"/>
  758.                 </number:number-style>
  759.             </xsl:when>
  760.             <xsl:otherwise>
  761.                 <xsl:if test="$total-unit > 1 and $current-unit = 0">
  762.                     <!-- still complete number format string of multiple sub-formats, split them out. glu -->
  763.                     <xsl:call-template name="process-number-format-unit">
  764.                         <xsl:with-param name="number-format-unit" select="substring-before($number-format-unit,';')"/>
  765.                         <xsl:with-param name="style-id" select="concat($style-id,'P1')"/>
  766.                         <xsl:with-param name="format-type" select="$format-type"/>
  767.                         <xsl:with-param name="total-unit" select="$total-unit"/>
  768.                         <xsl:with-param name="current-unit" select="1"/>
  769.                     </xsl:call-template>
  770.                     <xsl:if test="$total-unit > 2">
  771.                         <xsl:call-template name="process-number-format-unit">
  772.                             <xsl:with-param name="number-format-unit" select="substring-before(substring-after($number-format-unit,';'),';')"/>
  773.                             <xsl:with-param name="style-id" select="concat($style-id,'P2')"/>
  774.                             <xsl:with-param name="format-type" select="$format-type"/>
  775.                             <xsl:with-param name="total-unit" select="$total-unit"/>
  776.                             <xsl:with-param name="current-unit" select="2"/>
  777.                         </xsl:call-template>
  778.                     </xsl:if>
  779.                     <xsl:if test="$total-unit > 3">
  780.                         <!-- four sub number format. glu -->
  781.                         <xsl:call-template name="process-number-format-unit">
  782.                             <xsl:with-param name="number-format-unit" select="substring-before(substring-after(substring-after($number-format-unit,';'),';'),';')"/>
  783.                             <xsl:with-param name="style-id" select="concat($style-id,'P3')"/>
  784.                             <xsl:with-param name="format-type" select="$format-type"/>
  785.                             <xsl:with-param name="total-unit" select="$total-unit"/>
  786.                             <xsl:with-param name="current-unit" select="3"/>
  787.                         </xsl:call-template>
  788.                     </xsl:if>
  789.                 </xsl:if>
  790.                 <!-- symbol number format converted, below deal with ordinary number formatting. Watch out, it'll be quite complex. :( glu -->
  791.                 <xsl:variable name="current-number-format-unit">
  792.                     <xsl:choose>
  793.                         <xsl:when test="$total-unit = 1 and $current-unit = 0">
  794.                             <xsl:value-of select="$number-format-unit"/>
  795.                         </xsl:when>
  796.                         <xsl:when test="$total-unit = 2 and $current-unit = 0">
  797.                             <xsl:value-of select="substring-after($number-format-unit,';')"/>
  798.                         </xsl:when>
  799.                         <xsl:when test="$total-unit = 3 and $current-unit = 0">
  800.                             <xsl:value-of select="substring-after(substring-after($number-format-unit,';'),';')"/>
  801.                         </xsl:when>
  802.                         <xsl:when test="$current-unit = 0">
  803.                             <!-- the forth sub number format. glu -->
  804.                             <xsl:value-of select="substring-after(substring-after(substring-after($number-format-unit,';'),';'),';')"/>
  805.                         </xsl:when>
  806.                         <xsl:otherwise>
  807.                             <!-- not the default sub number format, glu. -->
  808.                             <xsl:value-of select="$number-format-unit"/>
  809.                         </xsl:otherwise>
  810.                     </xsl:choose>
  811.                 </xsl:variable>
  812.                 <xsl:variable name="style-type-name">
  813.                     <xsl:choose>
  814.                         <xsl:when test="($format-type = 'Number' and contains($current-number-format-unit,'[$') and not(contains($current-number-format-unit,'[$-') ) ) or contains($current-number-format-unit,'Currency') ">number:currency-style</xsl:when>
  815.                         <xsl:when test="($format-type = 'Number' and (contains($current-number-format-unit,'%') or contains($current-number-format-unit, 'Percent') ) ) or contains($current-number-format-unit,'Percent') ">number:percentage-style</xsl:when>
  816.                         <xsl:when test="$format-type = 'DateTime' and (contains($current-number-format-unit,'y') or contains($current-number-format-unit,'g') or contains($current-number-format-unit,'d') or contains($current-number-format-unit, 'Date') )">number:date-style</xsl:when>
  817.                         <xsl:when test="$format-type = 'DateTime' and ( contains($current-number-format-unit,'h') or contains($current-number-format-unit,'m') or contains($current-number-format-unit,'s') or contains($current-number-format-unit, 'Time') )">number:time-style</xsl:when>
  818.                         <xsl:when test="contains($current-number-format-unit, 'Number') or contains($current-number-format-unit, 'Fixed') or contains($current-number-format-unit, 'Standard') or contains($current-number-format-unit, 'Scientific') or contains($current-number-format-unit, 'General') or ( contains($current-number-format-unit,'#') or contains($current-number-format-unit,'0') or contains($current-number-format-unit,'?') )">number:number-style</xsl:when>
  819.                         <xsl:when test="$format-type = 'Boolean'">number:boolean-style</xsl:when>
  820.                         <xsl:otherwise>number:text-style</xsl:otherwise>
  821.                     </xsl:choose>
  822.                 </xsl:variable>
  823.                 <xsl:element name="{$style-type-name}">
  824.                     <xsl:attribute name="style:name"><xsl:value-of select="$style-id"/></xsl:attribute>
  825.                     <xsl:attribute name="style:family">data-style</xsl:attribute>
  826.                     <xsl:if test="$current-unit > 0">
  827.                         <xsl:attribute name="style:volatile">true</xsl:attribute>
  828.                     </xsl:if>
  829.                     <xsl:if test="contains ( $current-number-format-unit, '[h]') or contains ( $current-number-format-unit, '[m]') or contains ( $current-number-format-unit, '[s]')">
  830.                         <xsl:attribute name="number:truncate-on-overflow">false</xsl:attribute>
  831.                     </xsl:if>
  832.                     <xsl:if test="contains($current-number-format-unit,'[$') or contains($current-number-format-unit, '[DBNum')">
  833.                         <xsl:call-template name="create-language-country-attribute">
  834.                             <xsl:with-param name="attribute-code" select="substring-before(substring-after(substring-after($current-number-format-unit,'[$'),'-'),']')"/>
  835.                             <xsl:with-param name="number-code-style" select="substring-before( substring-after($current-number-format-unit,'[DBNum'),']')"/>
  836.                         </xsl:call-template>
  837.                     </xsl:if>
  838.                     <xsl:element name="style:properties">
  839.                         <xsl:choose>
  840.                             <xsl:when test="contains( $current-number-format-unit, '[Red')">
  841.                                 <xsl:attribute name="fo:color">#ff0000</xsl:attribute>
  842.                             </xsl:when>
  843.                             <xsl:when test="contains( $current-number-format-unit, '[Black')">
  844.                                 <xsl:attribute name="fo:color">#000000</xsl:attribute>
  845.                             </xsl:when>
  846.                             <xsl:when test="contains( $current-number-format-unit, '[Blue')">
  847.                                 <xsl:attribute name="fo:color">#0000ff</xsl:attribute>
  848.                             </xsl:when>
  849.                             <xsl:when test="contains( $current-number-format-unit, '[Cyan')">
  850.                                 <xsl:attribute name="fo:color">#00ffff</xsl:attribute>
  851.                             </xsl:when>
  852.                             <xsl:when test="contains( $current-number-format-unit, '[Green')">
  853.                                 <xsl:attribute name="fo:color">#00ff00</xsl:attribute>
  854.                             </xsl:when>
  855.                             <xsl:when test="contains( $current-number-format-unit, '[Magenta')">
  856.                                 <xsl:attribute name="fo:color">#ff00ff</xsl:attribute>
  857.                             </xsl:when>
  858.                             <xsl:when test="contains( $current-number-format-unit, '[White')">
  859.                                 <xsl:attribute name="fo:color">#ffffff</xsl:attribute>
  860.                             </xsl:when>
  861.                             <xsl:when test="contains( $current-number-format-unit, '[Yellow')">
  862.                                 <xsl:attribute name="fo:color">#ffff00</xsl:attribute>
  863.                             </xsl:when>
  864.                         </xsl:choose>
  865.                     </xsl:element>
  866.                     <xsl:call-template name="create-number-format-content">
  867.                         <xsl:with-param name="number-format-unit" select="$current-number-format-unit"/>
  868.                         <xsl:with-param name="unit-pos" select="1"/>
  869.                     </xsl:call-template>
  870.                     <!-- creat style:map for other sub number formats. glu -->
  871.                     <xsl:if test="$current-unit = 0 and $total-unit > 1">
  872.                         <xsl:variable name="style-condition1">
  873.                             <xsl:call-template name="get-number-format-condition">
  874.                                 <xsl:with-param name="number-format-unit" select="substring-before($number-format-unit,';')"/>
  875.                             </xsl:call-template>
  876.                         </xsl:variable>
  877.                         <xsl:choose>
  878.                             <xsl:when test="string-length($style-condition1) > 0">
  879.                                 <style:map style:condition="{concat('value()',$style-condition1)}" style:apply-style-name="{concat($style-id,'P1')}"/>
  880.                             </xsl:when>
  881.                             <xsl:otherwise>
  882.                                 <xsl:choose>
  883.                                     <xsl:when test="$total-unit = 2">
  884.                                         <style:map style:condition="value()>=0" style:apply-style-name="{concat($style-id,'P1')}"/>
  885.                                     </xsl:when>
  886.                                     <xsl:otherwise>
  887.                                         <style:map style:condition="value()>0" style:apply-style-name="{concat($style-id,'P1')}"/>
  888.                                     </xsl:otherwise>
  889.                                 </xsl:choose>
  890.                             </xsl:otherwise>
  891.                         </xsl:choose>
  892.                         <xsl:if test="$total-unit > 2">
  893.                             <xsl:variable name="style-condition2">
  894.                                 <xsl:call-template name="get-number-format-condition">
  895.                                     <xsl:with-param name="number-format-unit" select="substring-before(substring-after($number-format-unit,';'),';')"/>
  896.                                 </xsl:call-template>
  897.                             </xsl:variable>
  898.                             <xsl:choose>
  899.                                 <xsl:when test="string-length($style-condition2) > 0">
  900.                                     <style:map style:condition="{concat('value()',$style-condition2)}" style:apply-style-name="{concat($style-id,'P2')}"/>
  901.                                 </xsl:when>
  902.                                 <xsl:otherwise>
  903.                                     <style:map style:condition="value()<0" style:apply-style-name="{concat($style-id,'P2')}"/>
  904.                                 </xsl:otherwise>
  905.                             </xsl:choose>
  906.                         </xsl:if>
  907.                         <xsl:if test="$total-unit > 3">
  908.                             <!-- four sub number formats, glu. -->
  909.                             <xsl:variable name="style-condition3">
  910.                                 <xsl:call-template name="get-number-format-condition">
  911.                                     <xsl:with-param name="number-format-unit" select="substring-before(substring-after(substring-after($number-format-unit,';'),';'),';')"/>
  912.                                 </xsl:call-template>
  913.                             </xsl:variable>
  914.                             <xsl:choose>
  915.                                 <xsl:when test="string-length($style-condition3) > 0">
  916.                                     <style:map style:condition="{concat('value()',$style-condition3)}" style:apply-style-name="{concat($style-id,'P3')}"/>
  917.                                 </xsl:when>
  918.                                 <xsl:otherwise>
  919.                                     <style:map style:condition="value()=0" style:apply-style-name="{concat($style-id,'P3')}"/>
  920.                                 </xsl:otherwise>
  921.                             </xsl:choose>
  922.                         </xsl:if>
  923.                     </xsl:if>
  924.                 </xsl:element>
  925.             </xsl:otherwise>
  926.         </xsl:choose>
  927.     </xsl:template>
  928.     <xsl:template name="create-language-country-attribute">
  929.         <xsl:param name="attribute-code"/>
  930.         <xsl:param name="number-code-style"/>
  931.         <!-- convert Microsoft List of Locale ID (LCID) to language and country codes according to ISO-639 and ISO-3166. 
  932.             Reference:
  933.             http://www.loc.gov/standards/iso639-2/langcodes.html
  934.             http://etext.lib.virginia.edu/tei/iso639.html
  935.             http://nl.ijs.si/gnusl/cee/std/ISO_3166.html
  936.             http://xml.coverpages.org/ripe3166.txt
  937.             http://www.worldlanguage.com/
  938.             http://www.ethnologue.com/
  939.         glu -->
  940.         <!-- the variables of language-country-code and number-shape-code transmit to decimal format. tom chen -->
  941.         <xsl:variable name="language-country-code">
  942.             <xsl:variable name="temp-code">
  943.                 <xsl:choose>
  944.                     <xsl:when test="string-length($attribute-code) <= 4">
  945.                         <xsl:value-of select="$attribute-code"/>
  946.                     </xsl:when>
  947.                     <xsl:otherwise>
  948.                         <xsl:value-of select="substring($attribute-code,string-length($attribute-code) - 3)"/>
  949.                     </xsl:otherwise>
  950.                 </xsl:choose>
  951.             </xsl:variable>
  952.             <xsl:call-template name="hex2decimal">
  953.                 <xsl:with-param name="hex-number" select="$temp-code"/>
  954.                 <xsl:with-param name="index" select="1"/>
  955.                 <xsl:with-param name="str-length" select="string-length($temp-code)"/>
  956.                 <xsl:with-param name="last-value" select="0"/>
  957.             </xsl:call-template>
  958.         </xsl:variable>
  959.         <xsl:if test="string-length($attribute-code) > 4 or string-length($number-code-style) > 0">
  960.             <xsl:variable name="number-shape-code">
  961.                 <xsl:variable name="temp-code">
  962.                     <xsl:choose>
  963.                         <xsl:when test="string-length($attribute-code) > 4">
  964.                             <xsl:value-of select="substring($attribute-code, 1, string-length($attribute-code) - 6)"/>
  965.                         </xsl:when>
  966.                         <xsl:otherwise>0</xsl:otherwise>
  967.                     </xsl:choose>
  968.                 </xsl:variable>
  969.                 <xsl:call-template name="hex2decimal">
  970.                     <xsl:with-param name="hex-number" select="$temp-code"/>
  971.                     <xsl:with-param name="index" select="1"/>
  972.                     <xsl:with-param name="str-length" select="string-length($temp-code)"/>
  973.                     <xsl:with-param name="last-value" select="0"/>
  974.                 </xsl:call-template>
  975.             </xsl:variable>
  976.             <xsl:attribute name="number:transliteration-style">long</xsl:attribute>
  977.             <xsl:choose>
  978.                 <!-- Western, #01 -->
  979.                 <xsl:when test="$number-shape-code = 1"/>
  980.                 <!-- Arabic Indic, #02 -->
  981.                 <xsl:when test="$number-shape-code = 2"/>
  982.                 <!-- Extended Arabic Indic, #03 -->
  983.                 <xsl:when test="$number-shape-code = 3"/>
  984.                 <!-- Devanagari (Sanskrit - India), #04-->
  985.                 <xsl:when test="$number-shape-code = 4">
  986.                     <xsl:attribute name="number:transliteration-language">sa</xsl:attribute>
  987.                     <xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
  988.                 </xsl:when>
  989.                 <!-- Bengali (India), #05 -->
  990.                 <xsl:when test="$number-shape-code = 5">
  991.                     <xsl:attribute name="number:transliteration-language">bn</xsl:attribute>
  992.                     <xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
  993.                 </xsl:when>
  994.                 <!-- Gurmukhi (Punjabi - India), #06 -->
  995.                 <xsl:when test="$number-shape-code = 6">
  996.                     <xsl:attribute name="number:transliteration-language">pa</xsl:attribute>
  997.                     <xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
  998.                 </xsl:when>
  999.                 <!-- Gujarati (India), #07 -->
  1000.                 <xsl:when test="$number-shape-code = 7">
  1001.                     <xsl:attribute name="number:transliteration-language">gu</xsl:attribute>
  1002.                     <xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
  1003.                 </xsl:when>
  1004.                 <!-- Oriya (India), #08 -->
  1005.                 <xsl:when test="$number-shape-code = 8">
  1006.                     <xsl:attribute name="number:transliteration-language">or</xsl:attribute>
  1007.                     <xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
  1008.                 </xsl:when>
  1009.                 <!-- Tamil (India), #09 -->
  1010.                 <xsl:when test="$number-shape-code = 9">
  1011.                     <xsl:attribute name="number:transliteration-language">ta</xsl:attribute>
  1012.                     <xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
  1013.                 </xsl:when>
  1014.                 <!-- Telugu (India), #0a -->
  1015.                 <xsl:when test="$number-shape-code = 10">
  1016.                     <xsl:attribute name="number:transliteration-language">te</xsl:attribute>
  1017.                     <xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
  1018.                 </xsl:when>
  1019.                 <!-- Kannada (India), #0b -->
  1020.                 <xsl:when test="$number-shape-code = 11">
  1021.                     <xsl:attribute name="number:transliteration-language">kn</xsl:attribute>
  1022.                     <xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
  1023.                 </xsl:when>
  1024.                 <!-- Malayalam (India), #0c -->
  1025.                 <xsl:when test="$number-shape-code = 12">
  1026.                     <xsl:attribute name="number:transliteration-language">ml</xsl:attribute>
  1027.                     <xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
  1028.                 </xsl:when>
  1029.                 <!-- Thai, #0d -->
  1030.                 <xsl:when test="$number-shape-code = 13">
  1031.                     <xsl:attribute name="number:transliteration-language">th</xsl:attribute>
  1032.                     <xsl:attribute name="number:transliteration-country">TH</xsl:attribute>
  1033.                 </xsl:when>
  1034.                 <!-- Lao, #0e -->
  1035.                 <xsl:when test="$number-shape-code = 14">
  1036.                     <xsl:attribute name="number:transliteration-language">lo</xsl:attribute>
  1037.                     <xsl:attribute name="number:transliteration-country">LA</xsl:attribute>
  1038.                 </xsl:when>
  1039.                 <!-- Tibetan (China), #0f -->
  1040.                 <xsl:when test="$number-shape-code = 15">
  1041.                     <xsl:attribute name="number:transliteration-language">bo</xsl:attribute>
  1042.                     <xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
  1043.                 </xsl:when>
  1044.                 <!-- Myanmar (Burma), #10 -->
  1045.                 <xsl:when test="$number-shape-code = 16">
  1046.                     <xsl:attribute name="number:transliteration-language">my</xsl:attribute>
  1047.                     <xsl:attribute name="number:transliteration-country">MM</xsl:attribute>
  1048.                 </xsl:when>
  1049.                 <!-- Ethiopic (Geez), #11 -->
  1050.                 <xsl:when test="$number-shape-code = 17">
  1051.                     <xsl:attribute name="number:transliteration-language">gez</xsl:attribute>
  1052.                     <xsl:attribute name="number:transliteration-country">ET</xsl:attribute>
  1053.                 </xsl:when>
  1054.                 <!-- Khmer (Cambodian), #12-->
  1055.                 <xsl:when test="$number-shape-code = 18">
  1056.                     <xsl:attribute name="number:transliteration-language">km</xsl:attribute>
  1057.                     <xsl:attribute name="number:transliteration-country">KH</xsl:attribute>
  1058.                 </xsl:when>
  1059.                 <!-- Mongolian, #13 -->
  1060.                 <xsl:when test="$number-shape-code = 19">
  1061.                     <xsl:attribute name="number:transliteration-language">mn</xsl:attribute>
  1062.                     <xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
  1063.                 </xsl:when>
  1064.                 <!-- Japanese 1 ([DBNum1]) , #1b, #0411 -->
  1065.                 <xsl:when test="$number-shape-code = 27 or ($number-code-style = '1' and $language-country-code = 1041)">
  1066.                     <xsl:attribute name="number:transliteration-format">Σ╕Ç</xsl:attribute>
  1067.                     <xsl:attribute name="number:transliteration-language">ja</xsl:attribute>
  1068.                     <xsl:attribute name="number:transliteration-country">JP</xsl:attribute>
  1069.                 </xsl:when>
  1070.                 <!-- Japanese 2 ([DBNum2]) ,#1c, #0411 -->
  1071.                 <xsl:when test="$number-shape-code = 28 or ($number-code-style = '2' and $language-country-code = 1041 )">
  1072.                     <xsl:attribute name="number:transliteration-format">σú╣</xsl:attribute>
  1073.                     <xsl:attribute name="number:transliteration-language">ja</xsl:attribute>
  1074.                     <xsl:attribute name="number:transliteration-country">JP</xsl:attribute>
  1075.                 </xsl:when>
  1076.                 <!-- Japanese 3 ([DBNum3]), #1d, #0411 -->
  1077.                 <xsl:when test="$number-shape-code = 29 or ($number-code-style = '3' and $language-country-code = 1041 )">
  1078.                     <xsl:attribute name="number:transliteration-format">∩╝æ</xsl:attribute>
  1079.                     <xsl:attribute name="number:transliteration-language">ja</xsl:attribute>
  1080.                     <xsl:attribute name="number:transliteration-country">JP</xsl:attribute>
  1081.                 </xsl:when>
  1082.                 <!-- Simplified Chinese 1 ([DBNum1]), #1e, #0804 -->
  1083.                 <xsl:when test="$number-shape-code = 30 or ($number-code-style = '1' and $language-country-code = 2052 )">
  1084.                     <xsl:attribute name="number:transliteration-format">Σ╕Ç</xsl:attribute>
  1085.                     <xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
  1086.                     <xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
  1087.                 </xsl:when>
  1088.                 <!-- Simplified Chinese 2 ([DBNum2]),#1f,#0804 -->
  1089.                 <xsl:when test="$number-shape-code = 31 or ($number-code-style = '2' and $language-country-code = 2052 )">
  1090.                     <xsl:attribute name="number:transliteration-format">σú╣</xsl:attribute>
  1091.                     <xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
  1092.                     <xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
  1093.                 </xsl:when>
  1094.                 <!-- Simplified Chinese 3 ([DBNum3]), #20,#0804 -->
  1095.                 <xsl:when test="$number-shape-code = 32 or ($number-code-style = '3' and $language-country-code = 2052 )">
  1096.                     <xsl:attribute name="number:transliteration-format">∩╝æ</xsl:attribute>
  1097.                     <xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
  1098.                     <xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
  1099.                 </xsl:when>
  1100.                 <!-- Traditional Chinese 1 ([DBNum1]), #21, #0404 -->
  1101.                 <xsl:when test="$number-shape-code = 33 or ($number-code-style = '1' and $language-country-code = 1028 )">
  1102.                     <xsl:attribute name="number:transliteration-format">Σ╕Ç</xsl:attribute>
  1103.                     <xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
  1104.                     <xsl:attribute name="number:transliteration-country">TW</xsl:attribute>
  1105.                 </xsl:when>
  1106.                 <!-- Traditional Chinese 2 ([DBNum2]), #22, #0404 -->
  1107.                 <xsl:when test="$number-shape-code = 34 or ($number-code-style = '2' and $language-country-code = 1028 )">
  1108.                     <xsl:attribute name="number:transliteration-format">σú╣</xsl:attribute>
  1109.                     <xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
  1110.                     <xsl:attribute name="number:transliteration-country">TW</xsl:attribute>
  1111.                 </xsl:when>
  1112.                 <!-- Traditional Chinese 3 ([DBNum3]),#23, #0404  -->
  1113.                 <xsl:when test="$number-shape-code = 35 or ($number-code-style = '3' and $language-country-code = 1028 )">
  1114.                     <xsl:attribute name="number:transliteration-format">∩╝æ</xsl:attribute>
  1115.                     <xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
  1116.                     <xsl:attribute name="number:transliteration-country">TW</xsl:attribute>
  1117.                 </xsl:when>
  1118.                 <!-- Korean 1 ([DBNum1]), #24, #0412 -->
  1119.                 <xsl:when test="$number-shape-code = 36 or ($number-code-style = '1' and $language-country-code = 1042 )">
  1120.                     <xsl:attribute name="number:transliteration-format">Σ╕Ç</xsl:attribute>
  1121.                     <xsl:attribute name="number:transliteration-language">ko</xsl:attribute>
  1122.                     <xsl:attribute name="number:transliteration-country">KR</xsl:attribute>
  1123.                 </xsl:when>
  1124.                 <!-- Korean 2 ([DBNum2]), #25, #0412 -->
  1125.                 <xsl:when test="$number-shape-code = 37 or ($number-code-style = '2' and $language-country-code = 1042 )">
  1126.                     <xsl:attribute name="number:transliteration-format">σú╣</xsl:attribute>
  1127.                     <xsl:attribute name="number:transliteration-language">ko</xsl:attribute>
  1128.                     <xsl:attribute name="number:transliteration-country">KR</xsl:attribute>
  1129.                 </xsl:when>
  1130.                 <!-- Korean 3 ([DBNum3]), #26, #0412 -->
  1131.                 <xsl:when test="$number-shape-code = 38 or ($number-code-style = '3' and $language-country-code = 1042 )">
  1132.                     <xsl:attribute name="number:transliteration-format">∩╝æ</xsl:attribute>
  1133.                     <xsl:attribute name="number:transliteration-language">ko</xsl:attribute>
  1134.                     <xsl:attribute name="number:transliteration-country">KR</xsl:attribute>
  1135.                 </xsl:when>
  1136.                 <!-- Korean 4 ([DBNum4]), #27, #0412 -->
  1137.                 <xsl:when test="$number-shape-code = 39 or ($number-code-style = '4' and $language-country-code = 1042 )">
  1138.                     <xsl:attribute name="number:transliteration-format">1</xsl:attribute>
  1139.                     <xsl:attribute name="number:transliteration-language">ko</xsl:attribute>
  1140.                     <xsl:attribute name="number:transliteration-country">KR</xsl:attribute>
  1141.                 </xsl:when>
  1142.             </xsl:choose>
  1143.         </xsl:if>
  1144.         <!-- components of a format code: two digits  for number shape codes, two for calendar types, four for LCID. glu -->
  1145.         <xsl:choose>
  1146.             <!-- totally 223 language-country LCID codes, manually created, among which MS Office 2003 supports 134, OOo supports 91. glu -->
  1147.             <xsl:when test="$language-country-code = 1078">
  1148.                 <!-- Afrikaans - South Africa, #0436 -->
  1149.                 <xsl:attribute name="number:language">af</xsl:attribute>
  1150.                 <xsl:attribute name="number:country">ZA</xsl:attribute>
  1151.             </xsl:when>
  1152.             <xsl:when test="$language-country-code = 1052">
  1153.                 <!-- Albanian - Albania, #041c -->
  1154.                 <xsl:attribute name="number:language">sq</xsl:attribute>
  1155.                 <xsl:attribute name="number:country">AL</xsl:attribute>
  1156.             </xsl:when>
  1157.             <xsl:when test="$language-country-code = 1118">
  1158.                 <!-- Amharic - Ethiopia, #045e -->
  1159.                 <xsl:attribute name="number:language">am</xsl:attribute>
  1160.                 <xsl:attribute name="number:country">ET</xsl:attribute>
  1161.             </xsl:when>
  1162.             <xsl:when test="$language-country-code = 1025">
  1163.                 <!-- Arabic - Saudi Arabia, #0401 -->
  1164.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1165.                 <xsl:attribute name="number:country">SA</xsl:attribute>
  1166.             </xsl:when>
  1167.             <xsl:when test="$language-country-code = 5121">
  1168.                 <!-- Arabic - Algeria, #1401 -->
  1169.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1170.                 <xsl:attribute name="number:country">DZ</xsl:attribute>
  1171.             </xsl:when>
  1172.             <xsl:when test="$language-country-code = 15361">
  1173.                 <!-- Arabic - Bahrain, #3c01 -->
  1174.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1175.                 <xsl:attribute name="number:country">BH</xsl:attribute>
  1176.             </xsl:when>
  1177.             <xsl:when test="$language-country-code = 3073">
  1178.                 <!-- Arabic - Egypt, #0c01 -->
  1179.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1180.                 <xsl:attribute name="number:country">EG</xsl:attribute>
  1181.             </xsl:when>
  1182.             <xsl:when test="$language-country-code = 2049">
  1183.                 <!-- Arabic - Iraq, #0801 -->
  1184.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1185.                 <xsl:attribute name="number:country">IQ</xsl:attribute>
  1186.             </xsl:when>
  1187.             <xsl:when test="$language-country-code = 11265">
  1188.                 <!-- Arabic - Jordan, #2c01 -->
  1189.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1190.                 <xsl:attribute name="number:country">JO</xsl:attribute>
  1191.             </xsl:when>
  1192.             <xsl:when test="$language-country-code = 13313">
  1193.                 <!-- Arabic - Kuwait, #3401 -->
  1194.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1195.                 <xsl:attribute name="number:country">KW</xsl:attribute>
  1196.             </xsl:when>
  1197.             <xsl:when test="$language-country-code = 12289">
  1198.                 <!-- Arabic - Lebanon, #3001 -->
  1199.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1200.                 <xsl:attribute name="number:country">LB</xsl:attribute>
  1201.             </xsl:when>
  1202.             <xsl:when test="$language-country-code = 4097">
  1203.                 <!-- Arabic - Libya, #1001 -->
  1204.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1205.                 <xsl:attribute name="number:country">LY</xsl:attribute>
  1206.             </xsl:when>
  1207.             <xsl:when test="$language-country-code = 6145">
  1208.                 <!-- Arabic - Morocco, #1801 -->
  1209.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1210.                 <xsl:attribute name="number:country">MA</xsl:attribute>
  1211.             </xsl:when>
  1212.             <xsl:when test="$language-country-code = 8193">
  1213.                 <!-- Arabic - Oman, #2001 -->
  1214.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1215.                 <xsl:attribute name="number:country">OM</xsl:attribute>
  1216.             </xsl:when>
  1217.             <xsl:when test="$language-country-code = 16385">
  1218.                 <!-- Arabic - Qatar, #4001 -->
  1219.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1220.                 <xsl:attribute name="number:country">QA</xsl:attribute>
  1221.             </xsl:when>
  1222.             <xsl:when test="$language-country-code = 10241">
  1223.                 <!-- Arabic - Syria, #2801 -->
  1224.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1225.                 <xsl:attribute name="number:country">SY</xsl:attribute>
  1226.             </xsl:when>
  1227.             <xsl:when test="$language-country-code = 7169">
  1228.                 <!-- Arabic - Tunisia, #1c01 -->
  1229.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1230.                 <xsl:attribute name="number:country">TN</xsl:attribute>
  1231.             </xsl:when>
  1232.             <xsl:when test="$language-country-code = 14337">
  1233.                 <!-- Arabic - U.A.E., #3801 -->
  1234.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1235.                 <xsl:attribute name="number:country">AE</xsl:attribute>
  1236.             </xsl:when>
  1237.             <xsl:when test="$language-country-code = 9217">
  1238.                 <!-- Arabic - Yemen, #2401 -->
  1239.                 <xsl:attribute name="number:language">ar</xsl:attribute>
  1240.                 <xsl:attribute name="number:country">YE</xsl:attribute>
  1241.             </xsl:when>
  1242.             <xsl:when test="$language-country-code = 1067">
  1243.                 <!-- Armenian - Armenia, #042b -->
  1244.                 <xsl:attribute name="number:language">hy</xsl:attribute>
  1245.                 <xsl:attribute name="number:country">AM</xsl:attribute>
  1246.             </xsl:when>
  1247.             <xsl:when test="$language-country-code = 1101">
  1248.                 <!-- Assamese, #044d -->
  1249.                 <xsl:attribute name="number:language">as</xsl:attribute>
  1250.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1251.             </xsl:when>
  1252.             <xsl:when test="$language-country-code = 2092">
  1253.                 <!-- Azeri - Cyrillic, #082c -->
  1254.                 <xsl:attribute name="number:language">az</xsl:attribute>
  1255.                 <xsl:attribute name="number:country">AZ</xsl:attribute>
  1256.             </xsl:when>
  1257.             <xsl:when test="$language-country-code = 1068">
  1258.                 <!-- Azeri - Latin, #042c -->
  1259.                 <xsl:attribute name="number:language">az</xsl:attribute>
  1260.                 <xsl:attribute name="number:country">AZ</xsl:attribute>
  1261.             </xsl:when>
  1262.             <xsl:when test="$language-country-code = 1069">
  1263.                 <!-- Basque - France/Spain, #042d -->
  1264.                 <xsl:attribute name="number:language">eu</xsl:attribute>
  1265.                 <xsl:attribute name="number:country">ES</xsl:attribute>
  1266.             </xsl:when>
  1267.             <xsl:when test="$language-country-code = 1059">
  1268.                 <!-- Belarusian - Belarus, #0423 -->
  1269.                 <xsl:attribute name="number:language">be</xsl:attribute>
  1270.                 <xsl:attribute name="number:country">BY</xsl:attribute>
  1271.             </xsl:when>
  1272.             <xsl:when test="$language-country-code = 1093">
  1273.                 <!-- Bengali (India), #0445 -->
  1274.                 <xsl:attribute name="number:language">bn</xsl:attribute>
  1275.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1276.             </xsl:when>
  1277.             <xsl:when test="$language-country-code = 2117">
  1278.                 <!-- Bengali (Bangladesh), #0845 -->
  1279.                 <xsl:attribute name="number:language">bn</xsl:attribute>
  1280.                 <xsl:attribute name="number:country">BD</xsl:attribute>
  1281.             </xsl:when>
  1282.             <xsl:when test="$language-country-code = 5146">
  1283.                 <!-- Bosnian (Bosnia/Herzegovina), #141a -->
  1284.                 <xsl:attribute name="number:language">bs</xsl:attribute>
  1285.                 <xsl:attribute name="number:country">BA</xsl:attribute>
  1286.             </xsl:when>
  1287.             <xsl:when test="$language-country-code = 1026">
  1288.                 <!-- Bulgarian, #0402 -->
  1289.                 <xsl:attribute name="number:language">bg</xsl:attribute>
  1290.                 <xsl:attribute name="number:country">BG</xsl:attribute>
  1291.             </xsl:when>
  1292.             <xsl:when test="$language-country-code = 1109">
  1293.                 <!-- Burmese (Burma/Myanmar), #0455 -->
  1294.                 <xsl:attribute name="number:language">my</xsl:attribute>
  1295.                 <xsl:attribute name="number:country">MM</xsl:attribute>
  1296.             </xsl:when>
  1297.             <xsl:when test="$language-country-code = 1027">
  1298.                 <!-- Catalan - Spain, #0403 -->
  1299.                 <xsl:attribute name="number:language">ca</xsl:attribute>
  1300.                 <xsl:attribute name="number:country">ES</xsl:attribute>
  1301.             </xsl:when>
  1302.             <xsl:when test="$language-country-code = 1116">
  1303.                 <!-- Cherokee - United States, #045c -->
  1304.                 <xsl:attribute name="number:language">chr</xsl:attribute>
  1305.                 <xsl:attribute name="number:country">US</xsl:attribute>
  1306.             </xsl:when>
  1307.             <xsl:when test="$language-country-code = 2052">
  1308.                 <!-- Chinese - People's Republic of China, #0804 -->
  1309.                 <xsl:attribute name="number:language">zh</xsl:attribute>
  1310.                 <xsl:attribute name="number:country">CN</xsl:attribute>
  1311.             </xsl:when>
  1312.             <xsl:when test="$language-country-code = 4100">
  1313.                 <!-- Chinese - Singapore, #1004 -->
  1314.                 <xsl:attribute name="number:language">zh</xsl:attribute>
  1315.                 <xsl:attribute name="number:country">SG</xsl:attribute>
  1316.             </xsl:when>
  1317.             <xsl:when test="$language-country-code = 1028">
  1318.                 <!-- Chinese - Taiwan, #0404 -->
  1319.                 <xsl:attribute name="number:language">zh</xsl:attribute>
  1320.                 <xsl:attribute name="number:country">TW</xsl:attribute>
  1321.             </xsl:when>
  1322.             <xsl:when test="$language-country-code = 3076">
  1323.                 <!-- Chinese - Hong Kong SAR, #0c04 -->
  1324.                 <xsl:attribute name="number:language">zh</xsl:attribute>
  1325.                 <xsl:attribute name="number:country">HK</xsl:attribute>
  1326.             </xsl:when>
  1327.             <xsl:when test="$language-country-code = 5124">
  1328.                 <!-- Chinese - Macao SAR, #1404 -->
  1329.                 <xsl:attribute name="number:language">zh</xsl:attribute>
  1330.                 <xsl:attribute name="number:country">MO</xsl:attribute>
  1331.             </xsl:when>
  1332.             <xsl:when test="$language-country-code = 1050">
  1333.                 <!-- Croatian (Croatia), #041a -->
  1334.                 <xsl:attribute name="number:language">hr</xsl:attribute>
  1335.                 <xsl:attribute name="number:country">HR</xsl:attribute>
  1336.             </xsl:when>
  1337.             <xsl:when test="$language-country-code = 4122">
  1338.                 <!-- Croatian (Bosnia/Herzegovina), #101a -->
  1339.                 <xsl:attribute name="number:language">hr</xsl:attribute>
  1340.                 <xsl:attribute name="number:country">BA</xsl:attribute>
  1341.             </xsl:when>
  1342.             <xsl:when test="$language-country-code = 1029">
  1343.                 <!-- Czech, #0405 -->
  1344.                 <xsl:attribute name="number:language">cs</xsl:attribute>
  1345.                 <xsl:attribute name="number:country">CZ</xsl:attribute>
  1346.             </xsl:when>
  1347.             <xsl:when test="$language-country-code = 1030">
  1348.                 <!-- Danish, #0406 -->
  1349.                 <xsl:attribute name="number:language">da</xsl:attribute>
  1350.                 <xsl:attribute name="number:country">DK</xsl:attribute>
  1351.             </xsl:when>
  1352.             <xsl:when test="$language-country-code = 1125">
  1353.                 <!-- Divehi, #0465 -->
  1354.                 <xsl:attribute name="number:language">dv</xsl:attribute>
  1355.                 <xsl:attribute name="number:country">MV</xsl:attribute>
  1356.             </xsl:when>
  1357.             <xsl:when test="$language-country-code = 1043">
  1358.                 <!-- Dutch - Netherlands, #0413 -->
  1359.                 <xsl:attribute name="number:language">nl</xsl:attribute>
  1360.                 <xsl:attribute name="number:country">NL</xsl:attribute>
  1361.             </xsl:when>
  1362.             <xsl:when test="$language-country-code = 2067">
  1363.                 <!-- Dutch - Belgium, #0813 -->
  1364.                 <xsl:attribute name="number:language">nl</xsl:attribute>
  1365.                 <xsl:attribute name="number:country">BE</xsl:attribute>
  1366.             </xsl:when>
  1367.             <xsl:when test="$language-country-code = 1126">
  1368.                 <!-- Edo (Bini - Nigeria), #0466 -->
  1369.                 <xsl:attribute name="number:language">bin</xsl:attribute>
  1370.                 <xsl:attribute name="number:country">NG</xsl:attribute>
  1371.             </xsl:when>
  1372.             <xsl:when test="$language-country-code = 1033">
  1373.                 <!-- English - United States, #0409 -->
  1374.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1375.                 <xsl:attribute name="number:country">US</xsl:attribute>
  1376.             </xsl:when>
  1377.             <xsl:when test="$language-country-code = 2057">
  1378.                 <!-- English - United Kingdom, #0809 -->
  1379.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1380.                 <xsl:attribute name="number:country">GB</xsl:attribute>
  1381.             </xsl:when>
  1382.             <xsl:when test="$language-country-code = 3081">
  1383.                 <!-- English - Australia, #0c09 -->
  1384.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1385.                 <xsl:attribute name="number:country">AU</xsl:attribute>
  1386.             </xsl:when>
  1387.             <xsl:when test="$language-country-code = 10249">
  1388.                 <!-- English - Belize, #2809 -->
  1389.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1390.                 <xsl:attribute name="number:country">BZ</xsl:attribute>
  1391.             </xsl:when>
  1392.             <xsl:when test="$language-country-code = 4105">
  1393.                 <!-- English - Canada, #1009 -->
  1394.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1395.                 <xsl:attribute name="number:country">CA</xsl:attribute>
  1396.             </xsl:when>
  1397.             <xsl:when test="$language-country-code = 9225">
  1398.                 <!-- English - Caribbean (Cuba), #2409 -->
  1399.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1400.                 <xsl:attribute name="number:country">CU</xsl:attribute>
  1401.             </xsl:when>
  1402.             <xsl:when test="$language-country-code = 15369">
  1403.                 <!-- English - Hong Kong SAR, #3c09 -->
  1404.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1405.                 <xsl:attribute name="number:country">HK</xsl:attribute>
  1406.             </xsl:when>
  1407.             <xsl:when test="$language-country-code = 16393">
  1408.                 <!-- English - India, #4009 -->
  1409.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1410.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1411.             </xsl:when>
  1412.             <xsl:when test="$language-country-code = 14345">
  1413.                 <!-- English - Indonesia, #3809 -->
  1414.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1415.                 <xsl:attribute name="number:country">ID</xsl:attribute>
  1416.             </xsl:when>
  1417.             <xsl:when test="$language-country-code = 6153">
  1418.                 <!-- English - Ireland, #1809 -->
  1419.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1420.                 <xsl:attribute name="number:country">IE</xsl:attribute>
  1421.             </xsl:when>
  1422.             <xsl:when test="$language-country-code = 8201">
  1423.                 <!-- English - Jamaica, #2009 -->
  1424.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1425.                 <xsl:attribute name="number:country">JM</xsl:attribute>
  1426.             </xsl:when>
  1427.             <xsl:when test="$language-country-code = 17417">
  1428.                 <!-- English - Malaysia, #4409 -->
  1429.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1430.                 <xsl:attribute name="number:country">MY</xsl:attribute>
  1431.             </xsl:when>
  1432.             <xsl:when test="$language-country-code = 5129">
  1433.                 <!-- English - New Zealand, #1409 -->
  1434.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1435.                 <xsl:attribute name="number:country">NZ</xsl:attribute>
  1436.             </xsl:when>
  1437.             <xsl:when test="$language-country-code = 13321">
  1438.                 <!-- English - Philippines, #3409 -->
  1439.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1440.                 <xsl:attribute name="number:country">PH</xsl:attribute>
  1441.             </xsl:when>
  1442.             <xsl:when test="$language-country-code = 18441">
  1443.                 <!-- English - Singapore, #4809 -->
  1444.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1445.                 <xsl:attribute name="number:country">SG</xsl:attribute>
  1446.             </xsl:when>
  1447.             <xsl:when test="$language-country-code = 7177">
  1448.                 <!-- English - South Africa, #1c09 -->
  1449.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1450.                 <xsl:attribute name="number:country">ZA</xsl:attribute>
  1451.             </xsl:when>
  1452.             <xsl:when test="$language-country-code = 11273">
  1453.                 <!-- English - Trinidad, #2c09 -->
  1454.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1455.                 <xsl:attribute name="number:country">TT</xsl:attribute>
  1456.             </xsl:when>
  1457.             <xsl:when test="$language-country-code = 12297">
  1458.                 <!-- English - Zimbabwe, #3009 -->
  1459.                 <xsl:attribute name="number:language">en</xsl:attribute>
  1460.                 <xsl:attribute name="number:country">ZW</xsl:attribute>
  1461.             </xsl:when>
  1462.             <xsl:when test="$language-country-code = 1061">
  1463.                 <!-- Estonian (Estonia), #0425 -->
  1464.                 <xsl:attribute name="number:language">et</xsl:attribute>
  1465.                 <xsl:attribute name="number:country">EE</xsl:attribute>
  1466.             </xsl:when>
  1467.             <xsl:when test="$language-country-code = 1080">
  1468.                 <!-- Faroese (Faroe Islands), #0438 -->
  1469.                 <xsl:attribute name="number:language">fo</xsl:attribute>
  1470.                 <xsl:attribute name="number:country">FO</xsl:attribute>
  1471.             </xsl:when>
  1472.             <xsl:when test="$language-country-code = 1065">
  1473.                 <!-- Farsi (Persian/Iran), #0429 -->
  1474.                 <xsl:attribute name="number:language">fa</xsl:attribute>
  1475.                 <xsl:attribute name="number:country">IR</xsl:attribute>
  1476.             </xsl:when>
  1477.             <xsl:when test="$language-country-code = 1124">
  1478.                 <!-- Filipino (Philippine), #0464 -->
  1479.                 <xsl:attribute name="number:language">phi</xsl:attribute>
  1480.                 <xsl:attribute name="number:country">PH</xsl:attribute>
  1481.             </xsl:when>
  1482.             <xsl:when test="$language-country-code = 1035">
  1483.                 <!-- Finnish, #040b -->
  1484.                 <xsl:attribute name="number:language">fi</xsl:attribute>
  1485.                 <xsl:attribute name="number:country">FI</xsl:attribute>
  1486.             </xsl:when>
  1487.             <xsl:when test="$language-country-code = 1036">
  1488.                 <!-- French - France, #040c -->
  1489.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1490.                 <xsl:attribute name="number:country">FR</xsl:attribute>
  1491.             </xsl:when>
  1492.             <xsl:when test="$language-country-code = 2060">
  1493.                 <!-- French - Belgium, #080c -->
  1494.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1495.                 <xsl:attribute name="number:country">BE</xsl:attribute>
  1496.             </xsl:when>
  1497.             <xsl:when test="$language-country-code = 11276">
  1498.                 <!-- French - Cameroon, #2c0c -->
  1499.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1500.                 <xsl:attribute name="number:country">CM</xsl:attribute>
  1501.             </xsl:when>
  1502.             <xsl:when test="$language-country-code = 3084">
  1503.                 <!-- French - Canada, #0c0c -->
  1504.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1505.                 <xsl:attribute name="number:country">CA</xsl:attribute>
  1506.             </xsl:when>
  1507.             <xsl:when test="$language-country-code = 9228">
  1508.                 <!-- French - Congo, #240c -->
  1509.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1510.                 <xsl:attribute name="number:country">CG</xsl:attribute>
  1511.             </xsl:when>
  1512.             <xsl:when test="$language-country-code = 12300">
  1513.                 <!-- French - Cote d'Ivoire, #300c -->
  1514.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1515.                 <xsl:attribute name="number:country">CI</xsl:attribute>
  1516.             </xsl:when>
  1517.             <xsl:when test="$language-country-code = 15372">
  1518.                 <!-- French - Haiti, #3c0c -->
  1519.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1520.                 <xsl:attribute name="number:country">HT</xsl:attribute>
  1521.             </xsl:when>
  1522.             <xsl:when test="$language-country-code = 5132">
  1523.                 <!-- French - Luxembourg, #140c -->
  1524.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1525.                 <xsl:attribute name="number:country">LU</xsl:attribute>
  1526.             </xsl:when>
  1527.             <xsl:when test="$language-country-code = 13324">
  1528.                 <!-- French - Mali, #340c -->
  1529.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1530.                 <xsl:attribute name="number:country">ML</xsl:attribute>
  1531.             </xsl:when>
  1532.             <xsl:when test="$language-country-code = 6156">
  1533.                 <!-- French - Monaco, #180c -->
  1534.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1535.                 <xsl:attribute name="number:country">MC</xsl:attribute>
  1536.             </xsl:when>
  1537.             <xsl:when test="$language-country-code = 14348">
  1538.                 <!-- French - Morocco, #380c -->
  1539.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1540.                 <xsl:attribute name="number:country">MA</xsl:attribute>
  1541.             </xsl:when>
  1542.             <xsl:when test="$language-country-code = 58380">
  1543.                 <!-- French - North Africa (Algeria), #e40c -->
  1544.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1545.                 <xsl:attribute name="number:country">DZ</xsl:attribute>
  1546.             </xsl:when>
  1547.             <xsl:when test="$language-country-code = 8204">
  1548.                 <!-- French - Reunion, #200c -->
  1549.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1550.                 <xsl:attribute name="number:country">RE</xsl:attribute>
  1551.             </xsl:when>
  1552.             <xsl:when test="$language-country-code = 10252">
  1553.                 <!-- French - Senegal, #280c -->
  1554.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1555.                 <xsl:attribute name="number:country">SN</xsl:attribute>
  1556.             </xsl:when>
  1557.             <xsl:when test="$language-country-code = 4108">
  1558.                 <!-- French - Switzerland, #100c -->
  1559.                 <xsl:attribute name="number:language">fr</xsl:attribute>
  1560.                 <xsl:attribute name="number:country">CH</xsl:attribute>
  1561.             </xsl:when>
  1562.             <xsl:when test="$language-country-code = 1122">
  1563.                 <!-- Frisian - Netherlands, #0462 -->
  1564.                 <xsl:attribute name="number:language">fy</xsl:attribute>
  1565.                 <xsl:attribute name="number:country">NL</xsl:attribute>
  1566.             </xsl:when>
  1567.             <xsl:when test="$language-country-code = 1127">
  1568.                 <!-- Fulfude (Fulah) - Nigeria, #0467 -->
  1569.                 <xsl:attribute name="number:language">ff</xsl:attribute>
  1570.                 <xsl:attribute name="number:country">NG</xsl:attribute>
  1571.             </xsl:when>
  1572.             <xsl:when test="$language-country-code = 1071">
  1573.                 <!-- FYRO Macedonian, #042f -->
  1574.                 <xsl:attribute name="number:language">mk</xsl:attribute>
  1575.                 <xsl:attribute name="number:country">MK</xsl:attribute>
  1576.             </xsl:when>
  1577.             <xsl:when test="$language-country-code = 2108">
  1578.                 <!-- Gaelic (Ireland), #083c -->
  1579.                 <xsl:attribute name="number:language">gd</xsl:attribute>
  1580.                 <xsl:attribute name="number:country">IE</xsl:attribute>
  1581.             </xsl:when>
  1582.             <xsl:when test="$language-country-code = 1084">
  1583.                 <!-- Gaelic (Scotland), #043c -->
  1584.                 <xsl:attribute name="number:language">gd</xsl:attribute>
  1585.                 <xsl:attribute name="number:country">GB</xsl:attribute>
  1586.             </xsl:when>
  1587.             <xsl:when test="$language-country-code = 1110">
  1588.                 <!-- Galician (Gallegan) - Spain, #0456 -->
  1589.                 <xsl:attribute name="number:language">gl</xsl:attribute>
  1590.                 <xsl:attribute name="number:country">ES</xsl:attribute>
  1591.             </xsl:when>
  1592.             <xsl:when test="$language-country-code = 1079">
  1593.                 <!-- Georgian - Georgia, #0437 -->
  1594.                 <xsl:attribute name="number:language">ka</xsl:attribute>
  1595.                 <xsl:attribute name="number:country">GE</xsl:attribute>
  1596.             </xsl:when>
  1597.             <xsl:when test="$language-country-code = 1031">
  1598.                 <!-- German - Germany, #0407 -->
  1599.                 <xsl:attribute name="number:language">de</xsl:attribute>
  1600.                 <xsl:attribute name="number:country">DE</xsl:attribute>
  1601.             </xsl:when>
  1602.             <xsl:when test="$language-country-code = 3079">
  1603.                 <!-- German - Austria, #0c07 -->
  1604.                 <xsl:attribute name="number:language">de</xsl:attribute>
  1605.                 <xsl:attribute name="number:country">AT</xsl:attribute>
  1606.             </xsl:when>
  1607.             <xsl:when test="$language-country-code = 5127">
  1608.                 <!-- German - Liechtenstein, #1407 -->
  1609.                 <xsl:attribute name="number:language">de</xsl:attribute>
  1610.                 <xsl:attribute name="number:country">LI</xsl:attribute>
  1611.             </xsl:when>
  1612.             <xsl:when test="$language-country-code = 4103">
  1613.                 <!-- German - Luxembourg, #1007 -->
  1614.                 <xsl:attribute name="number:language">de</xsl:attribute>
  1615.                 <xsl:attribute name="number:country">LU</xsl:attribute>
  1616.             </xsl:when>
  1617.             <xsl:when test="$language-country-code = 2055">
  1618.                 <!-- German - Switzerland, #0807 -->
  1619.                 <xsl:attribute name="number:language">de</xsl:attribute>
  1620.                 <xsl:attribute name="number:country">CH</xsl:attribute>
  1621.             </xsl:when>
  1622.             <xsl:when test="$language-country-code = 1032">
  1623.                 <!-- Greek, #0408 -->
  1624.                 <xsl:attribute name="number:language">el</xsl:attribute>
  1625.                 <xsl:attribute name="number:country">GR</xsl:attribute>
  1626.             </xsl:when>
  1627.             <xsl:when test="$language-country-code = 1140">
  1628.                 <!-- Guarani - Paraguay, #0474 -->
  1629.                 <xsl:attribute name="number:language">gn</xsl:attribute>
  1630.                 <xsl:attribute name="number:country">PY</xsl:attribute>
  1631.             </xsl:when>
  1632.             <xsl:when test="$language-country-code = 1095">
  1633.                 <!-- Gujarati - India, #0447 -->
  1634.                 <xsl:attribute name="number:language">gu</xsl:attribute>
  1635.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1636.             </xsl:when>
  1637.             <xsl:when test="$language-country-code = 1128">
  1638.                 <!-- Hausa - Nigeria, #0468 -->
  1639.                 <xsl:attribute name="number:language">ha</xsl:attribute>
  1640.                 <xsl:attribute name="number:country">NG</xsl:attribute>
  1641.             </xsl:when>
  1642.             <xsl:when test="$language-country-code = 1141">
  1643.                 <!-- Hawaiian - US, #0475 -->
  1644.                 <xsl:attribute name="number:language">haw</xsl:attribute>
  1645.                 <xsl:attribute name="number:country">US</xsl:attribute>
  1646.             </xsl:when>
  1647.             <xsl:when test="$language-country-code = 1037">
  1648.                 <!-- Hebrew, #040d -->
  1649.                 <xsl:attribute name="number:language">he</xsl:attribute>
  1650.                 <xsl:attribute name="number:country">IL</xsl:attribute>
  1651.             </xsl:when>
  1652.             <xsl:when test="$language-country-code = 1081">
  1653.                 <!-- Hindi (India), #0439 -->
  1654.                 <xsl:attribute name="number:language">hi</xsl:attribute>
  1655.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1656.             </xsl:when>
  1657.             <xsl:when test="$language-country-code = 1038">
  1658.                 <!-- Hungarian - Hungary, #040e -->
  1659.                 <xsl:attribute name="number:language">hu</xsl:attribute>
  1660.                 <xsl:attribute name="number:country">HU</xsl:attribute>
  1661.             </xsl:when>
  1662.             <xsl:when test="$language-country-code = 1129">
  1663.                 <!-- Ibibio (Niger-Kordofanian) - Nigeria, #0469 -->
  1664.                 <xsl:attribute name="number:language">nic</xsl:attribute>
  1665.                 <xsl:attribute name="number:country">NG</xsl:attribute>
  1666.             </xsl:when>
  1667.             <xsl:when test="$language-country-code = 1039">
  1668.                 <!-- Icelandic, #040f -->
  1669.                 <xsl:attribute name="number:language">is</xsl:attribute>
  1670.                 <xsl:attribute name="number:country">IS</xsl:attribute>
  1671.             </xsl:when>
  1672.             <xsl:when test="$language-country-code = 1136">
  1673.                 <!-- Igbo - Nigeria, #0470 -->
  1674.                 <xsl:attribute name="number:language">ig</xsl:attribute>
  1675.                 <xsl:attribute name="number:country">NG</xsl:attribute>
  1676.             </xsl:when>
  1677.             <xsl:when test="$language-country-code = 1057">
  1678.                 <!-- Indonesian, #0421 -->
  1679.                 <xsl:attribute name="number:language">id</xsl:attribute>
  1680.                 <xsl:attribute name="number:country">ID</xsl:attribute>
  1681.             </xsl:when>
  1682.             <xsl:when test="$language-country-code = 1117">
  1683.                 <!-- Inuktitut - US, #045d -->
  1684.                 <xsl:attribute name="number:language">iu</xsl:attribute>
  1685.                 <xsl:attribute name="number:country">US</xsl:attribute>
  1686.             </xsl:when>
  1687.             <xsl:when test="$language-country-code = 1040">
  1688.                 <!-- Italian - Italy, #0410 -->
  1689.                 <xsl:attribute name="number:language">it</xsl:attribute>
  1690.                 <xsl:attribute name="number:country">IT</xsl:attribute>
  1691.             </xsl:when>
  1692.             <xsl:when test="$language-country-code = 2064">
  1693.                 <!-- Italian - Switzerland, #0810 -->
  1694.                 <xsl:attribute name="number:language">it</xsl:attribute>
  1695.                 <xsl:attribute name="number:country">CH</xsl:attribute>
  1696.             </xsl:when>
  1697.             <xsl:when test="$language-country-code = 1041">
  1698.                 <!-- Japanese, #0411 -->
  1699.                 <xsl:attribute name="number:language">ja</xsl:attribute>
  1700.                 <xsl:attribute name="number:country">JP</xsl:attribute>
  1701.             </xsl:when>
  1702.             <xsl:when test="$language-country-code = 1099">
  1703.                 <!-- Kannada (India), #044b -->
  1704.                 <xsl:attribute name="number:language">kn</xsl:attribute>
  1705.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1706.             </xsl:when>
  1707.             <xsl:when test="$language-country-code = 1137">
  1708.                 <!-- Kanuri - Nigeria, #0471 -->
  1709.                 <xsl:attribute name="number:language">kr</xsl:attribute>
  1710.                 <xsl:attribute name="number:country">NG</xsl:attribute>
  1711.             </xsl:when>
  1712.             <xsl:when test="$language-country-code = 2144">
  1713.                 <!-- Kashmiri (India), #0860 -->
  1714.                 <xsl:attribute name="number:language">ks</xsl:attribute>
  1715.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1716.             </xsl:when>
  1717.             <xsl:when test="$language-country-code = 1120">
  1718.                 <!-- Kashmiri (Arabic), #0460 -->
  1719.                 <xsl:attribute name="number:language">ks</xsl:attribute>
  1720.                 <xsl:attribute name="number:country">PK</xsl:attribute>
  1721.             </xsl:when>
  1722.             <xsl:when test="$language-country-code = 1087">
  1723.                 <!-- Kazakh, #043f -->
  1724.                 <xsl:attribute name="number:language">kk</xsl:attribute>
  1725.                 <xsl:attribute name="number:country">KZ</xsl:attribute>
  1726.             </xsl:when>
  1727.             <xsl:when test="$language-country-code = 1107">
  1728.                 <!-- Khmer (Cambodian), #0453 -->
  1729.                 <xsl:attribute name="number:language">km</xsl:attribute>
  1730.                 <xsl:attribute name="number:country">KH</xsl:attribute>
  1731.             </xsl:when>
  1732.             <xsl:when test="$language-country-code = 1111">
  1733.                 <!-- Konkani (India), #0457 -->
  1734.                 <xsl:attribute name="number:language">kok</xsl:attribute>
  1735.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1736.             </xsl:when>
  1737.             <xsl:when test="$language-country-code = 1042">
  1738.                 <!-- Korean, #0412 -->
  1739.                 <xsl:attribute name="number:language">ko</xsl:attribute>
  1740.                 <xsl:attribute name="number:country">KR</xsl:attribute>
  1741.             </xsl:when>
  1742.             <xsl:when test="$language-country-code = 1088">
  1743.                 <!-- Kyrgyz ( Kirgiz / Cyrillic), #0440 -->
  1744.                 <xsl:attribute name="number:language">ky</xsl:attribute>
  1745.                 <xsl:attribute name="number:country">KG</xsl:attribute>
  1746.             </xsl:when>
  1747.             <xsl:when test="$language-country-code = 1108">
  1748.                 <!-- Lao, #0454 -->
  1749.                 <xsl:attribute name="number:language">lo</xsl:attribute>
  1750.                 <xsl:attribute name="number:country">LA</xsl:attribute>
  1751.             </xsl:when>
  1752.             <xsl:when test="$language-country-code = 1142">
  1753.                 <!-- Latin, #0476 -->
  1754.                 <xsl:attribute name="number:language">la</xsl:attribute>
  1755.                 <xsl:attribute name="number:country">IT</xsl:attribute>
  1756.             </xsl:when>
  1757.             <xsl:when test="$language-country-code = 1062">
  1758.                 <!-- Latvian, #0426 -->
  1759.                 <xsl:attribute name="number:language">lv</xsl:attribute>
  1760.                 <xsl:attribute name="number:country">LV</xsl:attribute>
  1761.             </xsl:when>
  1762.             <xsl:when test="$language-country-code = 1063">
  1763.                 <!-- Lithuanian, #0427 -->
  1764.                 <xsl:attribute name="number:language">lt</xsl:attribute>
  1765.                 <xsl:attribute name="number:country">LT</xsl:attribute>
  1766.             </xsl:when>
  1767.             <xsl:when test="$language-country-code = 1086">
  1768.                 <!-- Malay - Malaysia, #043e -->
  1769.                 <xsl:attribute name="number:language">ms</xsl:attribute>
  1770.                 <xsl:attribute name="number:country">MY</xsl:attribute>
  1771.             </xsl:when>
  1772.             <xsl:when test="$language-country-code = 2110">
  1773.                 <!-- Malay - Brunei Darussalam, #083e -->
  1774.                 <xsl:attribute name="number:language">ms</xsl:attribute>
  1775.                 <xsl:attribute name="number:country">BN</xsl:attribute>
  1776.             </xsl:when>
  1777.             <xsl:when test="$language-country-code = 1071">
  1778.                 <!-- Macedonian (FYROM), #042f -->
  1779.                 <xsl:attribute name="number:language">mk</xsl:attribute>
  1780.                 <xsl:attribute name="number:country">MK</xsl:attribute>
  1781.             </xsl:when>
  1782.             <xsl:when test="$language-country-code = 1100">
  1783.                 <!-- Malayalam (India), #044c -->
  1784.                 <xsl:attribute name="number:language">ml</xsl:attribute>
  1785.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1786.             </xsl:when>
  1787.             <xsl:when test="$language-country-code = 1082">
  1788.                 <!-- Maltese, #043a -->
  1789.                 <xsl:attribute name="number:language">mt</xsl:attribute>
  1790.                 <xsl:attribute name="number:country">MT</xsl:attribute>
  1791.             </xsl:when>
  1792.             <xsl:when test="$language-country-code = 1112">
  1793.                 <!-- Manipuri (India), #0458 -->
  1794.                 <xsl:attribute name="number:language">mni</xsl:attribute>
  1795.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1796.             </xsl:when>
  1797.             <xsl:when test="$language-country-code = 1153">
  1798.                 <!-- Maori - New Zealand, #0481 -->
  1799.                 <xsl:attribute name="number:language">mi</xsl:attribute>
  1800.                 <xsl:attribute name="number:country">NZ</xsl:attribute>
  1801.             </xsl:when>
  1802.             <xsl:when test="$language-country-code = 1102">
  1803.                 <!-- Marathi (India), #044e -->
  1804.                 <xsl:attribute name="number:language">mr</xsl:attribute>
  1805.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1806.             </xsl:when>
  1807.             <xsl:when test="$language-country-code = 1104">
  1808.                 <!-- Mongolian (Cyrillic), #0450 -->
  1809.                 <xsl:attribute name="number:language">mn</xsl:attribute>
  1810.                 <xsl:attribute name="number:country">MN</xsl:attribute>
  1811.             </xsl:when>
  1812.             <xsl:when test="$language-country-code = 2128">
  1813.                 <!-- Mongolian (Mongolian), #0850 -->
  1814.                 <xsl:attribute name="number:language">mn</xsl:attribute>
  1815.                 <xsl:attribute name="number:country">CN</xsl:attribute>
  1816.             </xsl:when>
  1817.             <xsl:when test="$language-country-code = 1121">
  1818.                 <!-- Nepali, #0461 -->
  1819.                 <xsl:attribute name="number:language">ne</xsl:attribute>
  1820.                 <xsl:attribute name="number:country">NP</xsl:attribute>
  1821.             </xsl:when>
  1822.             <xsl:when test="$language-country-code = 2145">
  1823.                 <!-- Nepali (India), #0861 -->
  1824.                 <xsl:attribute name="number:language">ne</xsl:attribute>
  1825.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1826.             </xsl:when>
  1827.             <xsl:when test="$language-country-code = 1044">
  1828.                 <!-- Norwegian (Bokmal), #0414 -->
  1829.                 <xsl:attribute name="number:language">nb</xsl:attribute>
  1830.                 <xsl:attribute name="number:country">NO</xsl:attribute>
  1831.             </xsl:when>
  1832.             <xsl:when test="$language-country-code = 2068">
  1833.                 <!-- Norwegian (Nynorsk), #0814 -->
  1834.                 <xsl:attribute name="number:language">nn</xsl:attribute>
  1835.                 <xsl:attribute name="number:country">NO</xsl:attribute>
  1836.             </xsl:when>
  1837.             <xsl:when test="$language-country-code = 1096">
  1838.                 <!-- Oriya (India), #0448 -->
  1839.                 <xsl:attribute name="number:language">or</xsl:attribute>
  1840.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1841.             </xsl:when>
  1842.             <xsl:when test="$language-country-code = 1138">
  1843.                 <!-- Oromo (Ethiopia), #0472 -->
  1844.                 <xsl:attribute name="number:language">om</xsl:attribute>
  1845.                 <xsl:attribute name="number:country">ET</xsl:attribute>
  1846.             </xsl:when>
  1847.             <xsl:when test="$language-country-code = 1145">
  1848.                 <!-- Papiamentu (Netherlands Antilles), #0479 -->
  1849.                 <xsl:attribute name="number:language">pap</xsl:attribute>
  1850.                 <xsl:attribute name="number:country">AN</xsl:attribute>
  1851.             </xsl:when>
  1852.             <xsl:when test="$language-country-code = 1123">
  1853.                 <!-- Pashto (Afghanistan), #0463 -->
  1854.                 <xsl:attribute name="number:language">ps</xsl:attribute>
  1855.                 <xsl:attribute name="number:country">AF</xsl:attribute>
  1856.             </xsl:when>
  1857.             <xsl:when test="$language-country-code = 1045">
  1858.                 <!-- Polish, #0415 -->
  1859.                 <xsl:attribute name="number:language">pl</xsl:attribute>
  1860.                 <xsl:attribute name="number:country">PL</xsl:attribute>
  1861.             </xsl:when>
  1862.             <xsl:when test="$language-country-code = 1046">
  1863.                 <!-- Portuguese - Brazil, #0416 -->
  1864.                 <xsl:attribute name="number:language">pt</xsl:attribute>
  1865.                 <xsl:attribute name="number:country">BR</xsl:attribute>
  1866.             </xsl:when>
  1867.             <xsl:when test="$language-country-code = 2070">
  1868.                 <!-- Portuguese - Portugal, #0816 -->
  1869.                 <xsl:attribute name="number:language">pt</xsl:attribute>
  1870.                 <xsl:attribute name="number:country">PT</xsl:attribute>
  1871.             </xsl:when>
  1872.             <xsl:when test="$language-country-code = 1094">
  1873.                 <!-- Punjabi, #0446 -->
  1874.                 <xsl:attribute name="number:language">pa</xsl:attribute>
  1875.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1876.             </xsl:when>
  1877.             <xsl:when test="$language-country-code = 2118">
  1878.                 <!-- Punjabi (Pakistan), #0846 -->
  1879.                 <xsl:attribute name="number:language">pa</xsl:attribute>
  1880.                 <xsl:attribute name="number:country">PK</xsl:attribute>
  1881.             </xsl:when>
  1882.             <xsl:when test="$language-country-code = 1131">
  1883.                 <!-- Quecha - Blivia, #046b -->
  1884.                 <xsl:attribute name="number:language">qu</xsl:attribute>
  1885.                 <xsl:attribute name="number:country">BO</xsl:attribute>
  1886.             </xsl:when>
  1887.             <xsl:when test="$language-country-code = 2155">
  1888.                 <!-- Quecha - Ecuador, #086b -->
  1889.                 <xsl:attribute name="number:language">qu</xsl:attribute>
  1890.                 <xsl:attribute name="number:country">EC</xsl:attribute>
  1891.             </xsl:when>
  1892.             <xsl:when test="$language-country-code = 3179">
  1893.                 <!-- Quecha - peru, #0c6b -->
  1894.                 <xsl:attribute name="number:language">qu</xsl:attribute>
  1895.                 <xsl:attribute name="number:country">PE</xsl:attribute>
  1896.             </xsl:when>
  1897.             <xsl:when test="$language-country-code = 1047">
  1898.                 <!-- Rhaeto-Romanic (Italy), #0417 -->
  1899.                 <xsl:attribute name="number:language">rm</xsl:attribute>
  1900.                 <xsl:attribute name="number:country">IT</xsl:attribute>
  1901.             </xsl:when>
  1902.             <xsl:when test="$language-country-code = 1048">
  1903.                 <!-- Romanian, #0418 -->
  1904.                 <xsl:attribute name="number:language">ro</xsl:attribute>
  1905.                 <xsl:attribute name="number:country">RO</xsl:attribute>
  1906.             </xsl:when>
  1907.             <xsl:when test="$language-country-code = 2072">
  1908.                 <!-- Romanian - Moldova, #0818 -->
  1909.                 <xsl:attribute name="number:language">ro</xsl:attribute>
  1910.                 <xsl:attribute name="number:country">MD</xsl:attribute>
  1911.             </xsl:when>
  1912.             <xsl:when test="$language-country-code = 1049">
  1913.                 <!-- Russian, #0419 -->
  1914.                 <xsl:attribute name="number:language">ru</xsl:attribute>
  1915.                 <xsl:attribute name="number:country">RU</xsl:attribute>
  1916.             </xsl:when>
  1917.             <xsl:when test="$language-country-code = 2073">
  1918.                 <!-- Russian - Moldova, #0819 -->
  1919.                 <xsl:attribute name="number:language">ru</xsl:attribute>
  1920.                 <xsl:attribute name="number:country">MD</xsl:attribute>
  1921.             </xsl:when>
  1922.             <xsl:when test="$language-country-code = 1083">
  1923.                 <!-- Sami (Lappish), # (Northern Sami - Sweden), #043b -->
  1924.                 <xsl:attribute name="number:language">se</xsl:attribute>
  1925.                 <xsl:attribute name="number:country">SE</xsl:attribute>
  1926.             </xsl:when>
  1927.             <xsl:when test="$language-country-code = 1103">
  1928.                 <!-- Sanskrit (India), #044f -->
  1929.                 <xsl:attribute name="number:language">sa</xsl:attribute>
  1930.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1931.             </xsl:when>
  1932.             <xsl:when test="$language-country-code = 1132">
  1933.                 <!-- Sepedi (Northern Sotho - South Africa), #046c -->
  1934.                 <xsl:attribute name="number:language">nso</xsl:attribute>
  1935.                 <xsl:attribute name="number:country">ZA</xsl:attribute>
  1936.             </xsl:when>
  1937.             <xsl:when test="$language-country-code = 3098">
  1938.                 <!-- Serbian (Cyrillic - Serbia Yugoslavia), #0c1a -->
  1939.                 <xsl:attribute name="number:language">sr</xsl:attribute>
  1940.                 <xsl:attribute name="number:country">YU</xsl:attribute>
  1941.             </xsl:when>
  1942.             <xsl:when test="$language-country-code = 2074">
  1943.                 <!-- Serbian (Latin - Croatia), #081a -->
  1944.                 <xsl:attribute name="number:language">sr</xsl:attribute>
  1945.                 <xsl:attribute name="number:country">HR</xsl:attribute>
  1946.             </xsl:when>
  1947.             <xsl:when test="$language-country-code = 1113">
  1948.                 <!-- Sindhi - India,#0459 -->
  1949.                 <xsl:attribute name="number:language">sd</xsl:attribute>
  1950.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  1951.             </xsl:when>
  1952.             <xsl:when test="$language-country-code = 2137">
  1953.                 <!-- Sindhi - Pakistan, #0859 -->
  1954.                 <xsl:attribute name="number:language">sd</xsl:attribute>
  1955.                 <xsl:attribute name="number:country">PK</xsl:attribute>
  1956.             </xsl:when>
  1957.             <xsl:when test="$language-country-code = 1115">
  1958.                 <!-- Sinhalese - Sri Lanka, #045b -->
  1959.                 <xsl:attribute name="number:language">si</xsl:attribute>
  1960.                 <xsl:attribute name="number:country">LK</xsl:attribute>
  1961.             </xsl:when>
  1962.             <xsl:when test="$language-country-code = 1051">
  1963.                 <!-- Slovak, #041b -->
  1964.                 <xsl:attribute name="number:language">sk</xsl:attribute>
  1965.                 <xsl:attribute name="number:country">SK</xsl:attribute>
  1966.             </xsl:when>
  1967.             <xsl:when test="$language-country-code = 1060">
  1968.                 <!-- Slovenian, #0424 -->
  1969.                 <xsl:attribute name="number:language">sl</xsl:attribute>
  1970.                 <xsl:attribute name="number:country">SI</xsl:attribute>
  1971.             </xsl:when>
  1972.             <xsl:when test="$language-country-code = 1143">
  1973.                 <!-- Somali, #0477 -->
  1974.                 <xsl:attribute name="number:language">so</xsl:attribute>
  1975.                 <xsl:attribute name="number:country">SO</xsl:attribute>
  1976.             </xsl:when>
  1977.             <xsl:when test="$language-country-code = 1070">
  1978.                 <!-- Sorbian, #042e -->
  1979.                 <xsl:attribute name="number:language">wen</xsl:attribute>
  1980.                 <xsl:attribute name="number:country">DE</xsl:attribute>
  1981.             </xsl:when>
  1982.             <xsl:when test="$language-country-code = 3082">
  1983.                 <!-- Spanish - Spain (Modern/International Sort), #0c0a -->
  1984.                 <xsl:attribute name="number:language">es</xsl:attribute>
  1985.                 <xsl:attribute name="number:country">ES</xsl:attribute>
  1986.             </xsl:when>
  1987.             <xsl:when test="$language-country-code = 1034">
  1988.                 <!-- Spanish - Spain (Traditional Sort), #040a -->
  1989.                 <xsl:attribute name="number:language">es</xsl:attribute>
  1990.                 <xsl:attribute name="number:country">ES</xsl:attribute>
  1991.             </xsl:when>
  1992.             <xsl:when test="$language-country-code = 11274">
  1993.                 <!-- Spanish - Argentina, #2c0a -->
  1994.                 <xsl:attribute name="number:language">es</xsl:attribute>
  1995.                 <xsl:attribute name="number:country">AR</xsl:attribute>
  1996.             </xsl:when>
  1997.             <xsl:when test="$language-country-code = 16394">
  1998.                 <!-- Spanish - Bolivia, #400a -->
  1999.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2000.                 <xsl:attribute name="number:country">BO</xsl:attribute>
  2001.             </xsl:when>
  2002.             <xsl:when test="$language-country-code = 13322">
  2003.                 <!-- Spanish - Chile, #340a -->
  2004.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2005.                 <xsl:attribute name="number:country">CL</xsl:attribute>
  2006.             </xsl:when>
  2007.             <xsl:when test="$language-country-code = 9226">
  2008.                 <!-- Spanish - Colombia, #240a -->
  2009.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2010.                 <xsl:attribute name="number:country">CO</xsl:attribute>
  2011.             </xsl:when>
  2012.             <xsl:when test="$language-country-code = 5130">
  2013.                 <!-- Spanish - Costa Rica, #140a -->
  2014.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2015.                 <xsl:attribute name="number:country">CR</xsl:attribute>
  2016.             </xsl:when>
  2017.             <xsl:when test="$language-country-code = 7178">
  2018.                 <!-- Spanish - Dominican Republic, #1c0a -->
  2019.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2020.                 <xsl:attribute name="number:country">DO</xsl:attribute>
  2021.             </xsl:when>
  2022.             <xsl:when test="$language-country-code = 12298">
  2023.                 <!-- Spanish - Ecuador, #300a -->
  2024.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2025.                 <xsl:attribute name="number:country">EC</xsl:attribute>
  2026.             </xsl:when>
  2027.             <xsl:when test="$language-country-code = 17418">
  2028.                 <!-- Spanish - EL Salvador, #440a -->
  2029.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2030.                 <xsl:attribute name="number:country">SV</xsl:attribute>
  2031.             </xsl:when>
  2032.             <xsl:when test="$language-country-code = 4106">
  2033.                 <!-- Spanish - Guatemala, #100a -->
  2034.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2035.                 <xsl:attribute name="number:country">GT</xsl:attribute>
  2036.             </xsl:when>
  2037.             <xsl:when test="$language-country-code = 18442">
  2038.                 <!-- Spanish - Honduras, #480a -->
  2039.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2040.                 <xsl:attribute name="number:country">HN</xsl:attribute>
  2041.             </xsl:when>
  2042.             <xsl:when test="$language-country-code = 58378">
  2043.                 <!-- Spanish - Latin America (Argentina), #e40a -->
  2044.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2045.                 <xsl:attribute name="number:country">AR</xsl:attribute>
  2046.             </xsl:when>
  2047.             <xsl:when test="$language-country-code = 2058">
  2048.                 <!-- Spanish - Mexico, #080a -->
  2049.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2050.                 <xsl:attribute name="number:country">MX</xsl:attribute>
  2051.             </xsl:when>
  2052.             <xsl:when test="$language-country-code = 19466">
  2053.                 <!-- Spanish - Nicaragua, #4c0a -->
  2054.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2055.                 <xsl:attribute name="number:country">NI</xsl:attribute>
  2056.             </xsl:when>
  2057.             <xsl:when test="$language-country-code = 6154">
  2058.                 <!-- Spanish - Panama, #180a -->
  2059.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2060.                 <xsl:attribute name="number:country">PA</xsl:attribute>
  2061.             </xsl:when>
  2062.             <xsl:when test="$language-country-code = 15370">
  2063.                 <!-- Spanish - Paraguay, #3c0a -->
  2064.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2065.                 <xsl:attribute name="number:country">PY</xsl:attribute>
  2066.             </xsl:when>
  2067.             <xsl:when test="$language-country-code = 10250">
  2068.                 <!-- Spanish - Peru, #280a -->
  2069.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2070.                 <xsl:attribute name="number:country">PE</xsl:attribute>
  2071.             </xsl:when>
  2072.             <xsl:when test="$language-country-code = 20490">
  2073.                 <!-- Spanish - Puerto Rico, #500a -->
  2074.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2075.                 <xsl:attribute name="number:country">PR</xsl:attribute>
  2076.             </xsl:when>
  2077.             <xsl:when test="$language-country-code = 21514">
  2078.                 <!-- Spanish - US, #540a -->
  2079.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2080.                 <xsl:attribute name="number:country">US</xsl:attribute>
  2081.             </xsl:when>
  2082.             <xsl:when test="$language-country-code = 14346">
  2083.                 <!-- Spanish - Uruguay, #380a -->
  2084.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2085.                 <xsl:attribute name="number:country">UY</xsl:attribute>
  2086.             </xsl:when>
  2087.             <xsl:when test="$language-country-code = 8202">
  2088.                 <!-- Spanish - Venezuela, #200a -->
  2089.                 <xsl:attribute name="number:language">es</xsl:attribute>
  2090.                 <xsl:attribute name="number:country">VE</xsl:attribute>
  2091.             </xsl:when>
  2092.             <xsl:when test="$language-country-code = 1072">
  2093.                 <!-- Sutu (Ngoni - Tanzania), #0430 -->
  2094.                 <xsl:attribute name="number:language">bnt</xsl:attribute>
  2095.                 <xsl:attribute name="number:country">TZ</xsl:attribute>
  2096.             </xsl:when>
  2097.             <xsl:when test="$language-country-code = 1089">
  2098.                 <!-- Swahili (Tanzania), #0441 -->
  2099.                 <xsl:attribute name="number:language">sw</xsl:attribute>
  2100.                 <xsl:attribute name="number:country">TZ</xsl:attribute>
  2101.             </xsl:when>
  2102.             <xsl:when test="$language-country-code = 1053">
  2103.                 <!-- Swedish (Sweden), #041d -->
  2104.                 <xsl:attribute name="number:language">sv</xsl:attribute>
  2105.                 <xsl:attribute name="number:country">SE</xsl:attribute>
  2106.             </xsl:when>
  2107.             <xsl:when test="$language-country-code = 2077">
  2108.                 <!-- Swedish - Finland, #081d -->
  2109.                 <xsl:attribute name="number:language">sv</xsl:attribute>
  2110.                 <xsl:attribute name="number:country">FI</xsl:attribute>
  2111.             </xsl:when>
  2112.             <xsl:when test="$language-country-code = 1114">
  2113.                 <!-- Syriac (Syria), #045a -->
  2114.                 <xsl:attribute name="number:language">syr</xsl:attribute>
  2115.                 <xsl:attribute name="number:country">SY</xsl:attribute>
  2116.             </xsl:when>
  2117.             <xsl:when test="$language-country-code = 1064">
  2118.                 <!-- Tajik, #0428 -->
  2119.                 <xsl:attribute name="number:language">tg</xsl:attribute>
  2120.                 <xsl:attribute name="number:country">TJ</xsl:attribute>
  2121.             </xsl:when>
  2122.             <xsl:when test="$language-country-code = 1119">
  2123.                 <!-- Tamazight (Arabic), #045f -->
  2124.                 <xsl:attribute name="number:language">ber</xsl:attribute>
  2125.                 <xsl:attribute name="number:country">ML</xsl:attribute>
  2126.             </xsl:when>
  2127.             <xsl:when test="$language-country-code = 2143">
  2128.                 <!-- Tamazight (Latin), #085f -->
  2129.                 <xsl:attribute name="number:language">ber</xsl:attribute>
  2130.                 <xsl:attribute name="number:country">MA</xsl:attribute>
  2131.             </xsl:when>
  2132.             <xsl:when test="$language-country-code = 1097">
  2133.                 <!-- Tamil (India), #0449 -->
  2134.                 <xsl:attribute name="number:language">ta</xsl:attribute>
  2135.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  2136.             </xsl:when>
  2137.             <xsl:when test="$language-country-code = 1092">
  2138.                 <!-- Tatar (Russia), #0444 -->
  2139.                 <xsl:attribute name="number:language">tt</xsl:attribute>
  2140.                 <xsl:attribute name="number:country">RU</xsl:attribute>
  2141.             </xsl:when>
  2142.             <xsl:when test="$language-country-code = 1098">
  2143.                 <!-- Telugu (India), #044a -->
  2144.                 <xsl:attribute name="number:language">te</xsl:attribute>
  2145.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  2146.             </xsl:when>
  2147.             <xsl:when test="$language-country-code = 1054">
  2148.                 <!-- Thai, #041e -->
  2149.                 <xsl:attribute name="number:language">th</xsl:attribute>
  2150.                 <xsl:attribute name="number:country">TH</xsl:attribute>
  2151.             </xsl:when>
  2152.             <xsl:when test="$language-country-code = 2129">
  2153.                 <!-- Tibetan - Bhutan, #0851 -->
  2154.                 <xsl:attribute name="number:language">bo</xsl:attribute>
  2155.                 <xsl:attribute name="number:country">BT</xsl:attribute>
  2156.             </xsl:when>
  2157.             <xsl:when test="$language-country-code = 1105">
  2158.                 <!-- Tibetan - Peoples' Republic of China, #0451 -->
  2159.                 <xsl:attribute name="number:language">bo</xsl:attribute>
  2160.                 <xsl:attribute name="number:country">CN</xsl:attribute>
  2161.             </xsl:when>
  2162.             <xsl:when test="$language-country-code = 2163">
  2163.                 <!-- Tigrigna (Tigrinya) - Eritrea, #0873 -->
  2164.                 <xsl:attribute name="number:language">ti</xsl:attribute>
  2165.                 <xsl:attribute name="number:country">ER</xsl:attribute>
  2166.             </xsl:when>
  2167.             <xsl:when test="$language-country-code = 1139">
  2168.                 <!-- Tigrigna (Tigrinya) - Ethiopia, #0473 -->
  2169.                 <xsl:attribute name="number:language">ti</xsl:attribute>
  2170.                 <xsl:attribute name="number:country">ET</xsl:attribute>
  2171.             </xsl:when>
  2172.             <xsl:when test="$language-country-code = 1073">
  2173.                 <!-- Tsonga (South Africa), #0431 -->
  2174.                 <xsl:attribute name="number:language">ts</xsl:attribute>
  2175.                 <xsl:attribute name="number:country">ZA</xsl:attribute>
  2176.             </xsl:when>
  2177.             <xsl:when test="$language-country-code = 1074">
  2178.                 <!-- Tswana (South Africa), #0432 -->
  2179.                 <xsl:attribute name="number:language">tn</xsl:attribute>
  2180.                 <xsl:attribute name="number:country">ZA</xsl:attribute>
  2181.             </xsl:when>
  2182.             <xsl:when test="$language-country-code = 1055">
  2183.                 <!-- Turkish, #041f -->
  2184.                 <xsl:attribute name="number:language">tr</xsl:attribute>
  2185.                 <xsl:attribute name="number:country">TR</xsl:attribute>
  2186.             </xsl:when>
  2187.             <xsl:when test="$language-country-code = 1090">
  2188.                 <!-- Turkmen, #0442 -->
  2189.                 <xsl:attribute name="number:language">tk</xsl:attribute>
  2190.                 <xsl:attribute name="number:country">TM</xsl:attribute>
  2191.             </xsl:when>
  2192.             <xsl:when test="$language-country-code = 1152">
  2193.                 <!-- Uighur - China, #0480 -->
  2194.                 <xsl:attribute name="number:language">ug</xsl:attribute>
  2195.                 <xsl:attribute name="number:country">CN</xsl:attribute>
  2196.             </xsl:when>
  2197.             <xsl:when test="$language-country-code = 1058">
  2198.                 <!-- Ukrainian, #0422 -->
  2199.                 <xsl:attribute name="number:language">uk</xsl:attribute>
  2200.                 <xsl:attribute name="number:country">UA</xsl:attribute>
  2201.             </xsl:when>
  2202.             <xsl:when test="$language-country-code = 1056">
  2203.                 <!-- Urdu (Pakistan), #0420 -->
  2204.                 <xsl:attribute name="number:language">ur</xsl:attribute>
  2205.                 <xsl:attribute name="number:country">PK</xsl:attribute>
  2206.             </xsl:when>
  2207.             <xsl:when test="$language-country-code = 2080">
  2208.                 <!-- Urdu - India, #0820 -->
  2209.                 <xsl:attribute name="number:language">ur</xsl:attribute>
  2210.                 <xsl:attribute name="number:country">IN</xsl:attribute>
  2211.             </xsl:when>
  2212.             <xsl:when test="$language-country-code = 2115">
  2213.                 <!-- Uzbek (Cyrillic), #0843 -->
  2214.                 <xsl:attribute name="number:language">uz</xsl:attribute>
  2215.                 <xsl:attribute name="number:country">UZ</xsl:attribute>
  2216.             </xsl:when>
  2217.             <xsl:when test="$language-country-code = 1091">
  2218.                 <!-- Uzbek (Latin), #0443 -->
  2219.                 <xsl:attribute name="number:language">uz</xsl:attribute>
  2220.                 <xsl:attribute name="number:country">UZ</xsl:attribute>
  2221.             </xsl:when>
  2222.             <xsl:when test="$language-country-code = 1075">
  2223.                 <!-- Venda (South Africa), #0433 -->
  2224.                 <xsl:attribute name="number:language">ve</xsl:attribute>
  2225.                 <xsl:attribute name="number:country">ZA</xsl:attribute>
  2226.             </xsl:when>
  2227.             <xsl:when test="$language-country-code = 1066">
  2228.                 <!-- Vietnamese, #042a -->
  2229.                 <xsl:attribute name="number:language">vi</xsl:attribute>
  2230.                 <xsl:attribute name="number:country">VN</xsl:attribute>
  2231.             </xsl:when>
  2232.             <xsl:when test="$language-country-code = 1106">
  2233.                 <!-- Welsh (UK), #0452 -->
  2234.                 <xsl:attribute name="number:language">cy</xsl:attribute>
  2235.                 <xsl:attribute name="number:country">UK</xsl:attribute>
  2236.             </xsl:when>
  2237.             <xsl:when test="$language-country-code = 1076">
  2238.                 <!-- Xhosa (South Africa), #0434 -->
  2239.                 <xsl:attribute name="number:language">xh</xsl:attribute>
  2240.                 <xsl:attribute name="number:country">ZA</xsl:attribute>
  2241.             </xsl:when>
  2242.             <xsl:when test="$language-country-code = 1144">
  2243.                 <!-- Yi (Sino-Tibetan - China), #0478 -->
  2244.                 <xsl:attribute name="number:language">sit</xsl:attribute>
  2245.                 <xsl:attribute name="number:country">CN</xsl:attribute>
  2246.             </xsl:when>
  2247.             <xsl:when test="$language-country-code = 1085">
  2248.                 <!-- Yiddish (Jews - Israel), #043d -->
  2249.                 <xsl:attribute name="number:language">yi</xsl:attribute>
  2250.                 <xsl:attribute name="number:country">IL</xsl:attribute>
  2251.             </xsl:when>
  2252.             <xsl:when test="$language-country-code = 1130">
  2253.                 <!-- Yoruba (Nigeria), #046a -->
  2254.                 <xsl:attribute name="number:language">yo</xsl:attribute>
  2255.                 <xsl:attribute name="number:country">NG</xsl:attribute>
  2256.             </xsl:when>
  2257.             <xsl:when test="$language-country-code = 1077">
  2258.                 <!-- Zulu (South Africa), #0435 -->
  2259.                 <xsl:attribute name="number:language">zu</xsl:attribute>
  2260.                 <xsl:attribute name="number:country">ZA</xsl:attribute>
  2261.             </xsl:when>
  2262.         </xsl:choose>
  2263.     </xsl:template>
  2264.     <xsl:template name="get-number-format-condition">
  2265.         <xsl:param name="number-format-unit"/>
  2266.         <xsl:choose>
  2267.             <xsl:when test="contains($number-format-unit, '[>')">
  2268.                 <xsl:value-of select="concat('>', substring-before( substring-after($number-format-unit,'[>'), ']'))"/>
  2269.             </xsl:when>
  2270.             <xsl:when test="contains($number-format-unit, '[<')">
  2271.                 <xsl:value-of select="concat('<', substring-before( substring-after($number-format-unit,'[<'), ']'))"/>
  2272.             </xsl:when>
  2273.             <xsl:when test="contains($number-format-unit, '[=')">
  2274.                 <xsl:value-of select="concat('=', substring-before( substring-after($number-format-unit,'[='), ']'))"/>
  2275.             </xsl:when>
  2276.             <xsl:otherwise/>
  2277.         </xsl:choose>
  2278.     </xsl:template>
  2279.     <xsl:template name="create-number-format-content">
  2280.         <xsl:param name="number-format-unit"/>
  2281.         <xsl:param name="unit-pos"/>
  2282.         <xsl:variable name="posed-number-format-unit" select="substring($number-format-unit,$unit-pos)"/>
  2283.         <xsl:variable name="calendar-type-name">
  2284.             <xsl:if test="contains( $number-format-unit, '[$')">
  2285.                 <xsl:variable name="format-code" select="substring-before( substring-after( substring-after( $number-format-unit, '[$'), '-'), ']')"/>
  2286.                 <xsl:if test="string-length( $format-code) > 4">
  2287.                     <xsl:call-template name="get-calendar-type-name">
  2288.                         <xsl:with-param name="calendar-type" select="substring( $format-code, string-length($format-code) -5, 2)"/>
  2289.                     </xsl:call-template>
  2290.                 </xsl:if>
  2291.             </xsl:if>
  2292.         </xsl:variable>
  2293.         <!-- process number-format-unit by character string parser. -->
  2294.         <xsl:choose>
  2295.             <xsl:when test="starts-with( $posed-number-format-unit, '[$') and (not(starts-with($posed-number-format-unit, '[$-') ) )">
  2296.                 <xsl:element name="number:currency-symbol">
  2297.                     <xsl:call-template name="create-language-country-attribute">
  2298.                         <xsl:with-param name="attribute-code" select="substring-before(substring-after(substring-after($posed-number-format-unit,'[$'),'-'),']')"/>
  2299.                     </xsl:call-template>
  2300.                     <xsl:value-of select="substring-before( substring-after( $posed-number-format-unit, '[$'), '-')"/>
  2301.                 </xsl:element>
  2302.                 <xsl:call-template name="create-number-format-content">
  2303.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2304.                     <xsl:with-param name="unit-pos" select="$unit-pos + string-length( substring-before( $posed-number-format-unit, ']') ) + 1"/>
  2305.                 </xsl:call-template>
  2306.             </xsl:when>
  2307.             <xsl:when test="starts-with( $posed-number-format-unit, '\') or starts-with( $posed-number-format-unit, '*')">
  2308.                 <!-- place '*' temparily here, because now StarCalc doesn't support variable filling character definition. glu -->
  2309.                 <number:text>
  2310.                     <xsl:value-of select="substring($posed-number-format-unit,2,1)"/>
  2311.                 </number:text>
  2312.                 <xsl:call-template name="create-number-format-content">
  2313.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2314.                     <xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
  2315.                 </xsl:call-template>
  2316.             </xsl:when>
  2317.             <xsl:when test="starts-with( $posed-number-format-unit, '_')">
  2318.                 <number:text>
  2319.                     <xsl:text> </xsl:text>
  2320.                 </number:text>
  2321.                 <xsl:call-template name="create-number-format-content">
  2322.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2323.                     <xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
  2324.                 </xsl:call-template>
  2325.             </xsl:when>
  2326.             <xsl:when test="starts-with( $posed-number-format-unit, '"')">
  2327.                 <xsl:variable name="pre-character-string" select="substring-before(substring($posed-number-format-unit,2), '"')"/>
  2328.                 <number:text>
  2329.                     <xsl:value-of select="$pre-character-string"/>
  2330.                 </number:text>
  2331.                 <xsl:call-template name="create-number-format-content">
  2332.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2333.                     <xsl:with-param name="unit-pos" select="$unit-pos + string-length($pre-character-string) + 2"/>
  2334.                 </xsl:call-template>
  2335.             </xsl:when>
  2336.             <xsl:when test="(starts-with( $posed-number-format-unit, '0') or starts-with( $posed-number-format-unit, '#') or starts-with( $posed-number-format-unit, '?') ) and (not ( contains( $posed-number-format-unit, 's.00') ) )">
  2337.                 <xsl:variable name="valid-number-format-string">
  2338.                     <xsl:call-template name="get-valid-number-format-string">
  2339.                         <xsl:with-param name="number-format-unit" select="$posed-number-format-unit"/>
  2340.                     </xsl:call-template>
  2341.                 </xsl:variable>
  2342.                 <xsl:choose>
  2343.                     <xsl:when test="contains( $valid-number-format-string, '/')">
  2344.                         <xsl:element name="number:fraction">
  2345.                             <xsl:attribute name="number:min-integer-digits"><xsl:value-of select="string-length( substring-before($valid-number-format-string, '/') ) - string-length(translate( substring-before($valid-number-format-string, '/'), '0', '') )"/></xsl:attribute>
  2346.                             <xsl:if test="contains( $valid-number-format-string, ',')">
  2347.                                 <xsl:attribute name="number:grouping">true</xsl:attribute>
  2348.                             </xsl:if>
  2349.                             <xsl:attribute name="number:min-numerator-digits"><xsl:value-of select="string-length( substring-before($valid-number-format-string, '/') ) - string-length(translate( substring-before($valid-number-format-string,'/'), '?', '') )"/></xsl:attribute>
  2350.                             <xsl:attribute name="number:min-denominator-digits"><xsl:value-of select="string-length(substring-after($valid-number-format-string, '/') )"/></xsl:attribute>
  2351.                             <!-- deal with number:embedded-text glu -->
  2352.                             <xsl:call-template name="create-number-format-embedded-text">
  2353.                                 <xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
  2354.                                 <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  2355.                             </xsl:call-template>
  2356.                         </xsl:element>
  2357.                     </xsl:when>
  2358.                     <xsl:when test="contains( $valid-number-format-string, '%')">
  2359.                         <xsl:element name="number:number">
  2360.                             <xsl:choose>
  2361.                                 <xsl:when test="contains( $valid-number-format-string, '.')">
  2362.                                     <xsl:attribute name="number:decimal-places"><xsl:value-of select="string-length( substring-before( substring-after( $valid-number-format-string, '.'), '%') ) - string-length( translate( substring-before( substring-after( $valid-number-format-string, '.'), '%'), '0', '') )"/></xsl:attribute>
  2363.                                     <xsl:attribute name="number:min-integer-digits"><xsl:value-of select="string-length( substring-before($valid-number-format-string, '.') ) - string-length(translate( substring-before($valid-number-format-string, '.'), '0', '') )"/></xsl:attribute>
  2364.                                 </xsl:when>
  2365.                                 <xsl:otherwise>
  2366.                                     <xsl:attribute name="number:decimal-places">0</xsl:attribute>
  2367.                                     <xsl:attribute name="number:min-integer-digits"><xsl:value-of select="string-length( substring-before($valid-number-format-string, '%') ) - string-length(translate( substring-before($valid-number-format-string, '%'), '0', '') )"/></xsl:attribute>
  2368.                                 </xsl:otherwise>
  2369.                             </xsl:choose>
  2370.                             <xsl:choose>
  2371.                                 <xsl:when test="contains( $valid-number-format-string, ',') and (not (contains( $valid-number-format-string, ',#') ) )">
  2372.                                     <xsl:variable name="display-factor">
  2373.                                         <xsl:call-template name="get-display-factor">
  2374.                                             <xsl:with-param name="start-number" select="1"/>
  2375.                                             <xsl:with-param name="thousand-count" select="string-length($valid-number-format-string) - string-length( translate($valid-number-format-string, ',', '') )"/>
  2376.                                         </xsl:call-template>
  2377.                                     </xsl:variable>
  2378.                                     <xsl:attribute name="number:display-factor"><xsl:value-of select="$display-factor"/></xsl:attribute>
  2379.                                 </xsl:when>
  2380.                                 <xsl:when test="contains( $valid-number-format-string, ',')">
  2381.                                     <xsl:attribute name="number:grouping">true</xsl:attribute>
  2382.                                 </xsl:when>
  2383.                             </xsl:choose>
  2384.                             <!-- deal with number:embedded-text glu -->
  2385.                             <xsl:call-template name="create-number-format-embedded-text">
  2386.                                 <xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
  2387.                                 <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  2388.                             </xsl:call-template>
  2389.                         </xsl:element>
  2390.                         <number:text>%</number:text>
  2391.                     </xsl:when>
  2392.                     <xsl:when test="contains( $valid-number-format-string, 'E') or contains ($valid-number-format-string, 'e')">
  2393.                         <xsl:element name="number:scientific-number">
  2394.                             <xsl:choose>
  2395.                                 <xsl:when test="contains( $valid-number-format-string, '.')">
  2396.                                     <xsl:attribute name="number:decimal-places"><xsl:value-of select="string-length( substring-before( substring-after( $valid-number-format-string, '.'), 'E') ) - string-length( translate( substring-before( substring-after( $valid-number-format-string, '.'), 'E'), '0', '') )"/></xsl:attribute>
  2397.                                     <xsl:attribute name="number:min-integer-digits"><xsl:value-of select="string-length( substring-before($valid-number-format-string, '.') ) - string-length(translate( substring-before($valid-number-format-string, '.'), '0', '') )"/></xsl:attribute>
  2398.                                 </xsl:when>
  2399.                                 <xsl:otherwise>
  2400.                                     <xsl:attribute name="number:decimal-places">0</xsl:attribute>
  2401.                                     <xsl:attribute name="number:min-integer-digits"><xsl:value-of select="string-length( substring-before($valid-number-format-string, 'E') ) - string-length(translate( substring-before($valid-number-format-string, 'E'), '0', '') )"/></xsl:attribute>
  2402.                                 </xsl:otherwise>
  2403.                             </xsl:choose>
  2404.                             <xsl:attribute name="number:min-exponent-digits"><xsl:value-of select="string-length( substring-after( $valid-number-format-string, 'E') ) - string-length( translate( substring-after( $valid-number-format-string, 'E'), '0', '') )"/></xsl:attribute>
  2405.                             <!-- deal with number:embedded-text glu -->
  2406.                             <xsl:call-template name="create-number-format-embedded-text">
  2407.                                 <xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
  2408.                                 <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  2409.                             </xsl:call-template>
  2410.                         </xsl:element>
  2411.                     </xsl:when>
  2412.                     <xsl:otherwise>
  2413.                         <!-- -normal number format, currency, and accounting, e.g. -->
  2414.                         <xsl:element name="number:number">
  2415.                             <xsl:choose>
  2416.                                 <xsl:when test="contains( $valid-number-format-string, '.')">
  2417.                                     <xsl:attribute name="number:decimal-places"><xsl:value-of select="string-length( substring-after( $valid-number-format-string, '.') ) - string-length( translate( substring-after( $valid-number-format-string, '.'), '0', '') )"/></xsl:attribute>
  2418.                                     <xsl:attribute name="number:min-integer-digits"><xsl:value-of select="string-length( substring-before($valid-number-format-string, '.') ) - string-length(translate( substring-before($valid-number-format-string, '.'), '0', '') )"/></xsl:attribute>
  2419.                                 </xsl:when>
  2420.                                 <xsl:otherwise>
  2421.                                     <xsl:attribute name="number:decimal-places">0</xsl:attribute>
  2422.                                     <xsl:attribute name="number:min-integer-digits"><xsl:value-of select="string-length( $valid-number-format-string ) - string-length(translate( $valid-number-format-string, '0', '') )"/></xsl:attribute>
  2423.                                 </xsl:otherwise>
  2424.                             </xsl:choose>
  2425.                             <xsl:choose>
  2426.                                 <xsl:when test="contains( $valid-number-format-string, ',') and (not (contains( $valid-number-format-string, ',#') ) )">
  2427.                                     <xsl:variable name="display-factor">
  2428.                                         <xsl:call-template name="get-display-factor">
  2429.                                             <xsl:with-param name="start-number" select="1"/>
  2430.                                             <xsl:with-param name="thousand-count" select="string-length($valid-number-format-string) - string-length( translate($valid-number-format-string, ',', '') )"/>
  2431.                                         </xsl:call-template>
  2432.                                     </xsl:variable>
  2433.                                     <xsl:attribute name="number:display-factor"><xsl:value-of select="$display-factor"/></xsl:attribute>
  2434.                                 </xsl:when>
  2435.                                 <xsl:when test="contains( $valid-number-format-string, ',')">
  2436.                                     <xsl:attribute name="number:grouping">true</xsl:attribute>
  2437.                                 </xsl:when>
  2438.                             </xsl:choose>
  2439.                             <!-- deal with number:embedded-text glu -->
  2440.                             <xsl:call-template name="create-number-format-embedded-text">
  2441.                                 <xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
  2442.                                 <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  2443.                             </xsl:call-template>
  2444.                         </xsl:element>
  2445.                     </xsl:otherwise>
  2446.                 </xsl:choose>
  2447.                 <!-- deal with post number:text glu -->
  2448.                 <xsl:variable name="post-number-format-text">
  2449.                     <xsl:call-template name="get-post-number-format-text">
  2450.                         <xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
  2451.                         <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  2452.                     </xsl:call-template>
  2453.                 </xsl:variable>
  2454.                 <xsl:call-template name="create-number-format-content">
  2455.                     <xsl:with-param name="number-format-unit" select="$post-number-format-text"/>
  2456.                     <xsl:with-param name="unit-pos" select="1"/>
  2457.                 </xsl:call-template>
  2458.             </xsl:when>
  2459.             <xsl:when test="starts-with( $posed-number-format-unit, 'ggg')">
  2460.                 <xsl:element name="number:era">
  2461.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2462.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2463.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2464.                     </xsl:if>
  2465.                 </xsl:element>
  2466.                 <xsl:call-template name="create-number-format-content">
  2467.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2468.                     <xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
  2469.                 </xsl:call-template>
  2470.             </xsl:when>
  2471.             <xsl:when test="starts-with( $posed-number-format-unit, 'gg')">
  2472.                 <xsl:element name="number:era">
  2473.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2474.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2475.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2476.                     </xsl:if>
  2477.                 </xsl:element>
  2478.                 <xsl:call-template name="create-number-format-content">
  2479.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2480.                     <xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
  2481.                 </xsl:call-template>
  2482.             </xsl:when>
  2483.             <xsl:when test="starts-with( $posed-number-format-unit, 'g')">
  2484.                 <xsl:element name="number:era">
  2485.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2486.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2487.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2488.                     </xsl:if>
  2489.                 </xsl:element>
  2490.                 <xsl:call-template name="create-number-format-content">
  2491.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2492.                     <xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
  2493.                 </xsl:call-template>
  2494.             </xsl:when>
  2495.             <xsl:when test="starts-with( $posed-number-format-unit, 'ee')">
  2496.                 <xsl:element name="number:year">
  2497.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2498.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2499.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2500.                     </xsl:if>
  2501.                 </xsl:element>
  2502.                 <xsl:call-template name="create-number-format-content">
  2503.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2504.                     <xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
  2505.                 </xsl:call-template>
  2506.             </xsl:when>
  2507.             <xsl:when test="starts-with( $posed-number-format-unit, 'r')">
  2508.                 <xsl:element name="number:year">
  2509.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2510.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2511.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2512.                     </xsl:if>
  2513.                 </xsl:element>
  2514.                 <xsl:call-template name="create-number-format-content">
  2515.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2516.                     <xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
  2517.                 </xsl:call-template>
  2518.             </xsl:when>
  2519.             <xsl:when test="starts-with( $posed-number-format-unit, 'yyyy')">
  2520.                 <xsl:element name="number:year">
  2521.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2522.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2523.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2524.                     </xsl:if>
  2525.                 </xsl:element>
  2526.                 <xsl:call-template name="create-number-format-content">
  2527.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2528.                     <xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
  2529.                 </xsl:call-template>
  2530.             </xsl:when>
  2531.             <xsl:when test="starts-with( $posed-number-format-unit, 'yy')">
  2532.                 <xsl:element name="number:year">
  2533.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2534.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2535.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2536.                     </xsl:if>
  2537.                 </xsl:element>
  2538.                 <xsl:call-template name="create-number-format-content">
  2539.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2540.                     <xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
  2541.                 </xsl:call-template>
  2542.             </xsl:when>
  2543.             <xsl:when test="starts-with( $posed-number-format-unit, 'e') or starts-with( $posed-number-format-unit, 'y')">
  2544.                 <xsl:element name="number:year">
  2545.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2546.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2547.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2548.                     </xsl:if>
  2549.                 </xsl:element>
  2550.                 <xsl:call-template name="create-number-format-content">
  2551.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2552.                     <xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
  2553.                 </xsl:call-template>
  2554.             </xsl:when>
  2555.             <xsl:when test="starts-with( $posed-number-format-unit, 'mmmmm')">
  2556.                 <xsl:element name="number:month">
  2557.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2558.                     <xsl:attribute name="number:textual">true</xsl:attribute>
  2559.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2560.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2561.                     </xsl:if>
  2562.                 </xsl:element>
  2563.                 <xsl:call-template name="create-number-format-content">
  2564.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2565.                     <xsl:with-param name="unit-pos" select="$unit-pos + 5"/>
  2566.                 </xsl:call-template>
  2567.             </xsl:when>
  2568.             <xsl:when test="starts-with( $posed-number-format-unit, 'mmmm')">
  2569.                 <xsl:element name="number:month">
  2570.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2571.                     <xsl:attribute name="number:textual">true</xsl:attribute>
  2572.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2573.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2574.                     </xsl:if>
  2575.                 </xsl:element>
  2576.                 <xsl:call-template name="create-number-format-content">
  2577.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2578.                     <xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
  2579.                 </xsl:call-template>
  2580.             </xsl:when>
  2581.             <xsl:when test="starts-with( $posed-number-format-unit, 'mmm')">
  2582.                 <xsl:element name="number:month">
  2583.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2584.                     <xsl:attribute name="number:textual">true</xsl:attribute>
  2585.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2586.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2587.                     </xsl:if>
  2588.                 </xsl:element>
  2589.                 <xsl:call-template name="create-number-format-content">
  2590.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2591.                     <xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
  2592.                 </xsl:call-template>
  2593.             </xsl:when>
  2594.             <xsl:when test="starts-with( $posed-number-format-unit, '[mm]')">
  2595.                 <xsl:element name="number:minutes">
  2596.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2597.                 </xsl:element>
  2598.                 <xsl:call-template name="create-number-format-content">
  2599.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2600.                     <xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
  2601.                 </xsl:call-template>
  2602.             </xsl:when>
  2603.             <xsl:when test="starts-with( $posed-number-format-unit, '[m]')">
  2604.                 <xsl:element name="number:minutes">
  2605.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2606.                 </xsl:element>
  2607.                 <xsl:call-template name="create-number-format-content">
  2608.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2609.                     <xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
  2610.                 </xsl:call-template>
  2611.             </xsl:when>
  2612.             <xsl:when test="starts-with( $posed-number-format-unit, 'mm') and ( contains( $number-format-unit, 'h') or contains( $posed-number-format-unit, 's') )">
  2613.                 <xsl:element name="number:minutes">
  2614.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2615.                 </xsl:element>
  2616.                 <xsl:call-template name="create-number-format-content">
  2617.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2618.                     <xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
  2619.                 </xsl:call-template>
  2620.             </xsl:when>
  2621.             <xsl:when test="starts-with( $posed-number-format-unit, 'mm')">
  2622.                 <xsl:element name="number:month">
  2623.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2624.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2625.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2626.                     </xsl:if>
  2627.                 </xsl:element>
  2628.                 <xsl:call-template name="create-number-format-content">
  2629.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2630.                     <xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
  2631.                 </xsl:call-template>
  2632.             </xsl:when>
  2633.             <xsl:when test="starts-with( $posed-number-format-unit, 'm') and ( contains( $number-format-unit, 'h') or contains( $posed-number-format-unit, 's') )">
  2634.                 <xsl:element name="number:minutes">
  2635.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2636.                 </xsl:element>
  2637.                 <xsl:call-template name="create-number-format-content">
  2638.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2639.                     <xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
  2640.                 </xsl:call-template>
  2641.             </xsl:when>
  2642.             <xsl:when test="starts-with( $posed-number-format-unit, 'm')">
  2643.                 <xsl:element name="number:month">
  2644.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2645.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2646.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2647.                     </xsl:if>
  2648.                 </xsl:element>
  2649.                 <xsl:call-template name="create-number-format-content">
  2650.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2651.                     <xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
  2652.                 </xsl:call-template>
  2653.             </xsl:when>
  2654.             <xsl:when test="starts-with( $posed-number-format-unit, 'dddd') or starts-with( $posed-number-format-unit, 'aaaa')">
  2655.                 <xsl:element name="number:day-of-week">
  2656.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2657.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2658.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2659.                     </xsl:if>
  2660.                 </xsl:element>
  2661.                 <xsl:call-template name="create-number-format-content">
  2662.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2663.                     <xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
  2664.                 </xsl:call-template>
  2665.             </xsl:when>
  2666.             <xsl:when test="starts-with( $posed-number-format-unit, 'ddd') or starts-with( $posed-number-format-unit, 'aaa')">
  2667.                 <xsl:element name="number:day-of-week">
  2668.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2669.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2670.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2671.                     </xsl:if>
  2672.                 </xsl:element>
  2673.                 <xsl:call-template name="create-number-format-content">
  2674.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2675.                     <xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
  2676.                 </xsl:call-template>
  2677.             </xsl:when>
  2678.             <xsl:when test="starts-with( $posed-number-format-unit, 'dd')">
  2679.                 <xsl:element name="number:day">
  2680.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2681.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2682.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2683.                     </xsl:if>
  2684.                 </xsl:element>
  2685.                 <xsl:call-template name="create-number-format-content">
  2686.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2687.                     <xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
  2688.                 </xsl:call-template>
  2689.             </xsl:when>
  2690.             <xsl:when test="starts-with( $posed-number-format-unit, 'd')">
  2691.                 <xsl:element name="number:day">
  2692.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2693.                     <xsl:if test="string-length($calendar-type-name) > 0">
  2694.                         <xsl:attribute name="number:calendar"><xsl:value-of select="$calendar-type-name"/></xsl:attribute>
  2695.                     </xsl:if>
  2696.                 </xsl:element>
  2697.                 <xsl:call-template name="create-number-format-content">
  2698.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2699.                     <xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
  2700.                 </xsl:call-template>
  2701.             </xsl:when>
  2702.             <xsl:when test="starts-with( $posed-number-format-unit, 'hh')">
  2703.                 <xsl:element name="number:hours">
  2704.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2705.                 </xsl:element>
  2706.                 <xsl:call-template name="create-number-format-content">
  2707.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2708.                     <xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
  2709.                 </xsl:call-template>
  2710.             </xsl:when>
  2711.             <xsl:when test="starts-with( $posed-number-format-unit, '[hh]')">
  2712.                 <xsl:element name="number:hours">
  2713.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2714.                 </xsl:element>
  2715.                 <xsl:call-template name="create-number-format-content">
  2716.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2717.                     <xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
  2718.                 </xsl:call-template>
  2719.             </xsl:when>
  2720.             <xsl:when test="starts-with( $posed-number-format-unit, 'h')">
  2721.                 <xsl:element name="number:hours">
  2722.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2723.                 </xsl:element>
  2724.                 <xsl:call-template name="create-number-format-content">
  2725.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2726.                     <xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
  2727.                 </xsl:call-template>
  2728.             </xsl:when>
  2729.             <xsl:when test="starts-with( $posed-number-format-unit, '[h]')">
  2730.                 <xsl:element name="number:hours">
  2731.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2732.                 </xsl:element>
  2733.                 <xsl:call-template name="create-number-format-content">
  2734.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2735.                     <xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
  2736.                 </xsl:call-template>
  2737.             </xsl:when>
  2738.             <xsl:when test="starts-with( $posed-number-format-unit, 'AM/PM') or starts-with( $posed-number-format-unit, 'am/pm')">
  2739.                 <number:am-pm/>
  2740.                 <!-- long: am-pm doesn't support long style yet. glu -->
  2741.                 <xsl:call-template name="create-number-format-content">
  2742.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2743.                     <xsl:with-param name="unit-pos" select="$unit-pos + 5"/>
  2744.                 </xsl:call-template>
  2745.             </xsl:when>
  2746.             <xsl:when test="starts-with( $posed-number-format-unit, 'a/p'or starts-with( $posed-number-format-unit, 'A/P'))">
  2747.                 <number:am-pm/>
  2748.                 <!-- short: am-pm doesn't support short style yet. glu -->
  2749.                 <xsl:call-template name="create-number-format-content">
  2750.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2751.                     <xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
  2752.                 </xsl:call-template>
  2753.             </xsl:when>
  2754.             <xsl:when test="starts-with( $posed-number-format-unit, 'ss')">
  2755.                 <xsl:variable name="decimal-places">
  2756.                     <xsl:choose>
  2757.                         <xsl:when test="starts-with( $posed-number-format-unit, 'ss.0')">
  2758.                             <xsl:value-of select="string-length( $posed-number-format-unit) - string-length( translate( $posed-number-format-unit, '0', '') )"/>
  2759.                         </xsl:when>
  2760.                         <xsl:otherwise>0</xsl:otherwise>
  2761.                     </xsl:choose>
  2762.                 </xsl:variable>
  2763.                 <xsl:element name="number:seconds">
  2764.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2765.                     <xsl:if test="$decimal-places > 0">
  2766.                         <xsl:attribute name="number:decimal-places"><xsl:value-of select="$decimal-places"/></xsl:attribute>
  2767.                     </xsl:if>
  2768.                 </xsl:element>
  2769.                 <xsl:variable name="second-length">
  2770.                     <xsl:choose>
  2771.                         <xsl:when test="$decimal-places > 0">
  2772.                             <xsl:value-of select="$decimal-places + 3"/>
  2773.                         </xsl:when>
  2774.                         <xsl:otherwise>2</xsl:otherwise>
  2775.                     </xsl:choose>
  2776.                 </xsl:variable>
  2777.                 <xsl:call-template name="create-number-format-content">
  2778.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2779.                     <xsl:with-param name="unit-pos" select="$unit-pos + $second-length"/>
  2780.                 </xsl:call-template>
  2781.             </xsl:when>
  2782.             <xsl:when test="starts-with( $posed-number-format-unit, '[ss]')">
  2783.                 <xsl:element name="number:seconds">
  2784.                     <xsl:attribute name="number:style">long</xsl:attribute>
  2785.                 </xsl:element>
  2786.                 <xsl:call-template name="create-number-format-content">
  2787.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2788.                     <xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
  2789.                 </xsl:call-template>
  2790.             </xsl:when>
  2791.             <xsl:when test="starts-with( $posed-number-format-unit, 's')">
  2792.                 <xsl:variable name="decimal-places">
  2793.                     <xsl:choose>
  2794.                         <xsl:when test="starts-with( $posed-number-format-unit, 's.0')">
  2795.                             <xsl:value-of select="string-length( $posed-number-format-unit) - string-length( translate( $posed-number-format-unit, '0', '') )"/>
  2796.                         </xsl:when>
  2797.                         <xsl:otherwise>0</xsl:otherwise>
  2798.                     </xsl:choose>
  2799.                 </xsl:variable>
  2800.                 <xsl:element name="number:seconds">
  2801.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2802.                     <xsl:if test="$decimal-places > 0">
  2803.                         <xsl:attribute name="number:decimal-places"><xsl:value-of select="$decimal-places"/></xsl:attribute>
  2804.                     </xsl:if>
  2805.                 </xsl:element>
  2806.                 <xsl:variable name="second-length">
  2807.                     <xsl:choose>
  2808.                         <xsl:when test="$decimal-places > 0">
  2809.                             <xsl:value-of select="$decimal-places + 2"/>
  2810.                         </xsl:when>
  2811.                         <xsl:otherwise>1</xsl:otherwise>
  2812.                     </xsl:choose>
  2813.                 </xsl:variable>
  2814.                 <xsl:call-template name="create-number-format-content">
  2815.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2816.                     <xsl:with-param name="unit-pos" select="$unit-pos + $second-length"/>
  2817.                 </xsl:call-template>
  2818.             </xsl:when>
  2819.             <xsl:when test="starts-with( $posed-number-format-unit, '[s]')">
  2820.                 <xsl:element name="number:seconds">
  2821.                     <xsl:attribute name="number:style">short</xsl:attribute>
  2822.                 </xsl:element>
  2823.                 <xsl:call-template name="create-number-format-content">
  2824.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2825.                     <xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
  2826.                 </xsl:call-template>
  2827.             </xsl:when>
  2828.             <xsl:when test="starts-with( $posed-number-format-unit, '@')">
  2829.                 <number:text-content/>
  2830.                 <xsl:call-template name="create-number-format-content">
  2831.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2832.                     <xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
  2833.                 </xsl:call-template>
  2834.             </xsl:when>
  2835.             <!-- old numer-format-unit processing parser, to be deserted. glu -->
  2836.             <xsl:when test="$posed-number-format-unit = 'General' or $posed-number-format-unit = 'General Number'">
  2837.                 <number:number number:decimal-places="0" number:min-integer-digits="1"/>
  2838.             </xsl:when>
  2839.             <xsl:when test="$posed-number-format-unit = 'Fixed'">
  2840.                 <number:number number:decimal-places="2" number:min-integer-digits="1"/>
  2841.                 <number:text/>
  2842.             </xsl:when>
  2843.             <xsl:when test="$posed-number-format-unit = 'Standard'">
  2844.                 <number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
  2845.             </xsl:when>
  2846.             <xsl:when test="$posed-number-format-unit = 'General Date'">
  2847.                 <number:year number:style="long"/>
  2848.                 <number:text>-</number:text>
  2849.                 <number:month number:style="short"/>
  2850.                 <number:text>-</number:text>
  2851.                 <number:day number:style="short"/>
  2852.                 <number:text>
  2853.                     <xsl:text> </xsl:text>
  2854.                 </number:text>
  2855.                 <number:hours number:style="short"/>
  2856.                 <number:text>:</number:text>
  2857.                 <number:minutes number:style="long"/>
  2858.             </xsl:when>
  2859.             <xsl:when test="$posed-number-format-unit = 'Long Date'">
  2860.                 <number:year number:style="long"/>
  2861.                 <number:text>-</number:text>
  2862.                 <number:month number:style="long"/>
  2863.                 <number:text>-</number:text>
  2864.                 <number:day number:style="long"/>
  2865.             </xsl:when>
  2866.             <xsl:when test="$posed-number-format-unit = 'Medium Date'">
  2867.                 <number:day number:style="short"/>
  2868.                 <number:text>-</number:text>
  2869.                 <number:month number:textual="true"/>
  2870.                 <number:text>-</number:text>
  2871.                 <number:year number:style="short"/>
  2872.             </xsl:when>
  2873.             <xsl:when test="$posed-number-format-unit = 'Short Date'">
  2874.                 <number:day number:style="short"/>
  2875.                 <number:text>-</number:text>
  2876.                 <number:month number:style="short"/>
  2877.                 <number:text>-</number:text>
  2878.                 <number:year number:style="short"/>
  2879.             </xsl:when>
  2880.             <xsl:when test="$posed-number-format-unit = 'Long Time'">
  2881.                 <number:hours number:style="long"/>
  2882.                 <number:text>:</number:text>
  2883.                 <number:minutes number:style="long"/>
  2884.                 <number:text>:</number:text>
  2885.                 <number:seconds number:style="long"/>
  2886.                 <number:text>
  2887.                     <xsl:text> </xsl:text>
  2888.                 </number:text>
  2889.                 <number:am-pm/>
  2890.             </xsl:when>
  2891.             <xsl:when test="$posed-number-format-unit = 'Medium Time'">
  2892.                 <number:hours number:style="short"/>
  2893.                 <number:text>:</number:text>
  2894.                 <number:minutes number:style="long"/>
  2895.                 <number:text>
  2896.                     <xsl:text> </xsl:text>
  2897.                 </number:text>
  2898.                 <number:am-pm/>
  2899.             </xsl:when>
  2900.             <xsl:when test="$posed-number-format-unit = 'Short Time'">
  2901.                 <number:hours number:style="short"/>
  2902.                 <number:text>:</number:text>
  2903.                 <number:minutes number:style="long"/>
  2904.                 <number:text>
  2905.                     <xsl:text> </xsl:text>
  2906.                 </number:text>
  2907.             </xsl:when>
  2908.             <xsl:when test="$posed-number-format-unit = 'Percent'">
  2909.                 <number:number number:decimal-places="2" number:min-integer-digits="1"/>
  2910.                 <number:text>%</number:text>
  2911.             </xsl:when>
  2912.             <xsl:when test="$posed-number-format-unit = 'Scientific'">
  2913.                 <number:scientific-number number:decimal-places="2" number:min-integer-digits="1" number:min-exponent-digits="2"/>
  2914.             </xsl:when>
  2915.             <xsl:when test="starts-with( $posed-number-format-unit, '[')">
  2916.                 <xsl:call-template name="create-number-format-content">
  2917.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2918.                     <xsl:with-param name="unit-pos" select="$unit-pos + string-length( substring-before( $posed-number-format-unit, ']') ) + 1"/>
  2919.                 </xsl:call-template>
  2920.             </xsl:when>
  2921.             <xsl:when test="string-length( $posed-number-format-unit ) > 0">
  2922.                 <number:text>
  2923.                     <xsl:value-of select="substring( $posed-number-format-unit, 1, 1)"/>
  2924.                 </number:text>
  2925.                 <xsl:call-template name="create-number-format-content">
  2926.                     <xsl:with-param name="number-format-unit" select="$number-format-unit"/>
  2927.                     <xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
  2928.                 </xsl:call-template>
  2929.             </xsl:when>
  2930.         </xsl:choose>
  2931.     </xsl:template>
  2932.     <xsl:template name="get-calendar-type-name">
  2933.         <xsl:param name="calendar-type"/>
  2934.         <xsl:variable name="temp-type">
  2935.             <xsl:call-template name="hex2decimal">
  2936.                 <xsl:with-param name="hex-number" select="$calendar-type"/>
  2937.                 <xsl:with-param name="index" select="1"/>
  2938.                 <xsl:with-param name="str-length" select="string-length($calendar-type)"/>
  2939.                 <xsl:with-param name="last-value" select="0"/>
  2940.             </xsl:call-template>
  2941.         </xsl:variable>
  2942.         <xsl:choose>
  2943.             <!-- Japanese (Emperor era), #03 -->
  2944.             <xsl:when test="$temp-type = 3">gengou</xsl:when>
  2945.             <!-- Taiwanese, #04 -->
  2946.             <xsl:when test="$temp-type = 4">ROC</xsl:when>
  2947.             <!-- Korean (Tangun era) hanja_yoil is ok too. #05. glu -->
  2948.             <xsl:when test="$temp-type = 5">hanja</xsl:when>
  2949.             <!-- Hijri (Arabic lunar), #06 -->
  2950.             <xsl:when test="$temp-type = 6">hijri</xsl:when>
  2951.             <!-- Thai, #07 -->
  2952.             <xsl:when test="$temp-type = 7">buddhist</xsl:when>
  2953.             <!-- 01: Gregorian (Localized), 02: Gregorian (United States), 09: Gregorian (Middle East French), 0A: Gregorian (Arabic), 0B: Gregorian (Transliterated English) -->
  2954.             <xsl:otherwise>gregorian</xsl:otherwise>
  2955.             <!-- not found jewish yet. glu -->
  2956.         </xsl:choose>
  2957.     </xsl:template>
  2958.     <xsl:template name="get-valid-number-format-string">
  2959.         <xsl:param name="number-format-unit"/>
  2960.         <xsl:choose>
  2961.             <xsl:when test="contains( $number-format-unit, '\')">
  2962.                 <xsl:call-template name="get-valid-number-format-string">
  2963.                     <xsl:with-param name="number-format-unit" select="concat( substring-before( $number-format-unit, '\'), substring( substring-after( $number-format-unit, '\'), 2) )"/>
  2964.                 </xsl:call-template>
  2965.             </xsl:when>
  2966.             <xsl:when test="contains( $number-format-unit, '*')">
  2967.                 <xsl:call-template name="get-valid-number-format-string">
  2968.                     <xsl:with-param name="number-format-unit" select="concat( substring-before( $number-format-unit, '*'), substring( substring-after( $number-format-unit, '*'), 2) )"/>
  2969.                 </xsl:call-template>
  2970.             </xsl:when>
  2971.             <xsl:when test="contains( $number-format-unit, '_')">
  2972.                 <xsl:call-template name="get-valid-number-format-string">
  2973.                     <xsl:with-param name="number-format-unit" select="concat( substring-before( $number-format-unit, '_'), substring( substring-after( $number-format-unit, '_'), 2) )"/>
  2974.                 </xsl:call-template>
  2975.             </xsl:when>
  2976.             <xsl:when test="contains( $number-format-unit, '"')">
  2977.                 <xsl:call-template name="get-valid-number-format-string">
  2978.                     <xsl:with-param name="number-format-unit" select="concat( substring-before( $number-format-unit, '"'), substring-after( substring-after( $number-format-unit, '"'), '"') )"/>
  2979.                 </xsl:call-template>
  2980.             </xsl:when>
  2981.             <xsl:otherwise>
  2982.                 <xsl:value-of select="$number-format-unit"/>
  2983.             </xsl:otherwise>
  2984.         </xsl:choose>
  2985.     </xsl:template>
  2986.     <xsl:template name="get-display-factor">
  2987.         <xsl:param name="start-number"/>
  2988.         <xsl:param name="thousand-count"/>
  2989.         <xsl:choose>
  2990.             <xsl:when test="$thousand-count = 0">
  2991.                 <xsl:value-of select="$start-number"/>
  2992.             </xsl:when>
  2993.             <xsl:otherwise>
  2994.                 <xsl:call-template name="get-display-factor">
  2995.                     <xsl:with-param name="start-number" select="$start-number * 1000"/>
  2996.                     <xsl:with-param name="thousand-count" select="$thousand-count -1"/>
  2997.                 </xsl:call-template>
  2998.             </xsl:otherwise>
  2999.         </xsl:choose>
  3000.     </xsl:template>
  3001.     <xsl:template name="get-post-number-format-text">
  3002.         <xsl:param name="adapted-number-format-unit"/>
  3003.         <xsl:param name="valid-number-format-string"/>
  3004.         <xsl:variable name="first-embedded-character-pos">
  3005.             <xsl:choose>
  3006.                 <xsl:when test="contains( $adapted-number-format-unit, '\')">
  3007.                     <xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '\') ) + 1"/>
  3008.                 </xsl:when>
  3009.                 <xsl:when test="contains( $adapted-number-format-unit, '_')">
  3010.                     <xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '_') ) + 1"/>
  3011.                 </xsl:when>
  3012.                 <xsl:when test="contains( $adapted-number-format-unit, '*')">
  3013.                     <xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '*') ) + 1"/>
  3014.                 </xsl:when>
  3015.                 <xsl:otherwise>0</xsl:otherwise>
  3016.             </xsl:choose>
  3017.         </xsl:variable>
  3018.         <xsl:variable name="first-embedded-string-pos">
  3019.             <xsl:choose>
  3020.                 <xsl:when test="contains( $adapted-number-format-unit, '"')">
  3021.                     <xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '"') ) + 1"/>
  3022.                 </xsl:when>
  3023.                 <xsl:otherwise>0</xsl:otherwise>
  3024.             </xsl:choose>
  3025.         </xsl:variable>
  3026.         <xsl:variable name="first-embedded-text-pos">
  3027.             <xsl:choose>
  3028.                 <xsl:when test="$first-embedded-character-pos < $first-embedded-string-pos and $first-embedded-character-pos > 0">
  3029.                     <xsl:value-of select="$first-embedded-character-pos"/>
  3030.                 </xsl:when>
  3031.                 <xsl:when test="$first-embedded-character-pos < $first-embedded-string-pos and $first-embedded-character-pos = 0">
  3032.                     <xsl:value-of select="$first-embedded-string-pos"/>
  3033.                 </xsl:when>
  3034.                 <xsl:when test="$first-embedded-character-pos > $first-embedded-string-pos and $first-embedded-string-pos > 0">
  3035.                     <xsl:value-of select="$first-embedded-string-pos"/>
  3036.                 </xsl:when>
  3037.                 <xsl:when test="$first-embedded-character-pos > $first-embedded-string-pos and $first-embedded-string-pos = 0">
  3038.                     <xsl:value-of select="$first-embedded-character-pos"/>
  3039.                 </xsl:when>
  3040.             </xsl:choose>
  3041.         </xsl:variable>
  3042.         <xsl:choose>
  3043.             <xsl:when test="$first-embedded-text-pos > string-length( $valid-number-format-string )">
  3044.                 <xsl:value-of select="substring( $adapted-number-format-unit, $first-embedded-text-pos)"/>
  3045.             </xsl:when>
  3046.             <xsl:when test="$first-embedded-text-pos > 0 and $first-embedded-text-pos < string-length( $valid-number-format-string )">
  3047.                 <xsl:choose>
  3048.                     <xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '\')">
  3049.                         <xsl:call-template name="get-post-number-format-text">
  3050.                             <xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '\'), substring( $adapted-number-format-unit, $first-embedded-text-pos + 2) )"/>
  3051.                             <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  3052.                         </xsl:call-template>
  3053.                     </xsl:when>
  3054.                     <xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '_')">
  3055.                         <xsl:call-template name="get-post-number-format-text">
  3056.                             <xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '_'), substring( $adapted-number-format-unit, $first-embedded-text-pos + 2) )"/>
  3057.                             <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  3058.                         </xsl:call-template>
  3059.                     </xsl:when>
  3060.                     <xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '*')">
  3061.                         <xsl:call-template name="get-post-number-format-text">
  3062.                             <xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '*'), substring( $adapted-number-format-unit, $first-embedded-text-pos + 2) )"/>
  3063.                             <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  3064.                         </xsl:call-template>
  3065.                     </xsl:when>
  3066.                     <xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '"')">
  3067.                         <xsl:call-template name="get-post-number-format-text">
  3068.                             <xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '"'), substring-after( substring-after( $adapted-number-format-unit, '"'), '"') )"/>
  3069.                             <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  3070.                         </xsl:call-template>
  3071.                     </xsl:when>
  3072.                 </xsl:choose>
  3073.             </xsl:when>
  3074.             <xsl:otherwise/>
  3075.         </xsl:choose>
  3076.     </xsl:template>
  3077.     <xsl:template name="create-number-format-embedded-text">
  3078.         <xsl:param name="adapted-number-format-unit"/>
  3079.         <xsl:param name="valid-number-format-string"/>
  3080.         <xsl:variable name="first-embedded-character-pos">
  3081.             <xsl:choose>
  3082.                 <xsl:when test="contains( $adapted-number-format-unit, '\')">
  3083.                     <xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '\') ) + 1"/>
  3084.                 </xsl:when>
  3085.                 <xsl:when test="contains( $adapted-number-format-unit, '_')">
  3086.                     <xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '_') ) + 1"/>
  3087.                 </xsl:when>
  3088.                 <xsl:when test="contains( $adapted-number-format-unit, '*')">
  3089.                     <xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '*') ) + 1"/>
  3090.                 </xsl:when>
  3091.                 <xsl:otherwise>0</xsl:otherwise>
  3092.             </xsl:choose>
  3093.         </xsl:variable>
  3094.         <xsl:variable name="first-embedded-string-pos">
  3095.             <xsl:choose>
  3096.                 <xsl:when test="contains( $adapted-number-format-unit, '"')">
  3097.                     <xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '"') ) + 1"/>
  3098.                 </xsl:when>
  3099.                 <xsl:otherwise>0</xsl:otherwise>
  3100.             </xsl:choose>
  3101.         </xsl:variable>
  3102.         <xsl:variable name="first-embedded-text-pos">
  3103.             <xsl:choose>
  3104.                 <xsl:when test="$first-embedded-character-pos < $first-embedded-string-pos and $first-embedded-character-pos > 0">
  3105.                     <xsl:value-of select="$first-embedded-character-pos"/>
  3106.                 </xsl:when>
  3107.                 <xsl:when test="$first-embedded-character-pos < $first-embedded-string-pos and $first-embedded-character-pos = 0">
  3108.                     <xsl:value-of select="$first-embedded-string-pos"/>
  3109.                 </xsl:when>
  3110.                 <xsl:when test="$first-embedded-character-pos > $first-embedded-string-pos and $first-embedded-string-pos > 0">
  3111.                     <xsl:value-of select="$first-embedded-string-pos"/>
  3112.                 </xsl:when>
  3113.                 <xsl:when test="$first-embedded-character-pos > $first-embedded-string-pos and $first-embedded-string-pos = 0">
  3114.                     <xsl:value-of select="$first-embedded-character-pos"/>
  3115.                 </xsl:when>
  3116.             </xsl:choose>
  3117.         </xsl:variable>
  3118.         <xsl:if test="$first-embedded-text-pos > 0 and $first-embedded-text-pos < string-length( $valid-number-format-string )">
  3119.             <xsl:variable name="text-pos">
  3120.                 <xsl:choose>
  3121.                     <xsl:when test="contains( $valid-number-format-string, '.')">
  3122.                         <xsl:variable name="right-text-pos" select="substring( substring-before( $valid-number-format-string, '.'), $first-embedded-text-pos)"/>
  3123.                         <xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
  3124.                     </xsl:when>
  3125.                     <xsl:when test="contains( $valid-number-format-string, '/')">
  3126.                         <xsl:variable name="right-text-pos" select="substring( substring-before( $valid-number-format-string, '/'), $first-embedded-text-pos)"/>
  3127.                         <xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
  3128.                     </xsl:when>
  3129.                     <xsl:when test="contains( $valid-number-format-string, '%')">
  3130.                         <xsl:variable name="right-text-pos" select="substring( substring-before( $valid-number-format-string, '%'), $first-embedded-text-pos)"/>
  3131.                         <xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
  3132.                     </xsl:when>
  3133.                     <xsl:when test="contains( $valid-number-format-string, 'E')">
  3134.                         <xsl:variable name="right-text-pos" select="substring( substring-before( $valid-number-format-string, 'E'), $first-embedded-text-pos)"/>
  3135.                         <xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
  3136.                     </xsl:when>
  3137.                     <xsl:otherwise>
  3138.                         <xsl:variable name="right-text-pos" select="substring( $valid-number-format-string, $first-embedded-text-pos)"/>
  3139.                         <xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
  3140.                     </xsl:otherwise>
  3141.                 </xsl:choose>
  3142.             </xsl:variable>
  3143.             <xsl:choose>
  3144.                 <xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '\')">
  3145.                     <number:embedded-text number:position="{$text-pos}">
  3146.                         <xsl:value-of select="substring( $adapted-number-format-unit, $first-embedded-text-pos + 1, 1)"/>
  3147.                     </number:embedded-text>
  3148.                     <xsl:call-template name="create-number-format-embedded-text">
  3149.                         <xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '\'), substring( $adapted-number-format-unit, $first-embedded-text-pos + 2) )"/>
  3150.                         <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  3151.                     </xsl:call-template>
  3152.                 </xsl:when>
  3153.                 <xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '_')">
  3154.                     <number:embedded-text number:position="{$text-pos}">
  3155.                         <xsl:value-of select="substring( $adapted-number-format-unit, $first-embedded-text-pos + 1, 1)"/>
  3156.                     </number:embedded-text>
  3157.                     <xsl:call-template name="create-number-format-embedded-text">
  3158.                         <xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '_'), substring( $adapted-number-format-unit, $first-embedded-text-pos + 2) )"/>
  3159.                         <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  3160.                     </xsl:call-template>
  3161.                 </xsl:when>
  3162.                 <xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '*')">
  3163.                     <number:embedded-text number:position="{$text-pos}">
  3164.                         <xsl:value-of select="substring( $adapted-number-format-unit, $first-embedded-text-pos + 1, 1)"/>
  3165.                     </number:embedded-text>
  3166.                     <xsl:call-template name="create-number-format-embedded-text">
  3167.                         <xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '*'), substring( $adapted-number-format-unit, $first-embedded-text-pos + 2) )"/>
  3168.                         <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  3169.                     </xsl:call-template>
  3170.                 </xsl:when>
  3171.                 <xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '"')">
  3172.                     <number:embedded-text number:position="{$text-pos}">
  3173.                         <xsl:value-of select="substring-before( substring( $adapted-number-format-unit, $first-embedded-text-pos + 1), '"')"/>
  3174.                     </number:embedded-text>
  3175.                     <xsl:call-template name="create-number-format-embedded-text">
  3176.                         <xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '"'), substring-after( substring-after( $adapted-number-format-unit, '"'), '"') )"/>
  3177.                         <xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
  3178.                     </xsl:call-template>
  3179.                 </xsl:when>
  3180.             </xsl:choose>
  3181.         </xsl:if>
  3182.     </xsl:template>
  3183.     <xsl:template name="create-master-styles">
  3184.         <xsl:param name="worksheetoptions"/>
  3185.         <xsl:for-each select="$worksheetoptions">
  3186.             <xsl:element name="style:master-page">
  3187.                 <xsl:attribute name="style:name"><xsl:value-of select="concat( 'TAB_', ../@ss:Name)"/></xsl:attribute>
  3188.                 <xsl:attribute name="style:page-master-name"><xsl:value-of select="concat( 'pm_', ../@ss:Name)"/></xsl:attribute>
  3189.                 <xsl:choose>
  3190.                     <xsl:when test="x:PageSetup/x:Header/@x:Data">
  3191.                         <style:header>
  3192.                             <xsl:call-template name="translate-header-footer">
  3193.                                 <xsl:with-param name="content" select="x:PageSetup/x:Header/@x:Data"/>
  3194.                                 <xsl:with-param name="style-name-header" select="concat(../@ss:Name, substring(name(x:PageSetup/x:Header),1,1))"/>
  3195.                             </xsl:call-template>
  3196.                         </style:header>
  3197.                     </xsl:when>
  3198.                     <xsl:otherwise>
  3199.                         <style:header style:display="false"/>
  3200.                     </xsl:otherwise>
  3201.                 </xsl:choose>
  3202.                 <xsl:choose>
  3203.                     <xsl:when test="x:PageSetup/x:Footer/@x:Data">
  3204.                         <style:footer>
  3205.                             <xsl:call-template name="translate-header-footer">
  3206.                                 <xsl:with-param name="content" select="x:PageSetup/x:Footer/@x:Data"/>
  3207.                                 <xsl:with-param name="style-name-header" select="concat(../@ss:Name, substring(name(x:PageSetup/x:Footer),1,1))"/>
  3208.                             </xsl:call-template>
  3209.                         </style:footer>
  3210.                     </xsl:when>
  3211.                     <xsl:otherwise>
  3212.                         <style:footer style:display="false"/>
  3213.                     </xsl:otherwise>
  3214.                 </xsl:choose>
  3215.             </xsl:element>
  3216.         </xsl:for-each>
  3217.     </xsl:template>
  3218.     <xsl:template name="translate-header-footer">
  3219.         <xsl:param name="content"/>
  3220.         <xsl:param name="style-name-header"/>
  3221.         <style:region-left>
  3222.             <text:p>
  3223.                 <xsl:variable name="left-content">
  3224.                     <xsl:call-template name="get-pos-content">
  3225.                         <xsl:with-param name="content" select="$content"/>
  3226.                         <xsl:with-param name="pos" select="'left'"/>
  3227.                     </xsl:call-template>
  3228.                 </xsl:variable>
  3229.                 <xsl:call-template name="locate-header-footer-data">
  3230.                     <xsl:with-param name="header-footer-data" select="$left-content"/>
  3231.                     <xsl:with-param name="style-name-header" select="concat($style-name-header,'L')"/>
  3232.                     <xsl:with-param name="index" select="0"/>
  3233.                     <xsl:with-param name="current-pos" select="1"/>
  3234.                 </xsl:call-template>
  3235.             </text:p>
  3236.         </style:region-left>
  3237.         <style:region-center>
  3238.             <text:p>
  3239.                 <xsl:variable name="center-content">
  3240.                     <xsl:call-template name="get-pos-content">
  3241.                         <xsl:with-param name="content" select="$content"/>
  3242.                         <xsl:with-param name="pos" select="'center'"/>
  3243.                     </xsl:call-template>
  3244.                 </xsl:variable>
  3245.                 <xsl:call-template name="locate-header-footer-data">
  3246.                     <xsl:with-param name="header-footer-data" select="$center-content"/>
  3247.                     <xsl:with-param name="style-name-header" select="concat($style-name-header,'C')"/>
  3248.                     <xsl:with-param name="index" select="0"/>
  3249.                     <xsl:with-param name="current-pos" select="1"/>
  3250.                 </xsl:call-template>
  3251.             </text:p>
  3252.         </style:region-center>
  3253.         <style:region-right>
  3254.             <text:p>
  3255.                 <xsl:variable name="right-content">
  3256.                     <xsl:call-template name="get-pos-content">
  3257.                         <xsl:with-param name="content" select="$content"/>
  3258.                         <xsl:with-param name="pos" select="'right'"/>
  3259.                     </xsl:call-template>
  3260.                 </xsl:variable>
  3261.                 <xsl:call-template name="locate-header-footer-data">
  3262.                     <xsl:with-param name="header-footer-data" select="$right-content"/>
  3263.                     <xsl:with-param name="style-name-header" select="concat($style-name-header,'R')"/>
  3264.                     <xsl:with-param name="index" select="0"/>
  3265.                     <xsl:with-param name="current-pos" select="1"/>
  3266.                 </xsl:call-template>
  3267.             </text:p>
  3268.         </style:region-right>
  3269.     </xsl:template>
  3270.     <xsl:template name="locate-header-footer-data">
  3271.         <xsl:param name="header-footer-data"/>
  3272.         <xsl:param name="style-name-header"/>
  3273.         <xsl:param name="index"/>
  3274.         <xsl:param name="current-pos"/>
  3275.         <xsl:variable name="current-style-data">
  3276.             <xsl:value-of select="substring($header-footer-data,$current-pos)"/>
  3277.         </xsl:variable>
  3278.         <xsl:choose>
  3279.             <xsl:when test="starts-with($current-style-data,'&X') or starts-with($current-style-data,'&Y') or starts-with($current-style-data,'&S') or starts-with($current-style-data,'&U') or starts-with($current-style-data,'&E') or starts-with($current-style-data,'&B')">
  3280.                 <xsl:call-template name="locate-header-footer-data">
  3281.                     <xsl:with-param name="header-footer-data" select="$header-footer-data"/>
  3282.                     <xsl:with-param name="style-name-header" select="$style-name-header"/>
  3283.                     <xsl:with-param name="index" select="$index"/>
  3284.                     <xsl:with-param name="current-pos" select="$current-pos+2"/>
  3285.                 </xsl:call-template>
  3286.             </xsl:when>
  3287.             <xsl:when test="starts-with($current-style-data,'&0') or starts-with($current-style-data,'&1') or starts-with($current-style-data,'&2') or starts-with($current-style-data,'&3') or starts-with($current-style-data,'&4') or starts-with($current-style-data,'&5') or starts-with($current-style-data,'&6') or starts-with($current-style-data,'&7') or starts-with($current-style-data,'&8') or starts-with($current-style-data,'&9')">
  3288.                 <xsl:variable name="font-size-length">
  3289.                     <xsl:call-template name="get-digit-length">
  3290.                         <xsl:with-param name="complexive-string" select="substring-after($current-style-data,'&')"/>
  3291.                     </xsl:call-template>
  3292.                 </xsl:variable>
  3293.                 <xsl:call-template name="locate-header-footer-data">
  3294.                     <xsl:with-param name="header-footer-data" select="$header-footer-data"/>
  3295.                     <xsl:with-param name="style-name-header" select="$style-name-header"/>
  3296.                     <xsl:with-param name="index" select="$index"/>
  3297.                     <xsl:with-param name="current-pos" select="$current-pos+1+$font-size-length"/>
  3298.                 </xsl:call-template>
  3299.             </xsl:when>
  3300.             <xsl:when test="starts-with($current-style-data,'&"')">
  3301.                 <xsl:call-template name="locate-header-footer-data">
  3302.                     <xsl:with-param name="header-footer-data" select="$header-footer-data"/>
  3303.                     <xsl:with-param name="style-name-header" select="$style-name-header"/>
  3304.                     <xsl:with-param name="index" select="$index"/>
  3305.                     <xsl:with-param name="current-pos" select="string-length(substring-before(substring($header-footer-data,$current-pos+2),'"'))+$current-pos+3"/>
  3306.                 </xsl:call-template>
  3307.             </xsl:when>
  3308.             <xsl:otherwise>
  3309.                 <xsl:variable name="current-content-last-pos">
  3310.                     <xsl:call-template name="get-current-content-last-pos">
  3311.                         <xsl:with-param name="style-data" select="$header-footer-data"/>
  3312.                         <xsl:with-param name="current-pos" select="$current-pos"/>
  3313.                     </xsl:call-template>
  3314.                 </xsl:variable>
  3315.                 <xsl:choose>
  3316.                     <xsl:when test="$current-pos > 1">
  3317.                         <text:span text:style-name="{concat($style-name-header,$index)}">
  3318.                             <xsl:call-template name="translate-header-footer-data">
  3319.                                 <xsl:with-param name="header-footer-data" select="substring($header-footer-data,$current-pos,$current-content-last-pos+1-$current-pos)"/>
  3320.                             </xsl:call-template>
  3321.                         </text:span>
  3322.                         <xsl:if test="$current-content-last-pos < string-length($header-footer-data)">
  3323.                             <xsl:call-template name="locate-header-footer-data">
  3324.                                 <xsl:with-param name="header-footer-data" select="$header-footer-data"/>
  3325.                                 <xsl:with-param name="style-name-header" select="$style-name-header"/>
  3326.                                 <xsl:with-param name="index" select="$index+1"/>
  3327.                                 <xsl:with-param name="current-pos" select="$current-content-last-pos+1"/>
  3328.                             </xsl:call-template>
  3329.                         </xsl:if>
  3330.                     </xsl:when>
  3331.                     <xsl:otherwise>
  3332.                         <xsl:call-template name="translate-header-footer-data">
  3333.                             <xsl:with-param name="header-footer-data" select="substring($header-footer-data,$current-pos,$current-content-last-pos+1-$current-pos)"/>
  3334.                         </xsl:call-template>
  3335.                         <xsl:if test="$current-content-last-pos < string-length($header-footer-data)">
  3336.                             <xsl:call-template name="locate-header-footer-data">
  3337.                                 <xsl:with-param name="header-footer-data" select="$header-footer-data"/>
  3338.                                 <xsl:with-param name="style-name-header" select="$style-name-header"/>
  3339.                                 <xsl:with-param name="index" select="$index"/>
  3340.                                 <xsl:with-param name="current-pos" select="$current-content-last-pos+1"/>
  3341.                             </xsl:call-template>
  3342.                         </xsl:if>
  3343.                     </xsl:otherwise>
  3344.                 </xsl:choose>
  3345.             </xsl:otherwise>
  3346.         </xsl:choose>
  3347.     </xsl:template>
  3348.     <xsl:template name="get-current-content-last-pos">
  3349.         <xsl:param name="style-data"/>
  3350.         <xsl:param name="current-pos"/>
  3351.         <xsl:variable name="current-style-data">
  3352.             <xsl:value-of select="substring($style-data,$current-pos)"/>
  3353.         </xsl:variable>
  3354.         <xsl:choose>
  3355.             <xsl:when test="starts-with($current-style-data,'&"') or starts-with($current-style-data,'&X') or starts-with($current-style-data,'&Y') or starts-with($current-style-data,'&S') or starts-with($current-style-data,'&U') or starts-with($current-style-data,'&E') or starts-with($current-style-data,'&B')or starts-with($current-style-data,'&0') or starts-with($current-style-data,'&1') or starts-with($current-style-data,'&2') or starts-with($current-style-data,'&3') or starts-with($current-style-data,'&4') or starts-with($current-style-data,'&5') or starts-with($current-style-data,'&6') or starts-with($current-style-data,'&7') or starts-with($current-style-data,'&8') or starts-with($current-style-data,'&9')">
  3356.                 <xsl:value-of select="$current-pos - 1"/>
  3357.             </xsl:when>
  3358.             <xsl:when test="contains($current-style-data,'&"') or contains($current-style-data,'&X') or contains($current-style-data,'&Y') or contains($current-style-data,'&S') or contains($current-style-data,'&U') or contains($current-style-data,'&E') or contains($current-style-data,'&B')or contains($current-style-data,'&0') or contains($current-style-data,'&1') or contains($current-style-data,'&2') or contains($current-style-data,'&3') or contains($current-style-data,'&4') or contains($current-style-data,'&5') or contains($current-style-data,'&6') or contains($current-style-data,'&7') or contains($current-style-data,'&8') or contains($current-style-data,'&9')">
  3359.                 <xsl:variable name="temp" select="substring-before(substring($current-style-data,2),'&')"/>
  3360.                 <xsl:variable name="next-amp-pos">
  3361.                     <xsl:value-of select="$current-pos+string-length($temp)+1"/>
  3362.                 </xsl:variable>
  3363.                 <xsl:call-template name="get-current-content-last-pos">
  3364.                     <xsl:with-param name="style-data" select="$style-data"/>
  3365.                     <xsl:with-param name="current-pos" select="$next-amp-pos"/>
  3366.                 </xsl:call-template>
  3367.             </xsl:when>
  3368.             <xsl:otherwise>
  3369.                 <xsl:value-of select="string-length($style-data)"/>
  3370.             </xsl:otherwise>
  3371.         </xsl:choose>
  3372.     </xsl:template>
  3373.     <xsl:template name="translate-header-footer-data">
  3374.         <xsl:param name="header-footer-data"/>
  3375.         <xsl:choose>
  3376.             <xsl:when test="contains( $header-footer-data, '&D')">
  3377.                 <xsl:call-template name="translate-header-footer-data">
  3378.                     <xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&D')"/>
  3379.                 </xsl:call-template>
  3380.                 <text:date/>
  3381.                 <xsl:call-template name="translate-header-footer-data">
  3382.                     <xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&D')"/>
  3383.                 </xsl:call-template>
  3384.             </xsl:when>
  3385.             <xsl:when test="contains( $header-footer-data, '&T')">
  3386.                 <xsl:call-template name="translate-header-footer-data">
  3387.                     <xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&T')"/>
  3388.                 </xsl:call-template>
  3389.                 <text:time/>
  3390.                 <xsl:call-template name="translate-header-footer-data">
  3391.                     <xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&T')"/>
  3392.                 </xsl:call-template>
  3393.             </xsl:when>
  3394.             <xsl:when test="contains( $header-footer-data, '&P')">
  3395.                 <xsl:call-template name="translate-header-footer-data">
  3396.                     <xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&P')"/>
  3397.                 </xsl:call-template>
  3398.                 <text:page-number/>
  3399.                 <xsl:call-template name="translate-header-footer-data">
  3400.                     <xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&P')"/>
  3401.                 </xsl:call-template>
  3402.             </xsl:when>
  3403.             <xsl:when test="contains( $header-footer-data, '&N')">
  3404.                 <xsl:call-template name="translate-header-footer-data">
  3405.                     <xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&N')"/>
  3406.                 </xsl:call-template>
  3407.                 <text:page-count/>
  3408.                 <xsl:call-template name="translate-header-footer-data">
  3409.                     <xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&N')"/>
  3410.                 </xsl:call-template>
  3411.             </xsl:when>
  3412.             <xsl:when test="contains( $header-footer-data, '&A')">
  3413.                 <xsl:call-template name="translate-header-footer-data">
  3414.                     <xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&A')"/>
  3415.                 </xsl:call-template>
  3416.                 <text:sheet-name/>
  3417.                 <xsl:call-template name="translate-header-footer-data">
  3418.                     <xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&A')"/>
  3419.                 </xsl:call-template>
  3420.             </xsl:when>
  3421.             <xsl:when test="contains( $header-footer-data, '&Z&F')">
  3422.                 <xsl:call-template name="translate-header-footer-data">
  3423.                     <xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&Z&F')"/>
  3424.                 </xsl:call-template>
  3425.                 <text:file-name text:display="full"/>
  3426.                 <xsl:call-template name="translate-header-footer-data">
  3427.                     <xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&Z&F')"/>
  3428.                 </xsl:call-template>
  3429.             </xsl:when>
  3430.             <xsl:when test="contains( $header-footer-data, '&Z')">
  3431.                 <xsl:call-template name="translate-header-footer-data">
  3432.                     <xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&Z')"/>
  3433.                 </xsl:call-template>
  3434.                 <text:file-name text:display="path"/>
  3435.                 <xsl:call-template name="translate-header-footer-data">
  3436.                     <xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&Z')"/>
  3437.                 </xsl:call-template>
  3438.             </xsl:when>
  3439.             <xsl:when test="contains( $header-footer-data, '&F')">
  3440.                 <xsl:call-template name="translate-header-footer-data">
  3441.                     <xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&F')"/>
  3442.                 </xsl:call-template>
  3443.                 <text:file-name text:display="name"/>
  3444.                 <xsl:call-template name="translate-header-footer-data">
  3445.                     <xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&F')"/>
  3446.                 </xsl:call-template>
  3447.             </xsl:when>
  3448.             <xsl:otherwise>
  3449.                 <xsl:value-of select="$header-footer-data"/>
  3450.             </xsl:otherwise>
  3451.         </xsl:choose>
  3452.     </xsl:template>
  3453.     <xsl:template name="create-page-master">
  3454.         <xsl:param name="worksheetoptions"/>
  3455.         <xsl:for-each select="$worksheetoptions">
  3456.             <xsl:element name="style:page-master">
  3457.                 <xsl:attribute name="style:name"><xsl:value-of select="concat( 'pm_', ../@ss:Name)"/></xsl:attribute>
  3458.                 <xsl:element name="style:properties">
  3459.                     <xsl:choose>
  3460.                         <xsl:when test="x:PageSetup/x:Layout/@x:Orientation = 'Landscape'">
  3461.                             <xsl:attribute name="style:print-orientation">landscape</xsl:attribute>
  3462.                         </xsl:when>
  3463.                         <xsl:otherwise>
  3464.                             <xsl:attribute name="style:print-orientation">portrait</xsl:attribute>
  3465.                         </xsl:otherwise>
  3466.                     </xsl:choose>
  3467.                     <xsl:choose>
  3468.                         <xsl:when test="x:PageSetup/x:Layout/@x:StartPageNumber">
  3469.                             <xsl:attribute name="style:first-page-number"><xsl:value-of select="x:PageSetup/x:Layout/@x:StartPageNumber"/></xsl:attribute>
  3470.                         </xsl:when>
  3471.                         <xsl:otherwise>
  3472.                             <xsl:attribute name="style:first-page-number">continue</xsl:attribute>
  3473.                         </xsl:otherwise>
  3474.                     </xsl:choose>
  3475.                     <xsl:if test="x:PageSetup/x:PageMargins">
  3476.                         <xsl:attribute name="fo:margin-top"><xsl:value-of select="format-number( x:PageSetup/x:PageMargins/@x:Top * 2.54, '0.###cm')"/></xsl:attribute>
  3477.                         <xsl:attribute name="fo:margin-bottom"><xsl:value-of select="format-number( x:PageSetup/x:PageMargins/@x:Bottom * 2.54, '0.###cm')"/></xsl:attribute>
  3478.                         <xsl:attribute name="fo:margin-left"><xsl:value-of select="format-number( x:PageSetup/x:PageMargins/@x:Left * 2.54, '0.###cm')"/></xsl:attribute>
  3479.                         <xsl:attribute name="fo:margin-right"><xsl:value-of select="format-number( x:PageSetup/x:PageMargins/@x:Right * 2.54, '0.###cm')"/></xsl:attribute>
  3480.                     </xsl:if>
  3481.                 </xsl:element>
  3482.                 <xsl:if test="x:PageSetup/x:Header">
  3483.                     <style:header-style>
  3484.                         <xsl:element name="style:properties">
  3485.                             <xsl:attribute name="fo:min-height">0.75cm</xsl:attribute>
  3486.                             <xsl:choose>
  3487.                                 <xsl:when test="x:PageSetup/x:Header/@x:Margin">
  3488.                                     <xsl:attribute name="fo:margin-bottom"><xsl:value-of select="format-number( x:PageSetup/x:Header/@x:Margin * 2.54, '0.###cm')"/></xsl:attribute>
  3489.                                 </xsl:when>
  3490.                                 <xsl:otherwise>
  3491.                                     <xsl:attribute name="fo:margin-bottom">0.25cm</xsl:attribute>
  3492.                                 </xsl:otherwise>
  3493.                             </xsl:choose>
  3494.                         </xsl:element>
  3495.                     </style:header-style>
  3496.                 </xsl:if>
  3497.                 <xsl:if test="x:PageSetup/x:Footer">
  3498.                     <style:footer-style>
  3499.                         <xsl:element name="style:properties">
  3500.                             <xsl:attribute name="fo:min-height">0.75cm</xsl:attribute>
  3501.                             <xsl:choose>
  3502.                                 <xsl:when test="x:PageSetup/x:Footer/@x:Margin">
  3503.                                     <xsl:attribute name="fo:margin-top"><xsl:value-of select="format-number( x:PageSetup/x:Footer/@x:Margin * 2.54, '0.###cm')"/></xsl:attribute>
  3504.                                 </xsl:when>
  3505.                                 <xsl:otherwise>
  3506.                                     <xsl:attribute name="fo:margin-top">0.25cm</xsl:attribute>
  3507.                                 </xsl:otherwise>
  3508.                             </xsl:choose>
  3509.                         </xsl:element>
  3510.                     </style:footer-style>
  3511.                 </xsl:if>
  3512.             </xsl:element>
  3513.         </xsl:for-each>
  3514.     </xsl:template>
  3515.     <xsl:template match="ss:Style">
  3516.         <xsl:element name="style:style">
  3517.             <xsl:attribute name="style:name"><xsl:value-of select="@ss:ID"/></xsl:attribute>
  3518.             <!-- @ss:Name is optional, so just ust ss:ID as the default name. glu -->
  3519.             <xsl:attribute name="style:family">table-cell</xsl:attribute>
  3520.             <xsl:choose>
  3521.                 <xsl:when test="@ss:Parent">
  3522.                     <xsl:attribute name="style:parent-style-name"><xsl:value-of select="@ss:Parent"/></xsl:attribute>
  3523.                 </xsl:when>
  3524.                 <xsl:otherwise>
  3525.                     <xsl:attribute name="style:parent-style-name">Default</xsl:attribute>
  3526.                 </xsl:otherwise>
  3527.             </xsl:choose>
  3528.             <xsl:if test="ss:NumberFormat/@ss:Format">
  3529.                 <xsl:attribute name="style:data-style-name"><xsl:value-of select="concat( @ss:ID, 'F')"/></xsl:attribute>
  3530.             </xsl:if>
  3531.             <xsl:element name="style:properties">
  3532.                 <xsl:if test="ss:Alignment">
  3533.                     <xsl:if test="ss:Alignment/@ss:Horizontal">
  3534.                         <xsl:variable name="text-align">
  3535.                             <xsl:choose>
  3536.                                 <xsl:when test="ss:Alignment/@ss:Horizontal = 'Left'">start</xsl:when>
  3537.                                 <xsl:when test="ss:Alignment/@ss:Horizontal = 'Center'">center</xsl:when>
  3538.                                 <xsl:when test="ss:Alignment/@ss:Horizontal = 'Right'">end</xsl:when>
  3539.                                 <xsl:when test="ss:Alignment/@ss:Horizontal = 'Justify'">justify</xsl:when>
  3540.                                 <!-- many other text-align not supported yet. glu -->
  3541.                                 <xsl:otherwise>start</xsl:otherwise>
  3542.                             </xsl:choose>
  3543.                         </xsl:variable>
  3544.                         <xsl:attribute name="fo:text-align"><xsl:value-of select="$text-align"/></xsl:attribute>
  3545.                         <xsl:attribute name="style:text-align-source">fix</xsl:attribute>
  3546.                     </xsl:if>
  3547.                     <xsl:if test="ss:Alignment/@ss:Vertical">
  3548.                         <xsl:variable name="vertical-align">
  3549.                             <xsl:choose>
  3550.                                 <xsl:when test="ss:Alignment/@ss:Vertical = 'Top'">top</xsl:when>
  3551.                                 <xsl:when test="ss:Alignment/@ss:Vertical = 'Center'">middle</xsl:when>
  3552.                                 <xsl:when test="ss:Alignment/@ss:Vertical = 'Bottom'">bottom</xsl:when>
  3553.                                 <xsl:when test="ss:Alignment/@ss:Vertical = 'Automatic'">middle</xsl:when>
  3554.                                 <!-- actually for vertical writen characters, not supported by StarOffice/OpenOffice now yet. glu -->
  3555.                                 <xsl:otherwise>middle</xsl:otherwise>
  3556.                             </xsl:choose>
  3557.                         </xsl:variable>
  3558.                         <xsl:attribute name="fo:vertical-align"><xsl:value-of select="$vertical-align"/></xsl:attribute>
  3559.                     </xsl:if>
  3560.                     <xsl:if test="ss:Alignment/@ss:WrapText = '1'">
  3561.                         <xsl:attribute name="fo:wrap-option">wrap</xsl:attribute>
  3562.                     </xsl:if>
  3563.                     <xsl:if test="ss:Alignment/@ss:Indent">
  3564.                         <xsl:attribute name="fo:margin-left"><xsl:value-of select="concat( floor( ss:Alignment/@ss:Indent div 2.834  * 1000) div 1000, 'cm')"/></xsl:attribute>
  3565.                     </xsl:if>
  3566.                     <xsl:if test="ss:Alignment/@ss:Rotate">
  3567.                         <xsl:attribute name="style:rotation-angle"><xsl:value-of select="ss:Alignment/@ss:Rotate"/></xsl:attribute>
  3568.                         <xsl:attribute name="style:rotation-align">none</xsl:attribute>
  3569.                     </xsl:if>
  3570.                     <xsl:if test="ss:Alignment/@ss:VerticalText = '1'">
  3571.                         <xsl:attribute name="fo:direction">ttb</xsl:attribute>
  3572.                     </xsl:if>
  3573.                 </xsl:if>
  3574.                 <xsl:if test="ss:Borders">
  3575.                     <xsl:if test="ss:Borders/ss:Border">
  3576.                         <xsl:apply-templates select="ss:Borders/ss:Border"/>
  3577.                     </xsl:if>
  3578.                 </xsl:if>
  3579.                 <xsl:if test="ss:Font">
  3580.                     <xsl:choose>
  3581.                         <xsl:when test="ss:Font/@ss:FontName">
  3582.                             <xsl:attribute name="style:font-name"><xsl:value-of select="ss:Font/@ss:FontName"/></xsl:attribute>
  3583.                             <xsl:attribute name="style:font-name-asian"><xsl:value-of select="ss:Font/@ss:FontName"/></xsl:attribute>
  3584.                             <xsl:attribute name="style:font-name-complex"><xsl:value-of select="ss:Font/@ss:FontName"/></xsl:attribute>
  3585.                         </xsl:when>
  3586.                         <xsl:otherwise>
  3587.                             <xsl:attribute name="style:font-name">Arial</xsl:attribute>
  3588.                         </xsl:otherwise>
  3589.                     </xsl:choose>
  3590.                     <!-- "ss:Font/@x:Family" is useless here, so can't map to "fo:font-family" attribute. glu -->
  3591.                     <xsl:if test="ss:Font/@ss:Bold = '1'">
  3592.                         <xsl:attribute name="fo:font-weight">bold</xsl:attribute>
  3593.                         <xsl:attribute name="style:font-weight-asian">bold</xsl:attribute>
  3594.                         <xsl:attribute name="style:font-weight-complex">bold</xsl:attribute>
  3595.                     </xsl:if>
  3596.                     <xsl:choose>
  3597.                         <xsl:when test="ss:Font/@ss:Color">
  3598.                             <xsl:attribute name="fo:color"><xsl:value-of select="ss:Font/@ss:Color"/></xsl:attribute>
  3599.                         </xsl:when>
  3600.                         <xsl:otherwise>
  3601.                             <xsl:attribute name="style:use-window-font-color">true</xsl:attribute>
  3602.                         </xsl:otherwise>
  3603.                     </xsl:choose>
  3604.                     <xsl:if test="ss:Font/@ss:Italic = '1'">
  3605.                         <!-- omit font-style oblique. glu -->
  3606.                         <xsl:attribute name="fo:font-style">italic</xsl:attribute>
  3607.                         <xsl:attribute name="style:font-style-asian">italic</xsl:attribute>
  3608.                         <xsl:attribute name="style:font-style-complex">italic</xsl:attribute>
  3609.                     </xsl:if>
  3610.                     <xsl:choose>
  3611.                         <xsl:when test="ss:Font/@ss:Size">
  3612.                             <xsl:attribute name="fo:font-size"><xsl:value-of select="concat( ss:Font/@ss:Size, 'pt')"/></xsl:attribute>
  3613.                             <xsl:attribute name="style:font-size-asian"><xsl:value-of select="concat( ss:Font/@ss:Size, 'pt')"/></xsl:attribute>
  3614.                             <xsl:attribute name="style:font-size-complex"><xsl:value-of select="concat( ss:Font/@ss:Size, 'pt')"/></xsl:attribute>
  3615.                         </xsl:when>
  3616.                         <xsl:otherwise>
  3617.                             <xsl:attribute name="fo:font-size">10pt</xsl:attribute>
  3618.                             <xsl:attribute name="style:font-size-asian">10pt</xsl:attribute>
  3619.                             <xsl:attribute name="style:font-size-complex">10pt</xsl:attribute>
  3620.                         </xsl:otherwise>
  3621.                     </xsl:choose>
  3622.                     <xsl:if test="ss:Font/@ss:Outline = '1'">
  3623.                         <xsl:attribute name="style:text-outline">true</xsl:attribute>
  3624.                     </xsl:if>
  3625.                     <xsl:if test="ss:Font/@ss:Shadow = '1'">
  3626.                         <xsl:attribute name="style:text-shadow">shadow</xsl:attribute>
  3627.                         <xsl:attribute name="fo:text-shadow">1pt 1pt</xsl:attribute>
  3628.                     </xsl:if>
  3629.                     <xsl:if test="ss:Font/@ss:StrikeThrough = '1'">
  3630.                         <xsl:attribute name="style:text-crossing-out">single-line</xsl:attribute>
  3631.                     </xsl:if>
  3632.                     <xsl:if test="ss:Font/@ss:Underline">
  3633.                         <xsl:choose>
  3634.                             <xsl:when test="ss:Font/@ss:Underline = 'None'">
  3635.                                 <xsl:attribute name="style:text-underline">none</xsl:attribute>
  3636.                             </xsl:when>
  3637.                             <xsl:when test="ss:Font/@ss:Underline = 'Single'">
  3638.                                 <xsl:attribute name="style:text-underline">single</xsl:attribute>
  3639.                             </xsl:when>
  3640.                             <xsl:when test="ss:Font/@ss:Underline = 'Double'">
  3641.                                 <xsl:attribute name="style:text-underline">double</xsl:attribute>
  3642.                             </xsl:when>
  3643.                             <xsl:when test="ss:Font/@ss:Underline = 'SingleAccounting'">
  3644.                                 <xsl:attribute name="style:text-underline">single</xsl:attribute>"</xsl:when>
  3645.                             <xsl:when test="ss:Font/@ss:Underline = 'DoubleAccounting'">
  3646.                                 <xsl:attribute name="style:text-underline">double</xsl:attribute>
  3647.                             </xsl:when>
  3648.                             <xsl:otherwise>
  3649.                                 <xsl:attribute name="style:text-underline">none</xsl:attribute>
  3650.                             </xsl:otherwise>
  3651.                         </xsl:choose>
  3652.                     </xsl:if>
  3653.                     <xsl:if test="ss:Font/@x:Charset">
  3654.                         <!-- quite unclear till now, glu -->
  3655.                         <xsl:attribute name="style:font-charset">x-symbol</xsl:attribute>
  3656.                     </xsl:if>
  3657.                 </xsl:if>
  3658.                 <xsl:if test="ss:Interior">
  3659.                     <xsl:choose>
  3660.                         <xsl:when test="ss:Interior/@ss:Pattern = 'Solid'">
  3661.                             <xsl:if test="ss:Interior/@ss:Color">
  3662.                                 <xsl:attribute name="fo:background-color"><xsl:value-of select="ss:Interior/@ss:Color"/></xsl:attribute>
  3663.                             </xsl:if>
  3664.                         </xsl:when>
  3665.                         <xsl:otherwise>
  3666.                             <xsl:if test="ss:Interior/@ss:PatternColor">
  3667.                                 <!--2003.7.15,tom chen,invoke some method in Java,the name space declare at the top. removed for other parsers. :( -->
  3668.                                 <xsl:variable name="pattern-value">
  3669.                                     <xsl:call-template name="cell-pattern-color">
  3670.                                         <xsl:with-param name="pattern" select="concat('0.',substring-after(./ss:Interior/@ss:Pattern,'y'))"/>
  3671.                                         <xsl:with-param name="color-value" select="./ss:Interior/@ss:Color"/>
  3672.                                         <xsl:with-param name="pattern-color-value" select="./ss:Interior/@ss:PatternColor"/>
  3673.                                     </xsl:call-template>
  3674.                                 </xsl:variable>
  3675.                                 <xsl:attribute name="fo:background-color"><xsl:value-of select="$pattern-value"/></xsl:attribute>
  3676.                             </xsl:if>
  3677.                         </xsl:otherwise>
  3678.                     </xsl:choose>
  3679.                 </xsl:if>
  3680.                 <xsl:if test="ss:Protection">
  3681.                     <xsl:choose>
  3682.                         <xsl:when test="ss:Protection/@ss:Protected = '0'">
  3683.                             <xsl:choose>
  3684.                                 <xsl:when test="ss:Protection/@ss:HideFormula = '1'">
  3685.                                     <xsl:attribute name="style:cell-protect">hidden-and-protected</xsl:attribute>
  3686.                                 </xsl:when>
  3687.                                 <xsl:otherwise>
  3688.                                     <xsl:attribute name="style:cell-protect">none</xsl:attribute>
  3689.                                 </xsl:otherwise>
  3690.                             </xsl:choose>
  3691.                         </xsl:when>
  3692.                         <xsl:otherwise>
  3693.                             <xsl:choose>
  3694.                                 <xsl:when test="ss:Protection/@x:HideFormula = '1'">
  3695.                                     <xsl:attribute name="style:cell-protect">protected formula-hidden</xsl:attribute>
  3696.                                 </xsl:when>
  3697.                                 <xsl:otherwise>
  3698.                                     <xsl:attribute name="style:cell-protect">none</xsl:attribute>
  3699.                                 </xsl:otherwise>
  3700.                             </xsl:choose>
  3701.                         </xsl:otherwise>
  3702.                     </xsl:choose>
  3703.                 </xsl:if>
  3704.             </xsl:element>
  3705.         </xsl:element>
  3706.     </xsl:template>
  3707.     <xsl:template name="cell-pattern-color">
  3708.         <!-- generates a new color from cell-pattern-color.tom chen -->
  3709.         <xsl:param name="pattern"/>
  3710.         <xsl:param name="color-value"/>
  3711.         <xsl:param name="pattern-color-value"/>
  3712.         <xsl:variable name="rev-pattern" select="1 - $pattern"/>
  3713.         <xsl:variable name="color-R-value">
  3714.             <xsl:call-template name="hex2decimal">
  3715.                 <xsl:with-param name="hex-number" select="substring($color-value,2,2)"/>
  3716.                 <xsl:with-param name="index" select="1"/>
  3717.                 <xsl:with-param name="str-length" select="2"/>
  3718.                 <xsl:with-param name="last-value" select="0"/>
  3719.             </xsl:call-template>
  3720.         </xsl:variable>
  3721.         <xsl:variable name="color-G-value">
  3722.             <xsl:call-template name="hex2decimal">
  3723.                 <xsl:with-param name="hex-number" select="substring($color-value,4,2)"/>
  3724.                 <xsl:with-param name="index" select="1"/>
  3725.                 <xsl:with-param name="str-length" select="2"/>
  3726.                 <xsl:with-param name="last-value" select="0"/>
  3727.             </xsl:call-template>
  3728.         </xsl:variable>
  3729.         <xsl:variable name="color-B-value">
  3730.             <xsl:call-template name="hex2decimal">
  3731.                 <xsl:with-param name="hex-number" select="substring($color-value,6,2)"/>
  3732.                 <xsl:with-param name="index" select="1"/>
  3733.                 <xsl:with-param name="str-length" select="2"/>
  3734.                 <xsl:with-param name="last-value" select="0"/>
  3735.             </xsl:call-template>
  3736.         </xsl:variable>
  3737.         <xsl:variable name="pattern-R-value">
  3738.             <xsl:call-template name="hex2decimal">
  3739.                 <xsl:with-param name="hex-number" select="substring($pattern-color-value,2,2)"/>
  3740.                 <xsl:with-param name="index" select="1"/>
  3741.                 <xsl:with-param name="str-length" select="2"/>
  3742.                 <xsl:with-param name="last-value" select="0"/>
  3743.             </xsl:call-template>
  3744.         </xsl:variable>
  3745.         <xsl:variable name="pattern-G-value">
  3746.             <xsl:call-template name="hex2decimal">
  3747.                 <xsl:with-param name="hex-number" select="substring($pattern-color-value,4,2)"/>
  3748.                 <xsl:with-param name="index" select="1"/>
  3749.                 <xsl:with-param name="str-length" select="2"/>
  3750.                 <xsl:with-param name="last-value" select="0"/>
  3751.             </xsl:call-template>
  3752.         </xsl:variable>
  3753.         <xsl:variable name="pattern-B-value">
  3754.             <xsl:call-template name="hex2decimal">
  3755.                 <xsl:with-param name="hex-number" select="substring($pattern-color-value,6,2)"/>
  3756.                 <xsl:with-param name="index" select="1"/>
  3757.                 <xsl:with-param name="str-length" select="2"/>
  3758.                 <xsl:with-param name="last-value" select="0"/>
  3759.             </xsl:call-template>
  3760.         </xsl:variable>
  3761.         <xsl:variable name="R-value">
  3762.             <xsl:variable name="combined-R-value">
  3763.                 <xsl:call-template name="decimal2hex">
  3764.                     <xsl:with-param name="dec-number" select="floor($color-R-value * $rev-pattern + $pattern-R-value * $pattern)"/>
  3765.                     <xsl:with-param name="last-value" select="'H'"/>
  3766.                 </xsl:call-template>
  3767.             </xsl:variable>
  3768.             <xsl:choose>
  3769.                 <xsl:when test="string-length($combined-R-value) = 1">
  3770.                     <xsl:value-of select="concat('0',$combined-R-value)"/>
  3771.                 </xsl:when>
  3772.                 <xsl:otherwise>
  3773.                     <xsl:value-of select="$combined-R-value"/>
  3774.                 </xsl:otherwise>
  3775.             </xsl:choose>
  3776.         </xsl:variable>
  3777.         <xsl:variable name="G-value">
  3778.             <xsl:variable name="combined-G-value">
  3779.                 <xsl:call-template name="decimal2hex">
  3780.                     <xsl:with-param name="dec-number" select="floor($color-G-value * $rev-pattern + $pattern-G-value * $pattern)"/>
  3781.                     <xsl:with-param name="last-value" select="'H'"/>
  3782.                 </xsl:call-template>
  3783.             </xsl:variable>
  3784.             <xsl:choose>
  3785.                 <xsl:when test="string-length($combined-G-value) = 1">
  3786.                     <xsl:value-of select="concat('0',$combined-G-value)"/>
  3787.                 </xsl:when>
  3788.                 <xsl:otherwise>
  3789.                     <xsl:value-of select="$combined-G-value"/>
  3790.                 </xsl:otherwise>
  3791.             </xsl:choose>
  3792.         </xsl:variable>
  3793.         <xsl:variable name="B-value">
  3794.             <xsl:variable name="combined-B-value">
  3795.                 <xsl:call-template name="decimal2hex">
  3796.                     <xsl:with-param name="dec-number" select="floor($color-B-value * $rev-pattern + $pattern-B-value * $pattern)"/>
  3797.                     <xsl:with-param name="last-value" select="'H'"/>
  3798.                 </xsl:call-template>
  3799.             </xsl:variable>
  3800.             <xsl:choose>
  3801.                 <xsl:when test="string-length($combined-B-value) = 1">
  3802.                     <xsl:value-of select="concat('0',$combined-B-value)"/>
  3803.                 </xsl:when>
  3804.                 <xsl:otherwise>
  3805.                     <xsl:value-of select="$combined-B-value"/>
  3806.                 </xsl:otherwise>
  3807.             </xsl:choose>
  3808.         </xsl:variable>
  3809.         <xsl:value-of select="concat('#',$R-value,$G-value,$B-value)"/>
  3810.     </xsl:template>
  3811.     <xsl:template name="hex2decimal">
  3812.         <!-- transforms a hex number to a decimal number.parses the string from left to right.tom chen -->
  3813.         <xsl:param name="hex-number"/>
  3814.         <xsl:param name="index"/>
  3815.         <xsl:param name="str-length"/>
  3816.         <xsl:param name="last-value"/>
  3817.         <xsl:variable name="dec-char">
  3818.             <xsl:call-template name="hexNumber2dec">
  3819.                 <xsl:with-param name="hex-value" select="substring($hex-number, $index ,1)"/>
  3820.             </xsl:call-template>
  3821.         </xsl:variable>
  3822.         <xsl:variable name="current-value" select="$last-value * 16 + $dec-char"/>
  3823.         <xsl:if test="$index < $str-length">
  3824.             <xsl:call-template name="hex2decimal">
  3825.                 <xsl:with-param name="hex-number" select="$hex-number"/>
  3826.                 <xsl:with-param name="index" select="$index + 1"/>
  3827.                 <xsl:with-param name="str-length" select="$str-length"/>
  3828.                 <xsl:with-param name="last-value" select="$current-value"/>
  3829.             </xsl:call-template>
  3830.         </xsl:if>
  3831.         <xsl:if test="$index = $str-length">
  3832.             <xsl:value-of select="$current-value"/>
  3833.         </xsl:if>
  3834.     </xsl:template>
  3835.     <xsl:template name="hexNumber2dec">
  3836.         <!-- return a decimal number for a hex character.tom chen -->
  3837.         <xsl:param name="hex-value"/>
  3838.         <xsl:choose>
  3839.             <xsl:when test="$hex-value = 'A' or ($hex-value = 'a')">
  3840.                 <xsl:value-of select="10"/>
  3841.             </xsl:when>
  3842.             <xsl:when test="$hex-value = 'B' or ($hex-value = 'b')">
  3843.                 <xsl:value-of select="11"/>
  3844.             </xsl:when>
  3845.             <xsl:when test="$hex-value = 'C' or ($hex-value = 'c')">
  3846.                 <xsl:value-of select="12"/>
  3847.             </xsl:when>
  3848.             <xsl:when test="$hex-value = 'D' or ($hex-value = 'd')">
  3849.                 <xsl:value-of select="13"/>
  3850.             </xsl:when>
  3851.             <xsl:when test="$hex-value = 'E' or ($hex-value = 'e')">
  3852.                 <xsl:value-of select="14"/>
  3853.             </xsl:when>
  3854.             <xsl:when test="$hex-value = 'F' or ($hex-value = 'f')">
  3855.                 <xsl:value-of select="15"/>
  3856.             </xsl:when>
  3857.             <xsl:otherwise>
  3858.                 <xsl:value-of select="$hex-value"/>
  3859.             </xsl:otherwise>
  3860.         </xsl:choose>
  3861.     </xsl:template>
  3862.     <xsl:template name="decimal2hex">
  3863.         <!-- transforms a decimal number to a hex number,only for two-bit hex(less than 256 in decimal) currently.tom chen -->
  3864.         <xsl:param name="dec-number"/>
  3865.         <xsl:param name="last-value"/>
  3866.         <xsl:variable name="current-value">
  3867.             <xsl:call-template name="decNumber2hex">
  3868.                 <xsl:with-param name="dec-value">
  3869.                     <xsl:if test="$dec-number > 15">
  3870.                         <xsl:value-of select="floor($dec-number div 16)"/>
  3871.                     </xsl:if>
  3872.                     <xsl:if test="$dec-number < 16">
  3873.                         <xsl:value-of select="$dec-number"/>
  3874.                     </xsl:if>
  3875.                 </xsl:with-param>
  3876.             </xsl:call-template>
  3877.         </xsl:variable>
  3878.         <xsl:if test="$dec-number > 15">
  3879.             <xsl:call-template name="decimal2hex">
  3880.                 <xsl:with-param name="dec-number" select="$dec-number mod 16"/>
  3881.                 <xsl:with-param name="last-value" select="concat($last-value,$current-value)"/>
  3882.             </xsl:call-template>
  3883.         </xsl:if>
  3884.         <xsl:if test="$dec-number < 16">
  3885.             <xsl:value-of select="substring-after(concat($last-value,$current-value),'H')"/>
  3886.         </xsl:if>
  3887.     </xsl:template>
  3888.     <xsl:template name="decNumber2hex">
  3889.         <!-- return a hex number for a decimal character.tom chen -->
  3890.         <xsl:param name="dec-value"/>
  3891.         <xsl:choose>
  3892.             <xsl:when test="$dec-value = 10">
  3893.                 <xsl:value-of select="'A'"/>
  3894.             </xsl:when>
  3895.             <xsl:when test="$dec-value = 11">
  3896.                 <xsl:value-of select="'B'"/>
  3897.             </xsl:when>
  3898.             <xsl:when test="$dec-value = 12">
  3899.                 <xsl:value-of select="'C'"/>
  3900.             </xsl:when>
  3901.             <xsl:when test="$dec-value = 13">
  3902.                 <xsl:value-of select="'D'"/>
  3903.             </xsl:when>
  3904.             <xsl:when test="$dec-value = 14">
  3905.                 <xsl:value-of select="'E'"/>
  3906.             </xsl:when>
  3907.             <xsl:when test="$dec-value = 15">
  3908.                 <xsl:value-of select="'F'"/>
  3909.             </xsl:when>
  3910.             <xsl:otherwise>
  3911.                 <xsl:value-of select="$dec-value"/>
  3912.             </xsl:otherwise>
  3913.         </xsl:choose>
  3914.     </xsl:template>
  3915.     <xsl:template match="ss:Border">
  3916.         <xsl:variable name="position">
  3917.             <xsl:choose>
  3918.                 <xsl:when test="@ss:Position = 'Top'">fo:border-top</xsl:when>
  3919.                 <xsl:when test="@ss:Position = 'Bottom'">fo:border-bottom</xsl:when>
  3920.                 <xsl:when test="@ss:Position = 'Left'">fo:border-left</xsl:when>
  3921.                 <xsl:when test="@ss:Position = 'Right'">fo:border-right</xsl:when>
  3922.                 <!-- DiagonalLeft & DiagonalRight are not supported yet, glu -->
  3923.                 <xsl:otherwise>fo:border-left</xsl:otherwise>
  3924.             </xsl:choose>
  3925.         </xsl:variable>
  3926.         <xsl:variable name="width">
  3927.             <xsl:choose>
  3928.                 <!-- 0: Hairline -->
  3929.                 <xsl:when test="@ss:Weight = '0'">0.002cm</xsl:when>
  3930.                 <!-- 1: Thin -->
  3931.                 <xsl:when test="@ss:Weight = '1'">0.035cm</xsl:when>
  3932.                 <!-- 2: Medium -->
  3933.                 <xsl:when test="@ss:Weight = '2'">0.088cm</xsl:when>
  3934.                 <!-- 3: Thick -->
  3935.                 <xsl:when test="@ss:Weight = '3'">
  3936.                     <xsl:choose>
  3937.                         <xsl:when test="@ss:LineStyle = 'Double'">0.105cm</xsl:when>
  3938.                         <xsl:otherwise>0.141cm</xsl:otherwise>
  3939.                     </xsl:choose>
  3940.                 </xsl:when>
  3941.                 <!-- invalid value, or parameter not exist at all. glu -->
  3942.                 <xsl:otherwise>0.002cm</xsl:otherwise>
  3943.             </xsl:choose>
  3944.         </xsl:variable>
  3945.         <xsl:variable name="linestyle">
  3946.             <xsl:choose>
  3947.                 <xsl:when test="@ss:LineStyle = 'None'">none</xsl:when>
  3948.                 <xsl:when test="@ss:LineStyle = 'Continuous'">solid</xsl:when>
  3949.                 <xsl:when test="@ss:LineStyle = 'Double'">double</xsl:when>
  3950.                 <!-- Dash, Dot, DashDot, DashDotDot, SlantDashDot are not supported yet. glu -->
  3951.                 <xsl:otherwise>solid</xsl:otherwise>
  3952.             </xsl:choose>
  3953.         </xsl:variable>
  3954.         <xsl:variable name="color">
  3955.             <xsl:choose>
  3956.                 <xsl:when test="@ss:Color">
  3957.                     <xsl:value-of select="@ss:Color"/>
  3958.                 </xsl:when>
  3959.                 <!-- default border color is black -->
  3960.                 <xsl:otherwise>#000000</xsl:otherwise>
  3961.             </xsl:choose>
  3962.         </xsl:variable>
  3963.         <xsl:attribute name="{$position}"><xsl:value-of select="concat( $width, ' ', $linestyle, ' ', $color)"/></xsl:attribute>
  3964.         <xsl:if test="@ss:LineStyle = 'Double'">
  3965.             <xsl:variable name="widthposition">
  3966.                 <xsl:choose>
  3967.                     <xsl:when test="@ss:Position = 'Top'">style:border-line-width-top</xsl:when>
  3968.                     <xsl:when test="@ss:Position = 'Bottom'">style:border-line-width-bottom</xsl:when>
  3969.                     <xsl:when test="@ss:Position = 'Left'">style:border-line-width-left</xsl:when>
  3970.                     <xsl:when test="@ss:Position = 'Right'">style:border-line-width-right</xsl:when>
  3971.                 </xsl:choose>
  3972.             </xsl:variable>
  3973.             <xsl:attribute name="{$widthposition}">0.035cm 0.035cm 0.035cm</xsl:attribute>
  3974.         </xsl:if>
  3975.     </xsl:template>
  3976.     <xsl:template match="ss:Font">
  3977.         <xsl:choose>
  3978.             <xsl:when test="@ss:VerticalAlign = 'Superscript'">
  3979.                 <style:style style:name="{concat(../@ss:ID,'T0')}" style:family="text">
  3980.                     <style:properties style:text-position="33% 58%"/>
  3981.                 </style:style>
  3982.             </xsl:when>
  3983.             <xsl:when test="@ss:VerticalAlign = 'Subscript'">
  3984.                 <style:style style:name="{concat(../@ss:ID,'T0')}" style:family="text">
  3985.                     <style:properties style:text-position="-33% 58%"/>
  3986.                 </style:style>
  3987.             </xsl:when>
  3988.             <xsl:otherwise/>
  3989.         </xsl:choose>
  3990.     </xsl:template>
  3991.     <xsl:template match="ss:Table">
  3992.         <xsl:variable name="table-pos">
  3993.             <xsl:value-of select="count(../preceding-sibling::ss:Worksheet)+1"/>
  3994.         </xsl:variable>
  3995.         <xsl:variable name="default-column-width">
  3996.             <xsl:choose>
  3997.                 <xsl:when test="@ss:DefaultColumnWidth">
  3998.                     <xsl:value-of select="concat( floor(@ss:DefaultColumnWidth div 25.76 * 1000) div 1000, 'cm')"/>
  3999.                 </xsl:when>
  4000.                 <xsl:otherwise>2.096cm</xsl:otherwise>
  4001.             </xsl:choose>
  4002.         </xsl:variable>
  4003.         <style:style style:family="table-column" style:name="{concat('co', $table-pos)}">
  4004.             <style:properties style:column-width="{$default-column-width}"/>
  4005.         </style:style>
  4006.         <xsl:choose>
  4007.             <xsl:when test="ss:Column">
  4008.                 <xsl:call-template name="get-column-style-name">
  4009.                     <xsl:with-param name="lastcolumnpos" select="0"/>
  4010.                     <xsl:with-param name="column-count" select="count(./ss:Column)"/>
  4011.                     <xsl:with-param name="current-count" select="1"/>
  4012.                     <xsl:with-param name="table-pos" select="$table-pos"/>
  4013.                     <xsl:with-param name="default-column-width" select="$default-column-width"/>
  4014.                 </xsl:call-template>
  4015.             </xsl:when>
  4016.         </xsl:choose>
  4017.         <xsl:if test="../x:PageBreaks/x:ColBreaks">
  4018.             <style:style style:name="{concat('cob',$table-pos)}" style:family="table-column">
  4019.                 <xsl:element name="style:properties">
  4020.                     <xsl:attribute name="style:column-width"><xsl:value-of select="$default-column-width"/></xsl:attribute>
  4021.                     <xsl:attribute name="fo:break-before">page</xsl:attribute>
  4022.                 </xsl:element>
  4023.             </style:style>
  4024.         </xsl:if>
  4025.         <xsl:variable name="default-row-width">
  4026.             <xsl:choose>
  4027.                 <xsl:when test="@ss:DefaultRowHeight">
  4028.                     <xsl:value-of select="concat( floor(@ss:DefaultRowHeight div 28.34 * 1000) div 1000, 'cm')"/>
  4029.                 </xsl:when>
  4030.                 <xsl:otherwise>0.503cm</xsl:otherwise>
  4031.             </xsl:choose>
  4032.         </xsl:variable>
  4033.         <style:style style:family="table-row" style:name="{concat('ro', $table-pos)}">
  4034.             <style:properties style:row-height="{$default-row-width}" style:use-optimal-row-height="false"/>
  4035.         </style:style>
  4036.         <xsl:choose>
  4037.             <xsl:when test="ss:Row">
  4038.                 <xsl:call-template name="get-row-style-name">
  4039.                     <xsl:with-param name="lastrowpos" select="0"/>
  4040.                     <xsl:with-param name="row-count" select="count(./ss:Row)"/>
  4041.                     <xsl:with-param name="current-count" select="1"/>
  4042.                     <xsl:with-param name="table-pos" select="$table-pos"/>
  4043.                     <xsl:with-param name="default-row-width" select="$default-row-width"/>
  4044.                 </xsl:call-template>
  4045.             </xsl:when>
  4046.         </xsl:choose>
  4047.         <xsl:if test="../x:PageBreaks/x:RowBreaks">
  4048.             <style:style style:name="{concat('rob',$table-pos)}" style:family="table-row">
  4049.                 <xsl:element name="style:properties">
  4050.                     <xsl:attribute name="style:row-height"><xsl:value-of select="$default-row-width"/></xsl:attribute>
  4051.                     <xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
  4052.                     <xsl:attribute name="fo:break-before">page</xsl:attribute>
  4053.                 </xsl:element>
  4054.             </style:style>
  4055.         </xsl:if>
  4056.         <!-- create table-style. glu -->
  4057.         <xsl:element name="style:style">
  4058.             <xsl:attribute name="style:name"><xsl:value-of select="concat( 'ta', $table-pos)"/></xsl:attribute>
  4059.             <xsl:attribute name="style:family">table</xsl:attribute>
  4060.             <xsl:attribute name="style:master-page-name"><xsl:value-of select="concat( 'TAB_', ../@ss:Name)"/></xsl:attribute>
  4061.             <xsl:element name="style:properties">
  4062.                 <xsl:choose>
  4063.                     <xsl:when test="../x:WorksheetOptions/x:Visible = 'SheetHidden'">
  4064.                         <xsl:attribute name="table:display">false</xsl:attribute>
  4065.                     </xsl:when>
  4066.                     <xsl:otherwise>
  4067.                         <xsl:attribute name="table:display">true</xsl:attribute>
  4068.                     </xsl:otherwise>
  4069.                 </xsl:choose>
  4070.             </xsl:element>
  4071.         </xsl:element>
  4072.     </xsl:template>
  4073.     <xsl:template name="get-column-style-name">
  4074.         <!-- generate stylename of colbreak after matching the column number and the colbreak number.tom chen -->
  4075.         <xsl:param name="lastcolumnpos"/>
  4076.         <xsl:param name="column-count"/>
  4077.         <xsl:param name="current-count"/>
  4078.         <xsl:param name="table-pos"/>
  4079.         <xsl:param name="default-column-width"/>
  4080.         <xsl:if test="$current-count < ($column-count + 1)">
  4081.             <xsl:variable name="span-value">
  4082.                 <xsl:choose>
  4083.                     <xsl:when test="./ss:Column[position() = $current-count]/@ss:Span">
  4084.                         <xsl:value-of select="./ss:Column[position() = $current-count]/@ss:Span + 1"/>
  4085.                     </xsl:when>
  4086.                     <xsl:otherwise>
  4087.                         <xsl:value-of select="0"/>
  4088.                     </xsl:otherwise>
  4089.                 </xsl:choose>
  4090.             </xsl:variable>
  4091.             <xsl:variable name="current-index">
  4092.                 <xsl:choose>
  4093.                     <xsl:when test="./ss:Column[position() = $current-count]/@ss:Index">
  4094.                         <xsl:value-of select="./ss:Column[position() = $current-count]/@ss:Index - 1"/>
  4095.                     </xsl:when>
  4096.                     <xsl:otherwise>
  4097.                         <xsl:value-of select="$lastcolumnpos"/>
  4098.                     </xsl:otherwise>
  4099.                 </xsl:choose>
  4100.             </xsl:variable>
  4101.             <xsl:variable name="column-break">
  4102.                 <xsl:choose>
  4103.                     <xsl:when test="$span-value = 0">
  4104.                         <xsl:if test="../x:PageBreaks/x:ColBreaks/x:ColBreak/x:Column = $current-index">
  4105.                             <xsl:value-of select="1"/>
  4106.                         </xsl:if>
  4107.                     </xsl:when>
  4108.                     <xsl:otherwise>
  4109.                         <xsl:if test="../x:PageBreaks/x:ColBreaks[(x:ColBreak/x:Column > $lastcolumnpos) and (x:ColBreak/x:Column < ($lastcolumnpos + $span-value))]">
  4110.                             <xsl:value-of select="1"/>
  4111.                         </xsl:if>
  4112.                     </xsl:otherwise>
  4113.                 </xsl:choose>
  4114.             </xsl:variable>
  4115.             <xsl:if test="$column-break = 1">
  4116.                 <style:style style:name="{concat('cob', $table-pos, '-',$current-count)}" style:family="table-column">
  4117.                     <xsl:element name="style:properties">
  4118.                         <xsl:choose>
  4119.                             <xsl:when test="./ss:Column[position() = $current-count]/@ss:Width">
  4120.                                 <xsl:attribute name="style:column-width"><xsl:value-of select="concat( floor(./ss:Column[position() = $current-count]/@ss:Width div 25.76 * 1000) div 1000, 'cm')"/></xsl:attribute>
  4121.                             </xsl:when>
  4122.                             <xsl:otherwise>
  4123.                                 <xsl:attribute name="style:column-width"><xsl:value-of select="$default-column-width"/></xsl:attribute>
  4124.                             </xsl:otherwise>
  4125.                         </xsl:choose>
  4126.                         <xsl:choose>
  4127.                             <xsl:when test="./ss:Column[position() = $current-count]/@ss:AutoFitWidth = '0'">
  4128.                                 <xsl:attribute name="style:use-optimal-column-width">false</xsl:attribute>
  4129.                             </xsl:when>
  4130.                             <xsl:otherwise>
  4131.                                 <xsl:choose>
  4132.                                     <xsl:when test="./ss:Column[position() = $current-count]/@ss:Width > 0">
  4133.                                         <xsl:attribute name="style:use-optimal-column-width">false</xsl:attribute>
  4134.                                     </xsl:when>
  4135.                                     <xsl:otherwise>
  4136.                                         <xsl:attribute name="style:use-optimal-column-width">true</xsl:attribute>
  4137.                                     </xsl:otherwise>
  4138.                                 </xsl:choose>
  4139.                             </xsl:otherwise>
  4140.                         </xsl:choose>
  4141.                         <xsl:attribute name="fo:break-before">page</xsl:attribute>
  4142.                     </xsl:element>
  4143.                 </style:style>
  4144.             </xsl:if>
  4145.             <style:style style:name="{concat('co', $table-pos, '-',$current-count)}" style:family="table-column">
  4146.                 <xsl:element name="style:properties">
  4147.                     <xsl:choose>
  4148.                         <xsl:when test="./ss:Column[position() = $current-count]/@ss:Width">
  4149.                             <xsl:attribute name="style:column-width"><xsl:value-of select="concat( floor(./ss:Column[position() = $current-count]/@ss:Width div 25.76 * 1000) div 1000, 'cm')"/></xsl:attribute>
  4150.                         </xsl:when>
  4151.                         <xsl:otherwise>
  4152.                             <xsl:attribute name="style:column-width"><xsl:value-of select="$default-column-width"/></xsl:attribute>
  4153.                         </xsl:otherwise>
  4154.                     </xsl:choose>
  4155.                     <xsl:attribute name="fo:break-before">auto</xsl:attribute>
  4156.                 </xsl:element>
  4157.             </style:style>
  4158.             <xsl:if test="$current-count < $column-count">
  4159.                 <xsl:call-template name="get-column-style-name">
  4160.                     <xsl:with-param name="lastcolumnpos">
  4161.                         <xsl:choose>
  4162.                             <xsl:when test="./ss:Column[position() = $current-count]/@ss:Index">
  4163.                                 <xsl:choose>
  4164.                                     <xsl:when test="./ss:Column[position() = $current-count]/@ss:Span">
  4165.                                         <xsl:value-of select="./ss:Column[position() = $current-count]/@ss:Index + ./ss:Column[position() = $current-count]/@ss:Span"/>
  4166.                                     </xsl:when>
  4167.                                     <xsl:otherwise>
  4168.                                         <xsl:value-of select="./ss:Column[position() = $current-count]/@ss:Index"/>
  4169.                                     </xsl:otherwise>
  4170.                                 </xsl:choose>
  4171.                             </xsl:when>
  4172.                             <xsl:otherwise>
  4173.                                 <xsl:choose>
  4174.                                     <xsl:when test="./ss:Column[position() = $current-count]/@ss:Span">
  4175.                                         <xsl:value-of select="$lastcolumnpos + ./ss:Column[position() = $current-count]/@ss:Span + 1"/>
  4176.                                     </xsl:when>
  4177.                                     <xsl:otherwise>
  4178.                                         <xsl:value-of select="$lastcolumnpos + 1"/>
  4179.                                     </xsl:otherwise>
  4180.                                 </xsl:choose>
  4181.                             </xsl:otherwise>
  4182.                         </xsl:choose>
  4183.                     </xsl:with-param>
  4184.                     <xsl:with-param name="column-count" select="$column-count"/>
  4185.                     <xsl:with-param name="current-count" select="$current-count + 1"/>
  4186.                     <xsl:with-param name="table-pos" select="$table-pos"/>
  4187.                     <xsl:with-param name="default-column-width" select="$default-column-width"/>
  4188.                 </xsl:call-template>
  4189.             </xsl:if>
  4190.         </xsl:if>
  4191.     </xsl:template>
  4192.     <xsl:template name="get-row-style-name">
  4193.         <!-- generate stylename of rowbreak after matching the row number and the rowbreak number.tom chen -->
  4194.         <xsl:param name="lastrowpos"/>
  4195.         <xsl:param name="row-count"/>
  4196.         <xsl:param name="current-count"/>
  4197.         <xsl:param name="table-pos"/>
  4198.         <xsl:param name="default-row-width"/>
  4199.         <xsl:if test="$current-count < ($row-count + 1)">
  4200.             <xsl:variable name="span-value">
  4201.                 <xsl:choose>
  4202.                     <xsl:when test="./ss:Row[position() = $current-count]/@ss:Index">
  4203.                         <xsl:choose>
  4204.                             <xsl:when test="./ss:Row[position() = $current-count]/@ss:Span">
  4205.                                 <xsl:value-of select="./ss:Row[position() = $current-count]/@ss:Index - $lastrowpos+ ./ss:Row[position() = $current-count]/@ss:Span"/>
  4206.                             </xsl:when>
  4207.                             <xsl:otherwise>
  4208.                                 <xsl:value-of select="0"/>
  4209.                             </xsl:otherwise>
  4210.                         </xsl:choose>
  4211.                     </xsl:when>
  4212.                     <xsl:otherwise>
  4213.                         <xsl:choose>
  4214.                             <xsl:when test="./ss:Row[position() = $current-count]/@ss:Span">
  4215.                                 <xsl:value-of select="./ss:Row[position() = $current-count]/@ss:Span + 1"/>
  4216.                             </xsl:when>
  4217.                             <xsl:otherwise>
  4218.                                 <xsl:value-of select="0"/>
  4219.                             </xsl:otherwise>
  4220.                         </xsl:choose>
  4221.                     </xsl:otherwise>
  4222.                 </xsl:choose>
  4223.             </xsl:variable>
  4224.             <xsl:variable name="current-index">
  4225.                 <xsl:choose>
  4226.                     <xsl:when test="./ss:Row[position() = $current-count]/@ss:Index">
  4227.                         <xsl:value-of select="./ss:Row[position() = $current-count]/@ss:Index - 1"/>
  4228.                     </xsl:when>
  4229.                     <xsl:otherwise>
  4230.                         <xsl:value-of select="$lastrowpos"/>
  4231.                     </xsl:otherwise>
  4232.                 </xsl:choose>
  4233.             </xsl:variable>
  4234.             <xsl:variable name="row-break">
  4235.                 <xsl:choose>
  4236.                     <xsl:when test="$span-value = 0">
  4237.                         <xsl:if test="../x:PageBreaks/x:RowBreaks/x:RowBreak/x:Row = $current-index">
  4238.                             <xsl:value-of select="1"/>
  4239.                         </xsl:if>
  4240.                     </xsl:when>
  4241.                     <xsl:otherwise>
  4242.                         <xsl:if test="../x:PageBreaks/x:RowBreaks[(x:RowBreak/x:Row > $lastrowpos) and (x:RowBreak/x:Row < ($lastrowpos + $span-value))]">
  4243.                             <xsl:value-of select="1"/>
  4244.                         </xsl:if>
  4245.                     </xsl:otherwise>
  4246.                 </xsl:choose>
  4247.             </xsl:variable>
  4248.             <xsl:if test="$row-break = 1">
  4249.                 <style:style style:name="{concat('rob', $table-pos, '-',$current-count)}" style:family="table-row">
  4250.                     <xsl:element name="style:properties">
  4251.                         <xsl:choose>
  4252.                             <xsl:when test="./ss:Row[position() = $current-count]/@ss:Height">
  4253.                                 <xsl:attribute name="style:row-height"><xsl:value-of select="concat( floor(./ss:Row[position() = $current-count]/@ss:Height div 28.34 *     1000) div 1000, 'cm')"/></xsl:attribute>
  4254.                             </xsl:when>
  4255.                             <xsl:otherwise>
  4256.                                 <xsl:attribute name="style:row-height"><xsl:value-of select="$default-row-width"/></xsl:attribute>
  4257.                             </xsl:otherwise>
  4258.                         </xsl:choose>
  4259.                         <xsl:choose>
  4260.                             <xsl:when test="./ss:Row[position() = $current-count]/@ss:AutoFitHeight = '0'">
  4261.                                 <xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
  4262.                             </xsl:when>
  4263.                             <xsl:otherwise>
  4264.                                 <xsl:choose>
  4265.                                     <xsl:when test="./ss:Row[position() = $current-count]/@ss:Height > 0">
  4266.                                         <xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
  4267.                                     </xsl:when>
  4268.                                     <xsl:otherwise>
  4269.                                         <xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
  4270.                                     </xsl:otherwise>
  4271.                                 </xsl:choose>
  4272.                             </xsl:otherwise>
  4273.                         </xsl:choose>
  4274.                         <xsl:attribute name="fo:break-before">page</xsl:attribute>
  4275.                     </xsl:element>
  4276.                 </style:style>
  4277.             </xsl:if>
  4278.             <style:style style:name="{concat('ro', $table-pos, '-',$current-count)}" style:family="table-row">
  4279.                 <xsl:element name="style:properties">
  4280.                     <xsl:choose>
  4281.                         <xsl:when test="./ss:Row[position() = $current-count]/@ss:Height">
  4282.                             <xsl:attribute name="style:row-height"><xsl:value-of select="concat( floor(./ss:Row[position() = $current-count]/@ss:Height div 28.34 * 1000) div 1000, 'cm')"/></xsl:attribute>
  4283.                         </xsl:when>
  4284.                         <xsl:otherwise>
  4285.                             <xsl:attribute name="style:row-height"><xsl:value-of select="$default-row-width"/></xsl:attribute>
  4286.                         </xsl:otherwise>
  4287.                     </xsl:choose>
  4288.                     <xsl:choose>
  4289.                         <xsl:when test="./ss:Row[position() = $current-count]/@ss:AutoFitHeight">
  4290.                             <xsl:choose>
  4291.                                 <xsl:when test="./ss:Row[position() = $current-count]/@ss:AutoFitHeight = '0'">
  4292.                                     <xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
  4293.                                 </xsl:when>
  4294.                                 <xsl:otherwise>
  4295.                                     <xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
  4296.                                 </xsl:otherwise>
  4297.                             </xsl:choose>
  4298.                         </xsl:when>
  4299.                         <xsl:otherwise>
  4300.                             <xsl:choose>
  4301.                                 <xsl:when test="./ss:Row[position() = $current-count]/@ss:Height > 0">
  4302.                                     <xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
  4303.                                 </xsl:when>
  4304.                                 <xsl:otherwise>
  4305.                                     <xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
  4306.                                 </xsl:otherwise>
  4307.                             </xsl:choose>
  4308.                         </xsl:otherwise>
  4309.                     </xsl:choose>
  4310.                     <xsl:attribute name="fo:break-before">auto</xsl:attribute>
  4311.                 </xsl:element>
  4312.             </style:style>
  4313.             <xsl:if test="$current-count < $row-count">
  4314.                 <xsl:call-template name="get-row-style-name">
  4315.                     <xsl:with-param name="lastrowpos">
  4316.                         <xsl:choose>
  4317.                             <xsl:when test="./ss:Row[position() = $current-count]/@ss:Index">
  4318.                                 <xsl:choose>
  4319.                                     <xsl:when test="./ss:Row[position() = $current-count]/@ss:Span">
  4320.                                         <xsl:value-of select="./ss:Row[position() = $current-count]/@ss:Index + ./ss:Row[position() = $current-count]/@ss:Span"/>
  4321.                                     </xsl:when>
  4322.                                     <xsl:otherwise>
  4323.                                         <xsl:value-of select="./ss:Row[position() = $current-count]/@ss:Index"/>
  4324.                                     </xsl:otherwise>
  4325.                                 </xsl:choose>
  4326.                             </xsl:when>
  4327.                             <xsl:otherwise>
  4328.                                 <xsl:choose>
  4329.                                     <xsl:when test="./ss:Row[position() = $current-count]/@ss:Span">
  4330.                                         <xsl:value-of select="$lastrowpos + ./ss:Row[position() = $current-count]/@ss:Span + 1"/>
  4331.                                     </xsl:when>
  4332.                                     <xsl:otherwise>
  4333.                                         <xsl:value-of select="$lastrowpos + 1"/>
  4334.                                     </xsl:otherwise>
  4335.                                 </xsl:choose>
  4336.                             </xsl:otherwise>
  4337.                         </xsl:choose>
  4338.                     </xsl:with-param>
  4339.                     <xsl:with-param name="row-count" select="$row-count"/>
  4340.                     <xsl:with-param name="current-count" select="$current-count + 1"/>
  4341.                     <xsl:with-param name="table-pos" select="$table-pos"/>
  4342.                     <xsl:with-param name="default-row-width" select="$default-row-width"/>
  4343.                 </xsl:call-template>
  4344.             </xsl:if>
  4345.         </xsl:if>
  4346.     </xsl:template>
  4347.     <xsl:template match="ss:Worksheet">
  4348.         <xsl:element name="table:table">
  4349.             <xsl:attribute name="table:name"><xsl:value-of select="@ss:Name"/></xsl:attribute>
  4350.             <!-- other attributes aren't suitable to apply yet. glu -->
  4351.             <xsl:if test="ss:Table">
  4352.                 <xsl:attribute name="table:style-name"><xsl:value-of select="concat( 'ta', count(preceding-sibling::ss:Worksheet)+1)"/></xsl:attribute>
  4353.                 <xsl:if test="@ss:Protected = '1'">
  4354.                     <xsl:attribute name="table:protected">true</xsl:attribute>
  4355.                 </xsl:if>
  4356.                 <xsl:if test="descendant::ss:NamedRange[@ss:Name = 'Print_Area' and contains( @ss:RefersTo, '!R')]">
  4357.                     <xsl:variable name="referto">
  4358.                         <xsl:call-template name="translate-expression">
  4359.                             <xsl:with-param name="cell-row-pos" select="0"/>
  4360.                             <xsl:with-param name="cell-column-pos" select="0"/>
  4361.                             <xsl:with-param name="expression" select="descendant::ss:NamedRange/@ss:RefersTo"/>
  4362.                         </xsl:call-template>
  4363.                     </xsl:variable>
  4364.                     <xsl:attribute name="table:print-ranges"><xsl:value-of select="translate( $referto, '=', '$')"/></xsl:attribute>
  4365.                 </xsl:if>
  4366.                 <xsl:variable name="table-pos">
  4367.                     <xsl:value-of select="count(../preceding-sibling::ss:Worksheet)+1"/>
  4368.                 </xsl:variable>
  4369.                 <xsl:choose>
  4370.                     <xsl:when test="./ss:Table/ss:Column">
  4371.                         <xsl:call-template name="Column-Data">
  4372.                             <xsl:with-param name="lastcolumnpos" select="0"/>
  4373.                             <xsl:with-param name="column-count" select="count(ss:Table/ss:Column)"/>
  4374.                             <xsl:with-param name="current-count" select="1"/>
  4375.                         </xsl:call-template>
  4376.                     </xsl:when>
  4377.                     <xsl:otherwise>
  4378.                         <xsl:if test="./x:PageBreaks/x:ColBreaks">
  4379.                             <xsl:for-each select="./x:PageBreaks/x:ColBreaks/x:ColBreak">
  4380.                                 <xsl:variable name="number-repeated">
  4381.                                     <xsl:choose>
  4382.                                         <xsl:when test="position() = 1">
  4383.                                             <xsl:value-of select="./x:Column"/>
  4384.                                         </xsl:when>
  4385.                                         <xsl:otherwise>
  4386.                                             <xsl:value-of select=". - preceding::x:ColBreak[position()=count(.)]/x:Column - 1"/>
  4387.                                         </xsl:otherwise>
  4388.                                     </xsl:choose>
  4389.                                 </xsl:variable>
  4390.                                 <xsl:if test="$number-repeated > 0">
  4391.                                     <xsl:element name="table:table-column">
  4392.                                         <xsl:if test="ancestor::ss:Worksheet/ss:Table/@ss:StyleID">
  4393.                                             <xsl:attribute name="table:default-cell-style-name"><xsl:value-of select="ancestor::ss:Worksheet/ss:Table/@ss:StyleID"/></xsl:attribute>
  4394.                                         </xsl:if>
  4395.                                         <xsl:if test="@ss:Hidden = '1'">
  4396.                                             <xsl:attribute name="table:visibility">collapse</xsl:attribute>
  4397.                                         </xsl:if>
  4398.                                         <xsl:attribute name="table:style-name"><xsl:value-of select="concat('co',$table-pos)"/></xsl:attribute>
  4399.                                         <xsl:attribute name="table:number-columns-repeated"><xsl:value-of select="$number-repeated"/></xsl:attribute>
  4400.                                     </xsl:element>
  4401.                                 </xsl:if>
  4402.                                 <xsl:element name="table:table-column">
  4403.                                     <!-- column style be made out beforehead. glu -->
  4404.                                     <xsl:if test="ancestor::ss:Worksheet/ss:Table/@ss:StyleID">
  4405.                                         <xsl:attribute name="table:default-cell-style-name"><xsl:value-of select="ancestor::ss:Worksheet/ss:Table/@ss:StyleID"/></xsl:attribute>
  4406.                                     </xsl:if>
  4407.                                     <xsl:if test="@ss:Hidden = '1'">
  4408.                                         <xsl:attribute name="table:visibility">collapse</xsl:attribute>
  4409.                                     </xsl:if>
  4410.                                     <xsl:attribute name="table:style-name"><xsl:value-of select="concat('cob',$table-pos)"/></xsl:attribute>
  4411.                                 </xsl:element>
  4412.                             </xsl:for-each>
  4413.                         </xsl:if>
  4414.                         <!-- if exists attribute of StyleID in tag of ss:Table but no Row/Column. cp tom chen -->
  4415.                         <xsl:if test="./ss:Table/@ss:StyleID">
  4416.                             <table:table-column table:style-name="co1" table:number-columns-repeated="256" table:default-cell-style-name="{./ss:Table/@ss:StyleID}"/>
  4417.                         </xsl:if>
  4418.                     </xsl:otherwise>
  4419.                 </xsl:choose>
  4420.                 <!-- generates the string of row\column position if ConditionalFormatting exists.tom chen -->
  4421.                 <xsl:variable name="condition-pos-str">
  4422.                     <xsl:if test="./x:ConditionalFormatting">
  4423.                         <xsl:call-template name="condition-row-column-string">
  4424.                             <xsl:with-param name="last" select="''"/>
  4425.                             <xsl:with-param name="total" select="count(./x:ConditionalFormatting)"/>
  4426.                             <xsl:with-param name="index" select="1"/>
  4427.                         </xsl:call-template>
  4428.                     </xsl:if>
  4429.                 </xsl:variable>
  4430.                 <xsl:choose>
  4431.                     <xsl:when test="./ss:Table/ss:Row">
  4432.                         <xsl:call-template name="Row-Data">
  4433.                             <xsl:with-param name="lastrowpos" select="0"/>
  4434.                             <xsl:with-param name="row-count" select="count(ss:Table/ss:Row)"/>
  4435.                             <xsl:with-param name="current-count" select="1"/>
  4436.                             <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4437.                         </xsl:call-template>
  4438.                     </xsl:when>
  4439.                     <xsl:otherwise>
  4440.                         <xsl:variable name="table-style-value">
  4441.                             <xsl:choose>
  4442.                                 <xsl:when test="./ss:Table[@ss:StyleID]">
  4443.                                     <xsl:value-of select="1"/>
  4444.                                 </xsl:when>
  4445.                                 <xsl:otherwise>
  4446.                                     <xsl:value-of select="0"/>
  4447.                                 </xsl:otherwise>
  4448.                             </xsl:choose>
  4449.                         </xsl:variable>
  4450.                         <xsl:if test="./x:PageBreaks/x:RowBreaks">
  4451.                             <xsl:for-each select="./x:PageBreaks/x:RowBreaks/x:RowBreak">
  4452.                                 <xsl:variable name="number-repeated">
  4453.                                     <xsl:choose>
  4454.                                         <xsl:when test="position() = 1">
  4455.                                             <xsl:value-of select="./x:Row"/>
  4456.                                         </xsl:when>
  4457.                                         <xsl:otherwise>
  4458.                                             <xsl:value-of select=". - preceding::x:RowBreak[position()=count(.)]/x:Row - 1"/>
  4459.                                         </xsl:otherwise>
  4460.                                     </xsl:choose>
  4461.                                 </xsl:variable>
  4462.                                 <xsl:if test="$number-repeated > 0">
  4463.                                     <xsl:element name="table:table-row">
  4464.                                         <xsl:if test="ancestor::ss:Worksheet/ss:Table/@ss:StyleID">
  4465.                                             <xsl:attribute name="table:default-cell-style-name"><xsl:value-of select="ancestor::ss:Worksheet/ss:Table/@ss:StyleID"/></xsl:attribute>
  4466.                                         </xsl:if>
  4467.                                         <xsl:if test="@ss:Hidden = '1'">
  4468.                                             <xsl:attribute name="table:visibility">collapse</xsl:attribute>
  4469.                                         </xsl:if>
  4470.                                         <xsl:attribute name="table:style-name"><xsl:value-of select="concat('ro',$table-pos)"/></xsl:attribute>
  4471.                                         <xsl:attribute name="table:number-rows-repeated"><xsl:value-of select="$number-repeated"/></xsl:attribute>
  4472.                                         <xsl:if test="$table-style-value = 1">
  4473.                                             <table:table-cell table:number-columns-repeated="256"/>
  4474.                                         </xsl:if>
  4475.                                     </xsl:element>
  4476.                                 </xsl:if>
  4477.                                 <xsl:element name="table:table-row">
  4478.                                     <xsl:if test="ancestor::ss:Worksheet/ss:Table/@ss:StyleID">
  4479.                                         <xsl:attribute name="table:default-cell-style-name"><xsl:value-of select="ancestor::ss:Worksheet/ss:Table/@ss:StyleID"/></xsl:attribute>
  4480.                                     </xsl:if>
  4481.                                     <xsl:if test="@ss:Hidden = '1'">
  4482.                                         <xsl:attribute name="table:visibility">collapse</xsl:attribute>
  4483.                                     </xsl:if>
  4484.                                     <xsl:attribute name="table:style-name"><xsl:value-of select="concat('rob',$table-pos)"/></xsl:attribute>
  4485.                                     <xsl:if test="$table-style-value = 1">
  4486.                                         <table:table-cell table:number-columns-repeated="256"/>
  4487.                                     </xsl:if>
  4488.                                 </xsl:element>
  4489.                             </xsl:for-each>
  4490.                         </xsl:if>
  4491.                         <xsl:if test="./x:ConditionalFormatting">
  4492.                             <xsl:variable name="condition-row-max">
  4493.                                 <xsl:call-template name="condition-row-col-pos-max">
  4494.                                     <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4495.                                     <xsl:with-param name="last-value" select="0"/>
  4496.                                     <xsl:with-param name="div-value" select="'R'"/>
  4497.                                 </xsl:call-template>
  4498.                             </xsl:variable>
  4499.                             <xsl:variable name="condition-col-max">
  4500.                                 <xsl:call-template name="condition-row-col-pos-max">
  4501.                                     <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4502.                                     <xsl:with-param name="last-value" select="0"/>
  4503.                                     <xsl:with-param name="div-value" select="'C'"/>
  4504.                                 </xsl:call-template>
  4505.                             </xsl:variable>
  4506.                             <xsl:variable name="break-row-max">
  4507.                                 <xsl:call-template name="break-row-beyond-max">
  4508.                                     <xsl:with-param name="pos" select="1"/>
  4509.                                     <xsl:with-param name="last-value" select="0"/>
  4510.                                     <xsl:with-param name="count-value" select="count(./x:PageBreaks/x:RowBreaks/x:RowBreak)"/>
  4511.                                 </xsl:call-template>
  4512.                             </xsl:variable>
  4513.                             <xsl:variable name="end-value">
  4514.                                 <xsl:choose>
  4515.                                     <xsl:when test="$condition-row-max < $break-row-max">
  4516.                                         <xsl:value-of select="$break-row-max"/>
  4517.                                     </xsl:when>
  4518.                                     <xsl:otherwise>
  4519.                                         <xsl:value-of select="$condition-row-max"/>
  4520.                                     </xsl:otherwise>
  4521.                                 </xsl:choose>
  4522.                             </xsl:variable>
  4523.                             <xsl:call-template name="get-row-beyond-last">
  4524.                                 <xsl:with-param name="index-value" select="1"/>
  4525.                                 <xsl:with-param name="pre-worksheet" select="count(preceding-sibling::ss:Worksheet)+1"/>
  4526.                                 <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4527.                                 <xsl:with-param name="end-pos" select="$end-value"/>
  4528.                                 <xsl:with-param name="total-col" select="$condition-col-max"/>
  4529.                             </xsl:call-template>
  4530.                         </xsl:if>
  4531.                         <!-- if exists attribute of StyleID in tag of ss:Table but no Row/Column. cp tom chen -->
  4532.                         <xsl:if test="./ss:Table/@ss:StyleID">
  4533.                             <table:table-row table:style-name="ro1" table:number-rows-repeated="32000" table:default-cell-style-name="{./ss:Table/@ss:StyleID}">
  4534.                                 <table:table-cell table:number-columns-repeated="256"/>
  4535.                             </table:table-row>
  4536.                         </xsl:if>
  4537.                     </xsl:otherwise>
  4538.                 </xsl:choose>
  4539.             </xsl:if>
  4540.         </xsl:element>
  4541.     </xsl:template>
  4542.     <xsl:template name="Column-Data">
  4543.         <xsl:param name="lastcolumnpos"/>
  4544.         <xsl:param name="column-count"/>
  4545.         <xsl:param name="current-count"/>
  4546.         <xsl:if test="$current-count < ($column-count + 1)">
  4547.             <xsl:variable name="span-value">
  4548.                 <xsl:choose>
  4549.                     <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Index">
  4550.                         <xsl:choose>
  4551.                             <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Span">
  4552.                                 <xsl:value-of select="./ss:Table/ss:Column[position() = $current-count]/@ss:Index - $lastcolumnpos + ./ss:Table/ss:Column[position() = $current-count]/@ss:Span"/>
  4553.                             </xsl:when>
  4554.                             <xsl:otherwise>
  4555.                                 <xsl:value-of select="./ss:Table/ss:Column[position() = $current-count]/@ss:Index - $lastcolumnpos"/>
  4556.                             </xsl:otherwise>
  4557.                         </xsl:choose>
  4558.                     </xsl:when>
  4559.                     <xsl:otherwise>
  4560.                         <xsl:choose>
  4561.                             <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Span">
  4562.                                 <xsl:value-of select="./ss:Table/ss:Column[position() = $current-count]/@ss:Span + 1"/>
  4563.                             </xsl:when>
  4564.                             <xsl:otherwise>
  4565.                                 <xsl:value-of select="1"/>
  4566.                             </xsl:otherwise>
  4567.                         </xsl:choose>
  4568.                     </xsl:otherwise>
  4569.                 </xsl:choose>
  4570.             </xsl:variable>
  4571.             <xsl:variable name="current-index">
  4572.                 <xsl:choose>
  4573.                     <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Index">
  4574.                         <xsl:value-of select="./ss:Table/ss:Column[position() = $current-count]/@ss:Index"/>
  4575.                     </xsl:when>
  4576.                     <xsl:otherwise>
  4577.                         <xsl:value-of select="$lastcolumnpos + 1"/>
  4578.                     </xsl:otherwise>
  4579.                 </xsl:choose>
  4580.             </xsl:variable>
  4581.             <xsl:call-template name="get-column-span-in">
  4582.                 <xsl:with-param name="index-value" select="$lastcolumnpos"/>
  4583.                 <xsl:with-param name="span-value" select="$span-value"/>
  4584.                 <xsl:with-param name="pre-worksheet" select="count(preceding-sibling::ss:Worksheet)+1"/>
  4585.                 <xsl:with-param name="row-value" select="$current-count"/>
  4586.                 <xsl:with-param name="times" select="1"/>
  4587.                 <xsl:with-param name="current-index" select="$current-index"/>
  4588.             </xsl:call-template>
  4589.             <xsl:if test="$current-count < $column-count">
  4590.                 <xsl:call-template name="Column-Data">
  4591.                     <xsl:with-param name="lastcolumnpos">
  4592.                         <xsl:choose>
  4593.                             <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Index">
  4594.                                 <xsl:choose>
  4595.                                     <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Span">
  4596.                                         <xsl:value-of select="./ss:Table/ss:Column[position() = $current-count]/@ss:Index + ./ss:Table/ss:Column[position() = $current-count]/@ss:Span"/>
  4597.                                     </xsl:when>
  4598.                                     <xsl:otherwise>
  4599.                                         <xsl:value-of select="./ss:Table/ss:Column[position() = $current-count]/@ss:Index"/>
  4600.                                     </xsl:otherwise>
  4601.                                 </xsl:choose>
  4602.                             </xsl:when>
  4603.                             <xsl:otherwise>
  4604.                                 <xsl:choose>
  4605.                                     <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Span">
  4606.                                         <xsl:value-of select="$lastcolumnpos + ./ss:Table/ss:Column[position() = $current-count]/@ss:Span + 1"/>
  4607.                                     </xsl:when>
  4608.                                     <xsl:otherwise>
  4609.                                         <xsl:value-of select="$lastcolumnpos + 1"/>
  4610.                                     </xsl:otherwise>
  4611.                                 </xsl:choose>
  4612.                             </xsl:otherwise>
  4613.                         </xsl:choose>
  4614.                     </xsl:with-param>
  4615.                     <xsl:with-param name="column-count" select="$column-count"/>
  4616.                     <xsl:with-param name="current-count" select="$current-count + 1"/>
  4617.                 </xsl:call-template>
  4618.             </xsl:if>
  4619.         </xsl:if>
  4620.         <xsl:if test="$current-count = $column-count">
  4621.             <xsl:variable name="last-pos">
  4622.                 <xsl:choose>
  4623.                     <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Index">
  4624.                         <xsl:choose>
  4625.                             <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Span">
  4626.                                 <xsl:value-of select="./ss:Table/ss:Column[position() = $current-count]/@ss:Index + ./ss:Table/ss:Column[position() = $current-count]/@ss:Span"/>
  4627.                             </xsl:when>
  4628.                             <xsl:otherwise>
  4629.                                 <xsl:value-of select="./ss:Table/ss:Column[position() = $current-count]/@ss:Index"/>
  4630.                             </xsl:otherwise>
  4631.                         </xsl:choose>
  4632.                     </xsl:when>
  4633.                     <xsl:otherwise>
  4634.                         <xsl:choose>
  4635.                             <xsl:when test="./ss:Table/ss:Column[position() = $current-count]/@ss:Span">
  4636.                                 <xsl:value-of select="$lastcolumnpos + ./ss:Table/ss:Column[position() = $current-count]/@ss:Span + 1"/>
  4637.                             </xsl:when>
  4638.                             <xsl:otherwise>
  4639.                                 <xsl:value-of select="$lastcolumnpos + 1"/>
  4640.                             </xsl:otherwise>
  4641.                         </xsl:choose>
  4642.                     </xsl:otherwise>
  4643.                 </xsl:choose>
  4644.             </xsl:variable>
  4645.             <xsl:if test="./x:PageBreaks/x:ColBreaks/x:ColBreak/x:Column > ($last-pos - 1)">
  4646.                 <xsl:call-template name="get-column-beyond-last">
  4647.                     <xsl:with-param name="index-value" select="$last-pos + 1"/>
  4648.                     <xsl:with-param name="pre-worksheet" select="count(preceding-sibling::ss:Worksheet)+1"/>
  4649.                 </xsl:call-template>
  4650.             </xsl:if>
  4651.             <!-- generates some special tags for whole row style. tom chen -->
  4652.             <xsl:if test="(./ss:Table[@ss:StyleID] or ./ss:Table/ss:Row[@ss:StyleID]) and (256 - $last-pos > 0)">
  4653.                 <xsl:element name="table:table-column">
  4654.                     <xsl:attribute name="table:default-cell-style-name"><xsl:choose><xsl:when test="./ss:Table[@ss:StyleID]"><xsl:value-of select="./ss:Table/@ss:StyleID"/></xsl:when><xsl:otherwise><xsl:value-of select="'Default'"/></xsl:otherwise></xsl:choose></xsl:attribute>
  4655.                     <xsl:attribute name="table:style-name"><xsl:value-of select="'co1'"/></xsl:attribute>
  4656.                     <xsl:attribute name="table:number-columns-repeated"><xsl:value-of select="256 - $last-pos"/></xsl:attribute>
  4657.                 </xsl:element>
  4658.             </xsl:if>
  4659.         </xsl:if>
  4660.     </xsl:template>
  4661.     <xsl:template name="current-column-row-pos">
  4662.         <xsl:param name="current-column-row-list"/>
  4663.         <xsl:choose>
  4664.             <xsl:when test="$current-column-row-list">
  4665.                 <!-- Xalan-J returns preceding-sibling in forward document sequence, not reverse as XPath 1.0 defined. glu -->
  4666.                 <xsl:variable name="current-column-row" select="$current-column-row-list[position()=last()]"/>
  4667.                 <xsl:choose>
  4668.                     <xsl:when test="$current-column-row/@ss:Index">
  4669.                         <xsl:choose>
  4670.                             <xsl:when test="$current-column-row/@ss:Span">
  4671.                                 <xsl:value-of select="$current-column-row/@ss:Span + $current-column-row/@ss:Index"/>
  4672.                             </xsl:when>
  4673.                             <xsl:otherwise>
  4674.                                 <xsl:value-of select="$current-column-row/@ss:Index"/>
  4675.                             </xsl:otherwise>
  4676.                         </xsl:choose>
  4677.                     </xsl:when>
  4678.                     <xsl:otherwise>
  4679.                         <xsl:variable name="preceding-column-row">
  4680.                             <xsl:call-template name="current-column-row-pos">
  4681.                                 <xsl:with-param name="current-column-row-list" select="$current-column-row-list[position()!=last()]"/>
  4682.                             </xsl:call-template>
  4683.                         </xsl:variable>
  4684.                         <xsl:choose>
  4685.                             <xsl:when test="$current-column-row/@ss:Span">
  4686.                                 <xsl:value-of select="1 + $current-column-row/@ss:Span + $preceding-column-row"/>
  4687.                             </xsl:when>
  4688.                             <xsl:otherwise>
  4689.                                 <xsl:value-of select="1 + $preceding-column-row"/>
  4690.                             </xsl:otherwise>
  4691.                         </xsl:choose>
  4692.                     </xsl:otherwise>
  4693.                 </xsl:choose>
  4694.             </xsl:when>
  4695.             <xsl:otherwise>0</xsl:otherwise>
  4696.         </xsl:choose>
  4697.     </xsl:template>
  4698.     <xsl:template name="Row-Data">
  4699.         <xsl:param name="lastrowpos"/>
  4700.         <xsl:param name="row-count"/>
  4701.         <xsl:param name="current-count"/>
  4702.         <xsl:param name="condition-pos-str"/>
  4703.         <xsl:if test="$current-count < ($row-count + 1)">
  4704.             <xsl:variable name="span-value">
  4705.                 <xsl:choose>
  4706.                     <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Index">
  4707.                         <xsl:choose>
  4708.                             <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Span">
  4709.                                 <xsl:value-of select="./ss:Table/ss:Row[position() = $current-count]/@ss:Index - $lastrowpos + ./ss:Table/ss:Row[position() = $current-count]/@ss:Span"/>
  4710.                             </xsl:when>
  4711.                             <xsl:otherwise>
  4712.                                 <xsl:value-of select="./ss:Table/ss:Row[position() = $current-count]/@ss:Index - $lastrowpos"/>
  4713.                             </xsl:otherwise>
  4714.                         </xsl:choose>
  4715.                     </xsl:when>
  4716.                     <xsl:otherwise>
  4717.                         <xsl:choose>
  4718.                             <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Span">
  4719.                                 <xsl:value-of select="./ss:Table/ss:Row[position() = $current-count]/@ss:Span + 1"/>
  4720.                             </xsl:when>
  4721.                             <xsl:otherwise>
  4722.                                 <xsl:value-of select="1"/>
  4723.                             </xsl:otherwise>
  4724.                         </xsl:choose>
  4725.                     </xsl:otherwise>
  4726.                 </xsl:choose>
  4727.             </xsl:variable>
  4728.             <xsl:variable name="current-index">
  4729.                 <xsl:choose>
  4730.                     <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Index">
  4731.                         <xsl:value-of select="./ss:Table/ss:Row[position() = $current-count]/@ss:Index"/>
  4732.                     </xsl:when>
  4733.                     <xsl:otherwise>
  4734.                         <xsl:value-of select="$lastrowpos + 1"/>
  4735.                     </xsl:otherwise>
  4736.                 </xsl:choose>
  4737.             </xsl:variable>
  4738.             <xsl:call-template name="get-row-span-in">
  4739.                 <xsl:with-param name="index-value" select="$lastrowpos"/>
  4740.                 <xsl:with-param name="span-value" select="$span-value"/>
  4741.                 <xsl:with-param name="pre-worksheet" select="count(preceding-sibling::ss:Worksheet)+1"/>
  4742.                 <xsl:with-param name="row-value" select="$current-count"/>
  4743.                 <xsl:with-param name="times" select="1"/>
  4744.                 <xsl:with-param name="current-index" select="$current-index"/>
  4745.                 <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4746.             </xsl:call-template>
  4747.             <xsl:if test="$current-count < $row-count">
  4748.                 <xsl:call-template name="Row-Data">
  4749.                     <xsl:with-param name="lastrowpos">
  4750.                         <xsl:choose>
  4751.                             <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Index">
  4752.                                 <xsl:choose>
  4753.                                     <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Span">
  4754.                                         <xsl:value-of select="./ss:Table/ss:Row[position() = $current-count]/@ss:Index + ./ss:Table/ss:Row[position() = $current-count]/@ss:Span"/>
  4755.                                     </xsl:when>
  4756.                                     <xsl:otherwise>
  4757.                                         <xsl:value-of select="./ss:Table/ss:Row[position() = $current-count]/@ss:Index"/>
  4758.                                     </xsl:otherwise>
  4759.                                 </xsl:choose>
  4760.                             </xsl:when>
  4761.                             <xsl:otherwise>
  4762.                                 <xsl:choose>
  4763.                                     <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Span">
  4764.                                         <xsl:value-of select="$lastrowpos + ./ss:Table/ss:Row[position() = $current-count]/@ss:Span + 1"/>
  4765.                                     </xsl:when>
  4766.                                     <xsl:otherwise>
  4767.                                         <xsl:value-of select="$lastrowpos + 1"/>
  4768.                                     </xsl:otherwise>
  4769.                                 </xsl:choose>
  4770.                             </xsl:otherwise>
  4771.                         </xsl:choose>
  4772.                     </xsl:with-param>
  4773.                     <xsl:with-param name="row-count" select="$row-count"/>
  4774.                     <xsl:with-param name="current-count" select="$current-count + 1"/>
  4775.                     <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4776.                 </xsl:call-template>
  4777.             </xsl:if>
  4778.         </xsl:if>
  4779.         <xsl:if test="$current-count = $row-count">
  4780.             <xsl:variable name="last-pos">
  4781.                 <xsl:choose>
  4782.                     <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Index">
  4783.                         <xsl:choose>
  4784.                             <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Span">
  4785.                                 <xsl:value-of select="./ss:Table/ss:Row[position() = $current-count]/@ss:Index + ./ss:Table/ss:Row[position() = $current-count]/@ss:Span"/>
  4786.                             </xsl:when>
  4787.                             <xsl:otherwise>
  4788.                                 <xsl:value-of select="./ss:Table/ss:Row[position() = $current-count]/@ss:Index"/>
  4789.                             </xsl:otherwise>
  4790.                         </xsl:choose>
  4791.                     </xsl:when>
  4792.                     <xsl:otherwise>
  4793.                         <xsl:choose>
  4794.                             <xsl:when test="./ss:Table/ss:Row[position() = $current-count]/@ss:Span">
  4795.                                 <xsl:value-of select="$lastrowpos + ./ss:Table/ss:Row[position() = $current-count]/@ss:Span + 1"/>
  4796.                             </xsl:when>
  4797.                             <xsl:otherwise>
  4798.                                 <xsl:value-of select="$lastrowpos + 1"/>
  4799.                             </xsl:otherwise>
  4800.                         </xsl:choose>
  4801.                     </xsl:otherwise>
  4802.                 </xsl:choose>
  4803.             </xsl:variable>
  4804.             <xsl:if test="./x:PageBreaks/x:RowBreaks/x:RowBreak/x:Row > ($last-pos - 1) or ./x:ConditionalFormatting">
  4805.                 <xsl:variable name="condition-row-max">
  4806.                     <xsl:call-template name="condition-row-col-pos-max">
  4807.                         <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4808.                         <xsl:with-param name="last-value" select="0"/>
  4809.                         <xsl:with-param name="div-value" select="'R'"/>
  4810.                     </xsl:call-template>
  4811.                 </xsl:variable>
  4812.                 <xsl:variable name="condition-col-max">
  4813.                     <xsl:call-template name="condition-row-col-pos-max">
  4814.                         <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4815.                         <xsl:with-param name="last-value" select="0"/>
  4816.                         <xsl:with-param name="div-value" select="'C'"/>
  4817.                     </xsl:call-template>
  4818.                 </xsl:variable>
  4819.                 <xsl:variable name="break-row-max">
  4820.                     <xsl:call-template name="break-row-beyond-max">
  4821.                         <xsl:with-param name="pos" select="1"/>
  4822.                         <xsl:with-param name="last-value" select="0"/>
  4823.                         <xsl:with-param name="count-value" select="count(./x:PageBreaks/x:RowBreaks/x:RowBreak)"/>
  4824.                     </xsl:call-template>
  4825.                 </xsl:variable>
  4826.                 <xsl:variable name="end-value">
  4827.                     <xsl:choose>
  4828.                         <xsl:when test="$condition-row-max < $break-row-max">
  4829.                             <xsl:value-of select="$break-row-max"/>
  4830.                         </xsl:when>
  4831.                         <xsl:otherwise>
  4832.                             <xsl:value-of select="$condition-row-max"/>
  4833.                         </xsl:otherwise>
  4834.                     </xsl:choose>
  4835.                 </xsl:variable>
  4836.                 <xsl:call-template name="get-row-beyond-last">
  4837.                     <xsl:with-param name="index-value" select="$last-pos + 1"/>
  4838.                     <xsl:with-param name="pre-worksheet" select="count(preceding-sibling::ss:Worksheet)+1"/>
  4839.                     <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4840.                     <xsl:with-param name="end-pos" select="$end-value"/>
  4841.                     <xsl:with-param name="total-col" select="$condition-col-max"/>
  4842.                 </xsl:call-template>
  4843.             </xsl:if>
  4844.             <!-- generates some special tags for whole column style. tom chen -->
  4845.             <xsl:if test="./ss:Table/ss:Column[@ss:StyleID] or ./ss:Table[@ss:StyleID]">
  4846.                 <table:table-row table:style-name="ro1" table:number-rows-repeated="31990">
  4847.                     <table:table-cell table:number-columns-repeated="256"/>
  4848.                 </table:table-row>
  4849.                 <table:table-row table:style-name="ro1">
  4850.                     <table:table-cell table:number-columns-repeated="256"/>
  4851.                 </table:table-row>
  4852.             </xsl:if>
  4853.         </xsl:if>
  4854.     </xsl:template>
  4855.     <xsl:template name="get-row-span-in">
  4856.         <!-- dealing the every row from lastrowpos to Index or ss:Span(if exists) one by one.tom chen -->
  4857.         <xsl:param name="index-value"/>
  4858.         <xsl:param name="span-value"/>
  4859.         <xsl:param name="pre-worksheet"/>
  4860.         <xsl:param name="row-value"/>
  4861.         <xsl:param name="times"/>
  4862.         <xsl:param name="current-index"/>
  4863.         <xsl:param name="condition-pos-str"/>
  4864.         <xsl:element name="table:table-row">
  4865.             <!-- generates default-cell-style-name tag if appearance of StyleID in tag of Table. -->
  4866.             <xsl:if test="./ss:Table[@ss:StyleID]">
  4867.                 <xsl:attribute name="table:default-cell-style-name"><xsl:value-of select="./ss:Table/@ss:StyleID"/></xsl:attribute>
  4868.             </xsl:if>
  4869.             <xsl:choose>
  4870.                 <xsl:when test="./x:PageBreaks/x:RowBreaks/x:RowBreak/x:Row = ($index-value + $times - 1)">
  4871.                     <xsl:choose>
  4872.                         <xsl:when test="($index-value + $times < $current-index) and ($current-index != 0)">
  4873.                             <xsl:attribute name="table:style-name"><xsl:value-of select="concat('rob',$pre-worksheet)"/></xsl:attribute>
  4874.                         </xsl:when>
  4875.                         <xsl:otherwise>
  4876.                             <xsl:attribute name="table:style-name"><xsl:value-of select="concat('rob', $pre-worksheet, '-', $row-value)"/></xsl:attribute>
  4877.                         </xsl:otherwise>
  4878.                     </xsl:choose>
  4879.                 </xsl:when>
  4880.                 <xsl:otherwise>
  4881.                     <xsl:choose>
  4882.                         <xsl:when test="($index-value + $times < $current-index) and ($current-index != 0)">
  4883.                             <xsl:attribute name="table:style-name"><xsl:value-of select="concat('ro',$pre-worksheet)"/></xsl:attribute>
  4884.                         </xsl:when>
  4885.                         <xsl:otherwise>
  4886.                             <xsl:attribute name="table:style-name"><xsl:value-of select="concat('ro', $pre-worksheet, '-', $row-value)"/></xsl:attribute>
  4887.                         </xsl:otherwise>
  4888.                     </xsl:choose>
  4889.                 </xsl:otherwise>
  4890.             </xsl:choose>
  4891.             <xsl:if test="./ss:Table/ss:Row[position() = $row-value]/@ss:Hidden = '1'">
  4892.                 <xsl:choose>
  4893.                     <xsl:when test="./ss:Table/ss:Row[position() = $row-value]/@ss:Span">
  4894.                         <xsl:if test="$index-value + $times > ($current-index - 1)">
  4895.                             <xsl:attribute name="table:visibility">collapse</xsl:attribute>
  4896.                         </xsl:if>
  4897.                     </xsl:when>
  4898.                     <xsl:otherwise>
  4899.                         <xsl:if test="$index-value + $times = $current-index">
  4900.                             <xsl:attribute name="table:visibility">collapse</xsl:attribute>
  4901.                         </xsl:if>
  4902.                     </xsl:otherwise>
  4903.                 </xsl:choose>
  4904.             </xsl:if>
  4905.             <xsl:if test="$index-value + $times < $current-index">
  4906.                 <xsl:variable name="current" select="concat('R',($index-value + $times),'C')"/>
  4907.                 <xsl:variable name="col-pos-max">
  4908.                     <xsl:call-template name="condition-row-col-pos-max">
  4909.                         <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4910.                         <xsl:with-param name="last-value" select="0"/>
  4911.                         <xsl:with-param name="div-value" select="'C'"/>
  4912.                     </xsl:call-template>
  4913.                 </xsl:variable>
  4914.                 <xsl:if test="contains($condition-pos-str,$current)">
  4915.                     <xsl:call-template name="get-cell-span-in">
  4916.                         <xsl:with-param name="row-pos" select="$index-value + $times"/>
  4917.                         <xsl:with-param name="c-start" select="1"/>
  4918.                         <xsl:with-param name="c-end" select="$col-pos-max"/>
  4919.                         <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4920.                     </xsl:call-template>
  4921.                 </xsl:if>
  4922.             </xsl:if>
  4923.             <xsl:if test="$index-value + $times = $current-index">
  4924.                 <xsl:call-template name="Cell-Data">
  4925.                     <xsl:with-param name="row-node" select="descendant-or-self::ss:Table/ss:Row[position() = $row-value]"/>
  4926.                     <xsl:with-param name="row-pos" select="$index-value + $times"/>
  4927.                     <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4928.                 </xsl:call-template>
  4929.             </xsl:if>
  4930.             <!-- generates code for whole row style. the filter will don't work the style of first row correctly if total cells more than 256. to be modified. tom chen -->
  4931.             <xsl:if test="./ss:Table[@ss:StyleID] or ./ss:Table/ss:Row[position() = $row-value]/@ss:StyleID or ./ss:Table/ss:Column[@ss:StyleID]">
  4932.                 <xsl:element name="table:table-cell">
  4933.                     <xsl:attribute name="table:number-columns-repeated"><xsl:value-of select="256"/></xsl:attribute>
  4934.                     <xsl:if test="$index-value + $times = $current-index and (./ss:Table/ss:Row[position() = $row-value]/@ss:StyleID)">
  4935.                         <xsl:attribute name="table:style-name"><xsl:value-of select="./ss:Table/ss:Row[position() = $row-value]/@ss:StyleID"/></xsl:attribute>
  4936.                     </xsl:if>
  4937.                     <xsl:if test="./ss:Table[@ss:StyleID]">
  4938.                         <xsl:attribute name="table:default-cell-style-name"><xsl:value-of select="./ss:Table/@ss:StyleID"/></xsl:attribute>
  4939.                     </xsl:if>
  4940.                 </xsl:element>
  4941.             </xsl:if>
  4942.         </xsl:element>
  4943.         <xsl:if test="$times < $span-value">
  4944.             <xsl:call-template name="get-row-span-in">
  4945.                 <xsl:with-param name="index-value" select="$index-value"/>
  4946.                 <xsl:with-param name="span-value" select="$span-value"/>
  4947.                 <xsl:with-param name="pre-worksheet" select="$pre-worksheet"/>
  4948.                 <xsl:with-param name="row-value" select="$row-value"/>
  4949.                 <xsl:with-param name="times" select="$times + 1"/>
  4950.                 <xsl:with-param name="current-index" select="$current-index"/>
  4951.                 <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  4952.             </xsl:call-template>
  4953.         </xsl:if>
  4954.     </xsl:template>
  4955.     <xsl:template name="get-column-span-in">
  4956.         <!-- dealing the every column from lastcolumnpos to Index or ss:Span(if exists) one by one.tom chen -->
  4957.         <xsl:param name="index-value"/>
  4958.         <xsl:param name="span-value"/>
  4959.         <xsl:param name="pre-worksheet"/>
  4960.         <xsl:param name="row-value"/>
  4961.         <xsl:param name="times"/>
  4962.         <xsl:param name="current-index"/>
  4963.         <xsl:if test="$times - 1 < $span-value">
  4964.             <xsl:element name="table:table-column">
  4965.                 <xsl:attribute name="table:default-cell-style-name"><xsl:choose><xsl:when test="($times + $index-value = $current-index) and ./ss:Table/ss:Column[position() = $row-value]/@ss:StyleID"><xsl:value-of select="./ss:Table/ss:Column[position() = $row-value]/@ss:StyleID"/></xsl:when><xsl:otherwise><xsl:choose><xsl:when test="./ss:Table[@ss:StyleID]"><xsl:value-of select="./ss:Table/@ss:StyleID"/></xsl:when><xsl:otherwise><xsl:value-of select="'Default'"/></xsl:otherwise></xsl:choose></xsl:otherwise></xsl:choose></xsl:attribute>
  4966.                 <xsl:choose>
  4967.                     <xsl:when test="./x:PageBreaks/x:ColBreaks/x:ColBreak/x:Column = ($index-value + $times - 1)">
  4968.                         <xsl:choose>
  4969.                             <xsl:when test="($index-value + $times < $current-index) and ($current-index != 0)">
  4970.                                 <xsl:attribute name="table:style-name"><xsl:value-of select="concat('cob',$pre-worksheet)"/></xsl:attribute>
  4971.                             </xsl:when>
  4972.                             <xsl:otherwise>
  4973.                                 <xsl:attribute name="table:style-name"><xsl:value-of select="concat('cob', $pre-worksheet, '-', $row-value)"/></xsl:attribute>
  4974.                             </xsl:otherwise>
  4975.                         </xsl:choose>
  4976.                     </xsl:when>
  4977.                     <xsl:otherwise>
  4978.                         <xsl:choose>
  4979.                             <xsl:when test="($index-value + $times < $current-index) and ($current-index != 0)">
  4980.                                 <xsl:attribute name="table:style-name"><xsl:value-of select="concat('co',$pre-worksheet)"/></xsl:attribute>
  4981.                             </xsl:when>
  4982.                             <xsl:otherwise>
  4983.                                 <xsl:attribute name="table:style-name"><xsl:value-of select="concat('co', $pre-worksheet, '-', $row-value)"/></xsl:attribute>
  4984.                             </xsl:otherwise>
  4985.                         </xsl:choose>
  4986.                     </xsl:otherwise>
  4987.                 </xsl:choose>
  4988.                 <xsl:if test="./ss:Table/ss:Column[position() = $row-value]/@ss:Hidden = '1'">
  4989.                     <xsl:choose>
  4990.                         <xsl:when test="./ss:Table/ss:Column[position() = $row-value]/@ss:Span">
  4991.                             <xsl:if test="$index-value + $times > ($current-index - 1)">
  4992.                                 <xsl:attribute name="table:visibility">collapse</xsl:attribute>
  4993.                             </xsl:if>
  4994.                         </xsl:when>
  4995.                         <xsl:otherwise>
  4996.                             <xsl:if test="$index-value + $times = $current-index">
  4997.                                 <xsl:attribute name="table:visibility">collapse</xsl:attribute>
  4998.                             </xsl:if>
  4999.                         </xsl:otherwise>
  5000.                     </xsl:choose>
  5001.                 </xsl:if>
  5002.             </xsl:element>
  5003.         </xsl:if>
  5004.         <xsl:if test="$times - 1 < $span-value">
  5005.             <xsl:call-template name="get-column-span-in">
  5006.                 <xsl:with-param name="index-value" select="$index-value"/>
  5007.                 <xsl:with-param name="span-value" select="$span-value"/>
  5008.                 <xsl:with-param name="pre-worksheet" select="$pre-worksheet"/>
  5009.                 <xsl:with-param name="row-value" select="$row-value"/>
  5010.                 <xsl:with-param name="times" select="$times + 1"/>
  5011.                 <xsl:with-param name="current-index" select="$current-index"/>
  5012.             </xsl:call-template>
  5013.         </xsl:if>
  5014.     </xsl:template>
  5015.     <xsl:template name="get-row-beyond-last">
  5016.         <!-- dealing the RowBreak after last row by recursion.tom chen -->
  5017.         <xsl:param name="index-value"/>
  5018.         <xsl:param name="pre-worksheet"/>
  5019.         <xsl:param name="condition-pos-str"/>
  5020.         <xsl:param name="end-pos"/>
  5021.         <xsl:param name="total-col"/>
  5022.         <xsl:variable name="current" select="concat('R',$index-value)"/>
  5023.         <xsl:element name="table:table-row">
  5024.             <xsl:choose>
  5025.                 <xsl:when test="./x:PageBreaks/x:RowBreaks/x:RowBreak/x:Row = ($index-value - 1)">
  5026.                     <xsl:attribute name="table:style-name"><xsl:value-of select="concat('rob',$pre-worksheet)"/></xsl:attribute>
  5027.                 </xsl:when>
  5028.                 <xsl:otherwise>
  5029.                     <xsl:attribute name="table:style-name"><xsl:value-of select="concat('ro',$pre-worksheet)"/></xsl:attribute>
  5030.                 </xsl:otherwise>
  5031.             </xsl:choose>
  5032.             <xsl:if test="./ss:Table/ss:Column[@ss:StyleID] or ./ss:Table[@ss:StyleID]">
  5033.                 <xsl:if test="256 - count(./ss:Table/ss:Column) > 0">
  5034.                     <table:table-cell table:number-columns-repeated="{256 - count(./ss:Table/ss:Column)}"/>
  5035.                 </xsl:if>
  5036.             </xsl:if>
  5037.             <xsl:if test="contains($condition-pos-str,$current)">
  5038.                 <xsl:call-template name="get-cell-span-in">
  5039.                     <xsl:with-param name="row-pos" select="$index-value"/>
  5040.                     <xsl:with-param name="c-start" select="1"/>
  5041.                     <xsl:with-param name="c-end" select="$total-col"/>
  5042.                     <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  5043.                 </xsl:call-template>
  5044.             </xsl:if>
  5045.         </xsl:element>
  5046.         <xsl:if test="$index-value < ($end-pos + 1)">
  5047.             <xsl:call-template name="get-row-beyond-last">
  5048.                 <xsl:with-param name="index-value" select="$index-value + 1"/>
  5049.                 <xsl:with-param name="pre-worksheet" select="$pre-worksheet"/>
  5050.                 <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  5051.                 <xsl:with-param name="end-pos" select="$end-pos"/>
  5052.                 <xsl:with-param name="total-col" select="$total-col"/>
  5053.             </xsl:call-template>
  5054.         </xsl:if>
  5055.     </xsl:template>
  5056.     <xsl:template name="break-row-beyond-max">
  5057.         <!-- returns the max position of the row from condition-pos-str.tom chen -->
  5058.         <xsl:param name="pos"/>
  5059.         <xsl:param name="last-value"/>
  5060.         <xsl:param name="count-value"/>
  5061.         <xsl:variable name="pre-value" select="./x:PageBreaks/x:RowBreaks/x:RowBreak[position() = $pos]/x:Row"/>
  5062.         <xsl:variable name="end-value">
  5063.             <xsl:choose>
  5064.                 <xsl:when test="$last-value < $pre-value">
  5065.                     <xsl:value-of select="$pre-value"/>
  5066.                 </xsl:when>
  5067.                 <xsl:otherwise>
  5068.                     <xsl:value-of select="$last-value"/>
  5069.                 </xsl:otherwise>
  5070.             </xsl:choose>
  5071.         </xsl:variable>
  5072.         <xsl:choose>
  5073.             <xsl:when test="$pos < $count-value">
  5074.                 <xsl:call-template name="break-row-beyond-max">
  5075.                     <xsl:with-param name="pos" select="$pos + 1"/>
  5076.                     <xsl:with-param name="last-value" select="$end-value"/>
  5077.                     <xsl:with-param name="count-value" select="$count-value"/>
  5078.                 </xsl:call-template>
  5079.             </xsl:when>
  5080.             <xsl:otherwise>
  5081.                 <xsl:value-of select="$end-value"/>
  5082.             </xsl:otherwise>
  5083.         </xsl:choose>
  5084.     </xsl:template>
  5085.     <xsl:template name="get-column-beyond-last">
  5086.         <!-- dealing the ColBreak after last column by recursion.tom chen -->
  5087.         <xsl:param name="index-value"/>
  5088.         <xsl:param name="pre-worksheet"/>
  5089.         <xsl:for-each select="./x:PageBreaks/x:ColBreaks/x:ColBreak">
  5090.             <xsl:variable name="each-column-value" select="./x:Column"/>
  5091.             <xsl:choose>
  5092.                 <xsl:when test="$each-column-value + 1 > $index-value">
  5093.                     <xsl:variable name="number-repeated">
  5094.                         <xsl:choose>
  5095.                             <xsl:when test="preceding-sibling::x:ColBreak[position()=count(.)]/x:Column + 1 = $index-value">
  5096.                                 <xsl:value-of select="$each-column-value - preceding-sibling::x:ColBreak[position()=count(.)]/x:Column - 1"/>
  5097.                             </xsl:when>
  5098.                             <xsl:when test="preceding-sibling::x:ColBreak[position()=count(.)]/x:Column + 1 > $index-value">
  5099.                                 <xsl:value-of select="$each-column-value - preceding-sibling::x:ColBreak[position()=count(.)]/x:Column - 1"/>
  5100.                             </xsl:when>
  5101.                             <xsl:otherwise>
  5102.                                 <xsl:value-of select="$each-column-value - $index-value + 1"/>
  5103.                             </xsl:otherwise>
  5104.                         </xsl:choose>
  5105.                     </xsl:variable>
  5106.                     <xsl:if test="$number-repeated > 0">
  5107.                         <xsl:element name="table:table-column">
  5108.                             <xsl:attribute name="table:style-name"><xsl:value-of select="'co1'"/></xsl:attribute>
  5109.                             <xsl:attribute name="table:number-columns-repeated"><xsl:value-of select="$number-repeated"/></xsl:attribute>
  5110.                         </xsl:element>
  5111.                     </xsl:if>
  5112.                     <xsl:element name="table:table-column">
  5113.                         <xsl:if test="./../../../ss:Table[@ss:StyleID]">
  5114.                             <xsl:attribute name="table:default-cell-style-name"><xsl:value-of select="./ss:Table/@ss:StyleID"/></xsl:attribute>
  5115.                         </xsl:if>
  5116.                         <xsl:attribute name="table:style-name"><xsl:value-of select="concat('cob',$pre-worksheet)"/></xsl:attribute>
  5117.                     </xsl:element>
  5118.                 </xsl:when>
  5119.                 <xsl:when test="$each-column-value + 1 = $index-value">
  5120.                     <xsl:element name="table:table-column">
  5121.                         <xsl:if test="./../../../ss:Table[@ss:StyleID]">
  5122.                             <xsl:attribute name="table:default-cell-style-name"><xsl:value-of select="./../../../ss:Table/@ss:StyleID"/></xsl:attribute>
  5123.                         </xsl:if>
  5124.                         <xsl:attribute name="table:style-name"><xsl:value-of select="concat('cob',$pre-worksheet)"/></xsl:attribute>
  5125.                     </xsl:element>
  5126.                 </xsl:when>
  5127.             </xsl:choose>
  5128.         </xsl:for-each>
  5129.     </xsl:template>
  5130.     <xsl:template name="get-cell-span-in">
  5131.         <!-- judge the position of the Cell in the condition-pos-str.tom chen -->
  5132.         <xsl:param name="row-pos"/>
  5133.         <xsl:param name="c-start"/>
  5134.         <xsl:param name="c-end"/>
  5135.         <xsl:param name="condition-pos-str"/>
  5136.         <xsl:variable name="current" select="concat('R',$row-pos,'C',$c-start,',')"/>
  5137.         <xsl:variable name="style-name">
  5138.             <xsl:choose>
  5139.                 <xsl:when test="contains($condition-pos-str,$current)">
  5140.                     <xsl:variable name="temp-str">
  5141.                         <xsl:call-template name="condition-str">
  5142.                             <xsl:with-param name="param-str" select="substring-before($condition-pos-str,$current)"/>
  5143.                         </xsl:call-template>
  5144.                     </xsl:variable>
  5145.                     <xsl:value-of select="concat('ce',$temp-str)"/>
  5146.                 </xsl:when>
  5147.                 <xsl:otherwise>
  5148.                     <xsl:choose>
  5149.                         <xsl:when test="../ss:Cell[position() = position() - 1]/@ss:StyleID">
  5150.                             <xsl:value-of select="../ss:Cell[position() = position() - 1]/@ss:StyleID "/>
  5151.                         </xsl:when>
  5152.                         <xsl:when test="../@ss:StyleID">
  5153.                             <xsl:value-of select="../@ss:StyleID"/>
  5154.                         </xsl:when>
  5155.                         <xsl:otherwise>
  5156.                             <xsl:value-of select="'Default'"/>
  5157.                         </xsl:otherwise>
  5158.                     </xsl:choose>
  5159.                 </xsl:otherwise>
  5160.             </xsl:choose>
  5161.         </xsl:variable>
  5162.         <xsl:if test="$c-start < $c-end">
  5163.             <xsl:call-template name="get-cell-condition-in">
  5164.                 <xsl:with-param name="style-name" select="$style-name"/>
  5165.             </xsl:call-template>
  5166.             <xsl:call-template name="get-cell-span-in">
  5167.                 <xsl:with-param name="row-pos" select="$row-pos"/>
  5168.                 <xsl:with-param name="c-start" select="$c-start + 1"/>
  5169.                 <xsl:with-param name="c-end" select="$c-end"/>
  5170.                 <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  5171.             </xsl:call-template>
  5172.         </xsl:if>
  5173.         <xsl:if test="$c-start = $c-end">
  5174.             <xsl:call-template name="get-cell-condition-in">
  5175.                 <xsl:with-param name="style-name" select="$style-name"/>
  5176.             </xsl:call-template>
  5177.         </xsl:if>
  5178.     </xsl:template>
  5179.     <xsl:template name="get-cell-condition-in">
  5180.         <!-- generates the style code for current tag of Cell one by one.tom chen -->
  5181.         <xsl:param name="style-name"/>
  5182.         <xsl:element name="table:table-cell">
  5183.             <xsl:if test="not( contains($style-name, 'Default'))">
  5184.                 <xsl:attribute name="table:style-name"><xsl:value-of select="$style-name"/></xsl:attribute>
  5185.             </xsl:if>
  5186.         </xsl:element>
  5187.     </xsl:template>
  5188.     <xsl:template name="condition-row-col-pos-max">
  5189.         <!-- returns the max position of the column or row from condition-pos-str.tom chen -->
  5190.         <xsl:param name="condition-pos-str"/>
  5191.         <xsl:param name="last-value"/>
  5192.         <xsl:param name="div-value"/>
  5193.         <xsl:variable name="pre-value">
  5194.             <xsl:choose>
  5195.                 <xsl:when test="$div-value = 'R'">
  5196.                     <xsl:value-of select="substring-before(substring-after($condition-pos-str,$div-value),'C')"/>
  5197.                 </xsl:when>
  5198.                 <xsl:otherwise>
  5199.                     <xsl:value-of select="substring-before(substring-after($condition-pos-str,$div-value),',')"/>
  5200.                 </xsl:otherwise>
  5201.             </xsl:choose>
  5202.         </xsl:variable>
  5203.         <xsl:variable name="end-value">
  5204.             <xsl:choose>
  5205.                 <xsl:when test="$last-value < $pre-value">
  5206.                     <xsl:value-of select="$pre-value"/>
  5207.                 </xsl:when>
  5208.                 <xsl:otherwise>
  5209.                     <xsl:value-of select="$last-value"/>
  5210.                 </xsl:otherwise>
  5211.             </xsl:choose>
  5212.         </xsl:variable>
  5213.         <xsl:choose>
  5214.             <xsl:when test="contains($condition-pos-str,$div-value)">
  5215.                 <xsl:call-template name="condition-row-col-pos-max">
  5216.                     <xsl:with-param name="condition-pos-str" select="substring-after($condition-pos-str,$div-value)"/>
  5217.                     <xsl:with-param name="last-value" select="$end-value"/>
  5218.                     <xsl:with-param name="div-value" select="$div-value"/>
  5219.                 </xsl:call-template>
  5220.             </xsl:when>
  5221.             <xsl:otherwise>
  5222.                 <xsl:value-of select="$end-value"/>
  5223.             </xsl:otherwise>
  5224.         </xsl:choose>
  5225.     </xsl:template>
  5226.     <xsl:template name="condition-str">
  5227.         <!-- returns the string of style name of condition-pos-str.tom chen -->
  5228.         <xsl:param name="param-str"/>
  5229.         <xsl:choose>
  5230.             <xsl:when test="contains($param-str,'(')">
  5231.                 <xsl:call-template name="condition-str">
  5232.                     <xsl:with-param name="param-str" select="substring-after($param-str,'(')"/>
  5233.                 </xsl:call-template>
  5234.             </xsl:when>
  5235.             <xsl:otherwise>
  5236.                 <xsl:value-of select="substring-before($param-str,':')"/>
  5237.             </xsl:otherwise>
  5238.         </xsl:choose>
  5239.     </xsl:template>
  5240.     <xsl:template name="Cell-Data">
  5241.         <xsl:param name="row-node"/>
  5242.         <xsl:param name="row-pos"/>
  5243.         <xsl:param name="condition-pos-str"/>
  5244.         <xsl:variable name="col-pos-max">
  5245.             <xsl:call-template name="condition-row-col-pos-max">
  5246.                 <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  5247.                 <xsl:with-param name="last-value" select="0"/>
  5248.                 <xsl:with-param name="div-value" select="'C'"/>
  5249.             </xsl:call-template>
  5250.         </xsl:variable>
  5251.         <xsl:choose>
  5252.             <xsl:when test="$row-node/ss:Cell">
  5253.                 <xsl:for-each select="$row-node/ss:Cell">
  5254.                     <xsl:variable name="column-pos">
  5255.                         <xsl:choose>
  5256.                             <xsl:when test="@ss:Index">
  5257.                                 <xsl:value-of select="@ss:Index"/>
  5258.                             </xsl:when>
  5259.                             <xsl:otherwise>
  5260.                                 <xsl:variable name="preceding-cell-pos">
  5261.                                     <xsl:call-template name="current-cell-pos">
  5262.                                         <xsl:with-param name="current-cell-list" select="preceding-sibling::ss:Cell"/>
  5263.                                     </xsl:call-template>
  5264.                                 </xsl:variable>
  5265.                                 <xsl:value-of select="$preceding-cell-pos + 1"/>
  5266.                             </xsl:otherwise>
  5267.                         </xsl:choose>
  5268.                     </xsl:variable>
  5269.                     <xsl:if test="@ss:Index">
  5270.                         <xsl:variable name="lastcellpos">
  5271.                             <xsl:call-template name="current-cell-pos">
  5272.                                 <xsl:with-param name="current-cell-list" select="preceding-sibling::ss:Cell"/>
  5273.                             </xsl:call-template>
  5274.                         </xsl:variable>
  5275.                         <xsl:variable name="last-repeated-pos">
  5276.                             <xsl:value-of select="@ss:Index - $lastcellpos - 1"/>
  5277.                         </xsl:variable>
  5278.                         <xsl:if test="$last-repeated-pos > 0">
  5279.                             <xsl:call-template name="get-cell-span-in">
  5280.                                 <xsl:with-param name="row-pos" select="$row-pos"/>
  5281.                                 <xsl:with-param name="c-start" select="$lastcellpos + 1"/>
  5282.                                 <xsl:with-param name="c-end" select="@ss:Index - 1"/>
  5283.                                 <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  5284.                             </xsl:call-template>
  5285.                         </xsl:if>
  5286.                     </xsl:if>
  5287.                     <xsl:element name="table:table-cell">
  5288.                         <xsl:variable name="current-str" select="concat('R',$row-pos,'C',$column-pos,',')"/>
  5289.                         <xsl:variable name="style-name">
  5290.                             <xsl:choose>
  5291.                                 <xsl:when test="contains($condition-pos-str,$current-str)">
  5292.                                     <xsl:variable name="temp-str">
  5293.                                         <xsl:call-template name="condition-str">
  5294.                                             <xsl:with-param name="param-str" select="substring-before($condition-pos-str,$current-str)"/>
  5295.                                         </xsl:call-template>
  5296.                                     </xsl:variable>
  5297.                                     <xsl:value-of select="concat('ce',$temp-str)"/>
  5298.                                 </xsl:when>
  5299.                                 <xsl:otherwise>
  5300.                                     <xsl:choose>
  5301.                                         <xsl:when test="@ss:StyleID">
  5302.                                             <xsl:value-of select="@ss:StyleID"/>
  5303.                                         </xsl:when>
  5304.                                         <xsl:when test="../@ss:StyleID">
  5305.                                             <xsl:value-of select="../@ss:StyleID"/>
  5306.                                         </xsl:when>
  5307.                                         <xsl:otherwise>
  5308.                                             <xsl:value-of select="'Default'"/>
  5309.                                         </xsl:otherwise>
  5310.                                     </xsl:choose>
  5311.                                 </xsl:otherwise>
  5312.                             </xsl:choose>
  5313.                         </xsl:variable>
  5314.                         <xsl:if test="not( contains($style-name, 'Default'))">
  5315.                             <xsl:attribute name="table:style-name"><xsl:value-of select="$style-name"/></xsl:attribute>
  5316.                         </xsl:if>
  5317.                         <xsl:if test="@ss:MergeAcross or @ss:MergeDown">
  5318.                             <xsl:choose>
  5319.                                 <xsl:when test="@ss:MergeAcross">
  5320.                                     <xsl:attribute name="table:number-columns-spanned"><xsl:value-of select="@ss:MergeAcross + 1"/></xsl:attribute>
  5321.                                 </xsl:when>
  5322.                                 <xsl:otherwise>
  5323.                                     <xsl:attribute name="table:number-columns-spanned">1</xsl:attribute>
  5324.                                 </xsl:otherwise>
  5325.                             </xsl:choose>
  5326.                             <xsl:choose>
  5327.                                 <xsl:when test="@ss:MergeDown">
  5328.                                     <xsl:attribute name="table:number-rows-spanned"><xsl:value-of select="@ss:MergeDown+1"/></xsl:attribute>
  5329.                                 </xsl:when>
  5330.                                 <xsl:otherwise>
  5331.                                     <xsl:attribute name="table:number-rows-spanned">1</xsl:attribute>
  5332.                                 </xsl:otherwise>
  5333.                             </xsl:choose>
  5334.                         </xsl:if>
  5335.                         <xsl:if test="@ss:Formula">
  5336.                             <!-- formula translation from Excel to Clac, quite complexive. :( glu -->
  5337.                             <xsl:variable name="calc-formula">
  5338.                                 <xsl:call-template name="translate-expression">
  5339.                                     <xsl:with-param name="cell-row-pos" select="$row-pos"/>
  5340.                                     <xsl:with-param name="cell-column-pos" select="$column-pos"/>
  5341.                                     <xsl:with-param name="expression" select="@ss:Formula"/>
  5342.                                 </xsl:call-template>
  5343.                             </xsl:variable>
  5344.                             <xsl:attribute name="table:formula"><xsl:value-of select="$calc-formula"/></xsl:attribute>
  5345.                         </xsl:if>
  5346.                         <xsl:variable name="style-id">
  5347.                             <xsl:value-of select="@ss:StyleID"/>
  5348.                         </xsl:variable>
  5349.                         <xsl:if test="ss:Data">
  5350.                             <xsl:variable name="data-format">
  5351.                                 <xsl:value-of select="/ss:Workbook/ss:Styles/ss:Style[@ss:ID=$style-id]/ss:NumberFormat/@ss:Format"/>
  5352.                             </xsl:variable>
  5353.                             <xsl:choose>
  5354.                                 <xsl:when test="ss:Data/@ss:Type = 'Number'">
  5355.                                     <xsl:choose>
  5356.                                         <xsl:when test="$data-format = 'Percent' or contains( $data-format, '%')">
  5357.                                             <xsl:attribute name="table:value-type">percentage</xsl:attribute>
  5358.                                         </xsl:when>
  5359.                                         <xsl:when test="contains( $data-format, 'currency') or ( contains( $data-format, '[$') and (not( contains( $data-format, '[$-') )) )">
  5360.                                             <xsl:attribute name="table:value-type">currency</xsl:attribute>
  5361.                                         </xsl:when>
  5362.                                         <xsl:otherwise>
  5363.                                             <xsl:attribute name="table:value-type">float</xsl:attribute>
  5364.                                         </xsl:otherwise>
  5365.                                     </xsl:choose>
  5366.                                     <xsl:attribute name="table:value"><xsl:value-of select="ss:Data"/></xsl:attribute>
  5367.                                 </xsl:when>
  5368.                                 <xsl:when test="ss:Data/@ss:Type = 'DateTime'">
  5369.                                     <xsl:choose>
  5370.                                         <xsl:when test="(contains( $data-format, 'Date') or contains($data-format,'y') or contains($data-format,'g') or contains($data-format,'d') or contains($data-format,'e') or starts-with( substring( ss:Data, 11), 'T00:00:00.000' ) ) and (not (contains( $data-format, 'Time') ) )">
  5371.                                             <xsl:attribute name="table:value-type">date</xsl:attribute>
  5372.                                             <xsl:attribute name="table:date-value"><xsl:value-of select="substring(ss:Data, 1, 19)"/></xsl:attribute>
  5373.                                         </xsl:when>
  5374.                                         <xsl:otherwise>
  5375.                                             <xsl:attribute name="table:value-type">time</xsl:attribute>
  5376.                                             <xsl:attribute name="table:time-value"><xsl:value-of select="concat('P',substring(ss:Data, 11, 3), 'H', substring(ss:Data, 15, 2), 'M', substring(ss:Data, 18,2), ',', substring-after( ss:Data, '.'), '000S')"/></xsl:attribute>
  5377.                                         </xsl:otherwise>
  5378.                                     </xsl:choose>
  5379.                                 </xsl:when>
  5380.                                 <xsl:when test="ss:Data/@ss:Type = 'Boolean'">
  5381.                                     <xsl:attribute name="table:value-type">boolean</xsl:attribute>
  5382.                                 </xsl:when>
  5383.                                 <xsl:when test="ss:Data/@ss:Type = 'String'">
  5384.                                     <xsl:attribute name="table:value-type">string</xsl:attribute>
  5385.                                 </xsl:when>
  5386.                                 <xsl:otherwise/>
  5387.                             </xsl:choose>
  5388.                         </xsl:if>
  5389.                         <xsl:apply-templates select="ss:Comment"/>
  5390.                         <xsl:if test="ss:Data">
  5391.                             <text:p>
  5392.                                 <xsl:choose>
  5393.                                     <xsl:when test="ss:Data/descendant-or-self::*[(namespace-uri()='http://www.w3.org/TR/REC-html40' or child::html:*) and text() and string-length(.) > 0]">
  5394.                                         <xsl:for-each select="descendant-or-self::*[(namespace-uri()='http://www.w3.org/TR/REC-html40' or child::html:*) and text() and string-length(.) > 0]">
  5395.                                             <text:span text:style-name="{concat( $style-id, 'T', count(preceding::ss:Data[child::html:*]), '_', position())}">
  5396.                                                 <xsl:value-of select="text()"/>
  5397.                                             </text:span>
  5398.                                         </xsl:for-each>
  5399.                                     </xsl:when>
  5400.                                     <xsl:when test="contains( /ss:Workbook/ss:Styles/ss:Style[@ss:ID=$style-id]/ss:Font/@ss:VerticalAlign, 'script')">
  5401.                                         <text:span text:style-name="{concat( $style-id, 'T0')}">
  5402.                                             <xsl:choose>
  5403.                                                 <xsl:when test="@ss:HRef">
  5404.                                                     <text:a xlink:href="{@ss:HRef}">
  5405.                                                         <xsl:value-of select="ss:Data"/>
  5406.                                                     </text:a>
  5407.                                                 </xsl:when>
  5408.                                                 <xsl:otherwise>
  5409.                                                     <xsl:value-of select="ss:Data"/>
  5410.                                                 </xsl:otherwise>
  5411.                                             </xsl:choose>
  5412.                                         </text:span>
  5413.                                     </xsl:when>
  5414.                                     <xsl:when test="@ss:HRef">
  5415.                                         <text:a xlink:href="{@ss:HRef}">
  5416.                                             <xsl:value-of select="ss:Data"/>
  5417.                                         </text:a>
  5418.                                     </xsl:when>
  5419.                                     <xsl:otherwise>
  5420.                                         <xsl:value-of select="ss:Data"/>
  5421.                                     </xsl:otherwise>
  5422.                                 </xsl:choose>
  5423.                             </text:p>
  5424.                         </xsl:if>
  5425.                     </xsl:element>
  5426.                     <xsl:if test="@ss:MergeAcross">
  5427.                         <xsl:element name="table:covered-table-cell">
  5428.                             <xsl:if test="@ss:MergeAcross > 1">
  5429.                                 <xsl:attribute name="table:number-columns-repeated"><xsl:value-of select="@ss:MergeAcross"/></xsl:attribute>
  5430.                             </xsl:if>
  5431.                         </xsl:element>
  5432.                     </xsl:if>
  5433.                     <xsl:if test="position() = count(../ss:Cell) and ../../../x:ConditionalFormatting">
  5434.                         <!-- at the last position of the Cell tag,inspecting the following cell before condition-row-col-pos-max.tom chen -->
  5435.                         <xsl:call-template name="get-cell-span-in">
  5436.                             <xsl:with-param name="row-pos" select="$row-pos"/>
  5437.                             <xsl:with-param name="c-start" select="$column-pos + 1"/>
  5438.                             <xsl:with-param name="c-end" select="$col-pos-max"/>
  5439.                             <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  5440.                         </xsl:call-template>
  5441.                     </xsl:if>
  5442.                 </xsl:for-each>
  5443.             </xsl:when>
  5444.             <xsl:otherwise>
  5445.                 <xsl:variable name="current" select="concat('R',$row-pos,'C')"/>
  5446.                 <xsl:if test="contains($condition-pos-str,$current)">
  5447.                     <xsl:call-template name="get-cell-span-in">
  5448.                         <xsl:with-param name="row-pos" select="$row-pos"/>
  5449.                         <xsl:with-param name="c-start" select="1"/>
  5450.                         <xsl:with-param name="c-end" select="$col-pos-max"/>
  5451.                         <xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
  5452.                     </xsl:call-template>
  5453.                 </xsl:if>
  5454.             </xsl:otherwise>
  5455.         </xsl:choose>
  5456.     </xsl:template>
  5457.     <xsl:template name="condition-row-column-string">
  5458.         <!-- returns a string with structer,including row\column position by extraction from x:ConditionalFormatting.tom chen -->
  5459.         <xsl:param name="last"/>
  5460.         <xsl:param name="total"/>
  5461.         <xsl:param name="index"/>
  5462.         <xsl:variable name="table-pos" select="count(preceding-sibling::ss:Worksheet)+1"/>
  5463.         <xsl:variable name="current">
  5464.             <xsl:call-template name="parse-range">
  5465.                 <xsl:with-param name="range-value" select="./x:ConditionalFormatting[position() = $index]/x:Range"/>
  5466.             </xsl:call-template>
  5467.         </xsl:variable>
  5468.         <xsl:variable name="current-value" select="concat('(',$table-pos,'-',$index,':', $current,');')"/>
  5469.         <xsl:if test="$index < $total">
  5470.             <xsl:call-template name="condition-row-column-string">
  5471.                 <xsl:with-param name="last" select="concat($last, $current-value)"/>
  5472.                 <xsl:with-param name="total" select="$total"/>
  5473.                 <xsl:with-param name="index" select="$index + 1"/>
  5474.             </xsl:call-template>
  5475.         </xsl:if>
  5476.         <xsl:if test="$index = $total">
  5477.             <xsl:value-of select="concat($last, $current-value)"/>
  5478.         </xsl:if>
  5479.     </xsl:template>
  5480.     <xsl:template name="parse-range">
  5481.         <!-- returns a string,input param:the value of x:Range.tom chen -->
  5482.         <xsl:param name="range-value"/>
  5483.         <xsl:param name="last"/>
  5484.         <xsl:variable name="first-pit">
  5485.             <xsl:choose>
  5486.                 <xsl:when test="contains($range-value,',')">
  5487.                     <xsl:value-of select="substring-before($range-value,',')"/>
  5488.                 </xsl:when>
  5489.                 <xsl:otherwise>
  5490.                     <xsl:value-of select="$range-value"/>
  5491.                 </xsl:otherwise>
  5492.             </xsl:choose>
  5493.         </xsl:variable>
  5494.         <xsl:variable name="current">
  5495.             <xsl:choose>
  5496.                 <xsl:when test="contains($first-pit,':')">
  5497.                     <xsl:variable name="R-start" select="substring-before(substring-after($first-pit,'R'),'C')"/>
  5498.                     <xsl:variable name="C-start" select="substring-before(substring-after($first-pit,'C'),':')"/>
  5499.                     <xsl:variable name="second-pit" select="substring-after($first-pit,':')"/>
  5500.                     <xsl:variable name="R-end" select="substring-before(substring-after($second-pit,'R'),'C')"/>
  5501.                     <xsl:variable name="C-end" select="substring-after($second-pit,'C')"/>
  5502.                     <xsl:variable name="the-str">
  5503.                         <xsl:call-template name="condition-rc-str">
  5504.                             <xsl:with-param name="r-start" select="$R-start"/>
  5505.                             <xsl:with-param name="r-end" select="$R-end"/>
  5506.                             <xsl:with-param name="c-start" select="$C-start"/>
  5507.                             <xsl:with-param name="c-end" select="$C-end"/>
  5508.                             <xsl:with-param name="last" select="''"/>
  5509.                         </xsl:call-template>
  5510.                     </xsl:variable>
  5511.                     <xsl:value-of select="$the-str"/>
  5512.                 </xsl:when>
  5513.                 <xsl:otherwise>
  5514.                     <xsl:value-of select="concat($first-pit,',')"/>
  5515.                 </xsl:otherwise>
  5516.             </xsl:choose>
  5517.         </xsl:variable>
  5518.         <xsl:choose>
  5519.             <xsl:when test="contains($range-value,',')">
  5520.                 <xsl:call-template name="parse-range">
  5521.                     <xsl:with-param name="range-value" select="substring-after($range-value,',')"/>
  5522.                     <xsl:with-param name="last" select="concat($last,$current)"/>
  5523.                 </xsl:call-template>
  5524.             </xsl:when>
  5525.             <xsl:otherwise>
  5526.                 <xsl:value-of select="concat($last,$current)"/>
  5527.             </xsl:otherwise>
  5528.         </xsl:choose>
  5529.     </xsl:template>
  5530.     <xsl:template name="condition-rc-str">
  5531.         <!-- dealing the range of row\column.tom chen -->
  5532.         <xsl:param name="r-start"/>
  5533.         <xsl:param name="r-end"/>
  5534.         <xsl:param name="c-start"/>
  5535.         <xsl:param name="c-end"/>
  5536.         <xsl:param name="last"/>
  5537.         <xsl:variable name="current">
  5538.             <xsl:call-template name="condition-c-str">
  5539.                 <xsl:with-param name="rc-str" select="concat('R',$r-start)"/>
  5540.                 <xsl:with-param name="start" select="$c-start"/>
  5541.                 <xsl:with-param name="end" select="$c-end"/>
  5542.                 <xsl:with-param name="last" select="''"/>
  5543.             </xsl:call-template>
  5544.         </xsl:variable>
  5545.         <xsl:if test="$r-start < $r-end">
  5546.             <xsl:call-template name="condition-rc-str">
  5547.                 <xsl:with-param name="r-start" select="$r-start + 1"/>
  5548.                 <xsl:with-param name="r-end" select="$r-end"/>
  5549.                 <xsl:with-param name="c-start" select="$c-start"/>
  5550.                 <xsl:with-param name="c-end" select="$c-end"/>
  5551.                 <xsl:with-param name="last" select="concat($last,$current)"/>
  5552.             </xsl:call-template>
  5553.         </xsl:if>
  5554.         <xsl:if test="$r-start = $r-end">
  5555.             <xsl:value-of select="concat($last,$current)"/>
  5556.         </xsl:if>
  5557.     </xsl:template>
  5558.     <xsl:template name="condition-c-str">
  5559.         <xsl:param name="rc-str"/>
  5560.         <xsl:param name="start"/>
  5561.         <xsl:param name="end"/>
  5562.         <xsl:param name="last"/>
  5563.         <xsl:variable name="current" select="concat($rc-str,'C',$start,',')"/>
  5564.         <xsl:if test="$start < $end">
  5565.             <xsl:call-template name="condition-c-str">
  5566.                 <xsl:with-param name="rc-str" select="$rc-str"/>
  5567.                 <xsl:with-param name="start" select="$start + 1"/>
  5568.                 <xsl:with-param name="end" select="$end"/>
  5569.                 <xsl:with-param name="last" select="concat($last,$current)"/>
  5570.             </xsl:call-template>
  5571.         </xsl:if>
  5572.         <xsl:if test="$start = $end">
  5573.             <xsl:value-of select="concat($last,$current)"/>
  5574.         </xsl:if>
  5575.     </xsl:template>
  5576.     <xsl:template match="ss:Data">
  5577.         <xsl:for-each select="descendant-or-self::*[(namespace-uri()='http://www.w3.org/TR/REC-html40' or child::html:*) and text() and string-length(.)>0]">
  5578.             <style:style style:name="{concat(ancestor::ss:Cell/@ss:StyleID,'T',count(preceding::ss:Data[child::html:*]), '_', position())}" style:family="text">
  5579.                 <xsl:element name="style:properties">
  5580.                     <xsl:if test="ancestor-or-self::html:Font/@html:Face">
  5581.                         <xsl:attribute name="style:font-name"><xsl:value-of select="ancestor-or-self::html:Font/@html:Face"/></xsl:attribute>
  5582.                     </xsl:if>
  5583.                     <xsl:if test="ancestor-or-self::html:Font/@html:Size">
  5584.                         <xsl:attribute name="fo:font-size"><xsl:value-of select="concat(ancestor-or-self::html:Font/@html:Size,'pt')"/></xsl:attribute>
  5585.                         <xsl:attribute name="style:font-size-asian"><xsl:value-of select="concat(ancestor-or-self::html:Font/@html:Size,'pt')"/></xsl:attribute>
  5586.                         <xsl:attribute name="style:font-size-complex"><xsl:value-of select="concat(ancestor-or-self::html:Font/@html:Size,'pt')"/></xsl:attribute>
  5587.                     </xsl:if>
  5588.                     <xsl:if test="ancestor-or-self::html:Font/@html:Color">
  5589.                         <xsl:attribute name="fo:color"><xsl:value-of select="ancestor-or-self::html:Font/@html:Color"/></xsl:attribute>
  5590.                     </xsl:if>
  5591.                     <xsl:if test="ancestor-or-self::html:B">
  5592.                         <xsl:attribute name="fo:font-weight">bold</xsl:attribute>
  5593.                         <xsl:attribute name="style:font-weight-asian">bold</xsl:attribute>
  5594.                         <xsl:attribute name="style:font-weight-complex">bold</xsl:attribute>
  5595.                     </xsl:if>
  5596.                     <xsl:if test="ancestor-or-self::html:I">
  5597.                         <xsl:attribute name="fo:font-style">italic</xsl:attribute>
  5598.                         <xsl:attribute name="style:font-style-asian">italic</xsl:attribute>
  5599.                         <xsl:attribute name="style:font-style-complex">italic</xsl:attribute>
  5600.                     </xsl:if>
  5601.                     <xsl:if test="ancestor-or-self::html:U">
  5602.                         <xsl:attribute name="style:text-underline">single</xsl:attribute>
  5603.                     </xsl:if>
  5604.                     <xsl:if test="ancestor-or-self::html:S">
  5605.                         <xsl:attribute name="style:text-crossing-out">single-line</xsl:attribute>
  5606.                     </xsl:if>
  5607.                     <xsl:if test="ancestor-or-self::html:Sup">
  5608.                         <xsl:attribute name="style:text-position">33% 58%</xsl:attribute>
  5609.                     </xsl:if>
  5610.                     <xsl:if test="ancestor-or-self::html:Sub">
  5611.                         <xsl:attribute name="style:text-position">-33% 58%</xsl:attribute>
  5612.                     </xsl:if>
  5613.                 </xsl:element>
  5614.             </style:style>
  5615.         </xsl:for-each>
  5616.     </xsl:template>
  5617.     <xsl:template name="get-pos-content">
  5618.         <xsl:param name="content"/>
  5619.         <xsl:param name="pos"/>
  5620.         <xsl:choose>
  5621.             <xsl:when test="$pos = 'left'">
  5622.                 <xsl:choose>
  5623.                     <xsl:when test="contains($content,'&C')">
  5624.                         <xsl:value-of select="substring-before( substring-after( $content, '&L'), '&C')"/>
  5625.                     </xsl:when>
  5626.                     <xsl:when test="contains($content,'&R')">
  5627.                         <xsl:value-of select="substring-before( substring-after( $content, '&L'), '&R')"/>
  5628.                     </xsl:when>
  5629.                     <xsl:when test="contains($content,'&L')">
  5630.                         <xsl:value-of select="substring-after( $content, '&L')"/>
  5631.                     </xsl:when>
  5632.                     <xsl:otherwise/>
  5633.                 </xsl:choose>
  5634.             </xsl:when>
  5635.             <xsl:when test="$pos = 'center'">
  5636.                 <xsl:choose>
  5637.                     <xsl:when test="contains($content,'&R')">
  5638.                         <xsl:value-of select="substring-before( substring-after( $content, '&C'), '&R')"/>
  5639.                     </xsl:when>
  5640.                     <xsl:when test="contains($content,'&C')">
  5641.                         <xsl:value-of select="substring-after( $content, '&C')"/>
  5642.                     </xsl:when>
  5643.                     <xsl:when test="contains($content,'&L')"/>
  5644.                     <xsl:otherwise>
  5645.                         <xsl:value-of select="$content"/>
  5646.                     </xsl:otherwise>
  5647.                 </xsl:choose>
  5648.             </xsl:when>
  5649.             <xsl:when test="$pos = 'right'">
  5650.                 <xsl:value-of select="substring-after( $content, '&R')"/>
  5651.             </xsl:when>
  5652.         </xsl:choose>
  5653.     </xsl:template>
  5654.     <xsl:template match="@x:Data">
  5655.         <xsl:variable name="style-name-header">
  5656.             <xsl:value-of select="concat(ancestor::ss:Worksheet/@ss:Name, substring(name(..),1,1))"/>
  5657.         </xsl:variable>
  5658.         <xsl:variable name="left-style-data">
  5659.             <xsl:call-template name="get-pos-content">
  5660.                 <xsl:with-param name="content" select="."/>
  5661.                 <xsl:with-param name="pos" select="'left'"/>
  5662.             </xsl:call-template>
  5663.         </xsl:variable>
  5664.         <xsl:if test="string-length($left-style-data)>0 and contains($left-style-data,'&')">
  5665.             <xsl:call-template name="create-header-footer-style">
  5666.                 <xsl:with-param name="style-name-header" select="concat($style-name-header,'L')"/>
  5667.                 <xsl:with-param name="style-data" select="$left-style-data"/>
  5668.                 <xsl:with-param name="index" select="0"/>
  5669.                 <xsl:with-param name="current-pos" select="1"/>
  5670.             </xsl:call-template>
  5671.         </xsl:if>
  5672.         <xsl:variable name="center-style-data">
  5673.             <xsl:call-template name="get-pos-content">
  5674.                 <xsl:with-param name="content" select="."/>
  5675.                 <xsl:with-param name="pos" select="'center'"/>
  5676.             </xsl:call-template>
  5677.         </xsl:variable>
  5678.         <xsl:if test="string-length($center-style-data)>0 and contains($center-style-data,'&')">
  5679.             <xsl:call-template name="create-header-footer-style">
  5680.                 <xsl:with-param name="style-name-header" select="concat($style-name-header,'C')"/>
  5681.                 <xsl:with-param name="style-data" select="$center-style-data"/>
  5682.                 <xsl:with-param name="index" select="0"/>
  5683.                 <xsl:with-param name="current-pos" select="1"/>
  5684.             </xsl:call-template>
  5685.         </xsl:if>
  5686.         <xsl:variable name="right-style-data">
  5687.             <xsl:call-template name="get-pos-content">
  5688.                 <xsl:with-param name="content" select="."/>
  5689.                 <xsl:with-param name="pos" select="'right'"/>
  5690.             </xsl:call-template>
  5691.         </xsl:variable>
  5692.         <xsl:if test="string-length($right-style-data)>0 and contains($right-style-data,'&')">
  5693.             <xsl:call-template name="create-header-footer-style">
  5694.                 <xsl:with-param name="style-name-header" select="concat($style-name-header,'R')"/>
  5695.                 <xsl:with-param name="style-data" select="$right-style-data"/>
  5696.                 <xsl:with-param name="index" select="0"/>
  5697.                 <xsl:with-param name="current-pos" select="1"/>
  5698.             </xsl:call-template>
  5699.         </xsl:if>
  5700.     </xsl:template>
  5701.     <xsl:template name="create-header-footer-style">
  5702.         <xsl:param name="style-name-header"/>
  5703.         <xsl:param name="style-data"/>
  5704.         <xsl:param name="index"/>
  5705.         <xsl:param name="current-pos"/>
  5706.         <xsl:variable name="current-style-data">
  5707.             <xsl:value-of select="substring($style-data,$current-pos)"/>
  5708.         </xsl:variable>
  5709.         <xsl:choose>
  5710.             <xsl:when test="starts-with($current-style-data,'&D') or starts-with($current-style-data,'&T') or starts-with($current-style-data,'&P') or starts-with($current-style-data,'&N') or starts-with($current-style-data,'&A') or starts-with($current-style-data,'&F') or starts-with($current-style-data,'&Z')">
  5711.                 <xsl:call-template name="create-header-footer-style">
  5712.                     <xsl:with-param name="style-name-header" select="$style-name-header"/>
  5713.                     <xsl:with-param name="style-data" select="$style-data"/>
  5714.                     <xsl:with-param name="index" select="$index"/>
  5715.                     <xsl:with-param name="current-pos" select="$current-pos +2"/>
  5716.                 </xsl:call-template>
  5717.             </xsl:when>
  5718.             <xsl:when test="starts-with($current-style-data,'&')">
  5719.                 <xsl:element name="style:style">
  5720.                     <xsl:attribute name="style:name"><xsl:value-of select="concat($style-name-header,$index)"/></xsl:attribute>
  5721.                     <xsl:attribute name="style:family">text</xsl:attribute>
  5722.                     <xsl:element name="style:properties">
  5723.                         <xsl:call-template name="process-header-footer-style-properties">
  5724.                             <xsl:with-param name="style-data" select="$style-data"/>
  5725.                             <xsl:with-param name="current-pos" select="$current-pos"/>
  5726.                         </xsl:call-template>
  5727.                     </xsl:element>
  5728.                 </xsl:element>
  5729.                 <xsl:variable name="next-style-header-pos">
  5730.                     <xsl:call-template name="get-current-content-pos">
  5731.                         <xsl:with-param name="style-data" select="$style-data"/>
  5732.                         <xsl:with-param name="current-pos" select="$current-pos"/>
  5733.                     </xsl:call-template>
  5734.                 </xsl:variable>
  5735.                 <xsl:call-template name="create-header-footer-style">
  5736.                     <xsl:with-param name="style-name-header" select="$style-name-header"/>
  5737.                     <xsl:with-param name="style-data" select="$style-data"/>
  5738.                     <xsl:with-param name="index" select="$index+1"/>
  5739.                     <xsl:with-param name="current-pos" select="$next-style-header-pos"/>
  5740.                 </xsl:call-template>
  5741.             </xsl:when>
  5742.             <xsl:when test="contains($current-style-data,'&')">
  5743.                 <xsl:variable name="temp" select="substring-before($current-style-data,'&')"/>
  5744.                 <xsl:call-template name="create-header-footer-style">
  5745.                     <xsl:with-param name="style-name-header" select="$style-name-header"/>
  5746.                     <xsl:with-param name="style-data" select="$style-data"/>
  5747.                     <xsl:with-param name="index" select="$index"/>
  5748.                     <xsl:with-param name="current-pos" select="string-length($temp)+$current-pos"/>
  5749.                 </xsl:call-template>
  5750.             </xsl:when>
  5751.             <xsl:otherwise/>
  5752.         </xsl:choose>
  5753.     </xsl:template>
  5754.     <xsl:template name="process-header-footer-style-properties">
  5755.         <xsl:param name="style-data"/>
  5756.         <xsl:param name="current-pos"/>
  5757.         <xsl:variable name="current-style-data">
  5758.             <xsl:value-of select="substring($style-data,$current-pos)"/>
  5759.         </xsl:variable>
  5760.         <xsl:choose>
  5761.             <!-- stack operations necessary. glu -->
  5762.             <xsl:when test="starts-with($current-style-data,'&"')">
  5763.                 <xsl:attribute name="style:font-name"><xsl:value-of select="substring-before(substring-after($current-style-data,'&"'),',')"/></xsl:attribute>
  5764.                 <xsl:if test="contains(substring-before(substring-after($current-style-data,','),'"'),'Bold')">
  5765.                     <xsl:attribute name="fo:font-weight">bold</xsl:attribute>
  5766.                     <xsl:attribute name="style:font-weight-asian">bold</xsl:attribute>
  5767.                     <xsl:attribute name="style:font-weight-complex">bold</xsl:attribute>
  5768.                 </xsl:if>
  5769.                 <xsl:if test="contains(substring-before(substring-after($current-style-data,','),'"'),'Italic')">
  5770.                     <xsl:attribute name="fo:font-style">italic</xsl:attribute>
  5771.                     <xsl:attribute name="style:font-style-asian">italic</xsl:attribute>
  5772.                     <xsl:attribute name="style:font-style-complex">italic</xsl:attribute>
  5773.                 </xsl:if>
  5774.                 <xsl:variable name="temp" select="substring-before(substring($style-data,$current-pos+2),'"')"/>
  5775.                 <xsl:call-template name="process-header-footer-style-properties">
  5776.                     <xsl:with-param name="style-data" select="$style-data"/>
  5777.                     <xsl:with-param name="current-pos" select="string-length($temp)+$current-pos+3"/>
  5778.                 </xsl:call-template>
  5779.             </xsl:when>
  5780.             <xsl:when test="starts-with($current-style-data,'&0') or starts-with($current-style-data,'&1') or starts-with($current-style-data,'&2') or starts-with($current-style-data,'&3') or starts-with($current-style-data,'&4') or starts-with($current-style-data,'&5') or starts-with($current-style-data,'&6') or starts-with($current-style-data,'&7') or starts-with($current-style-data,'&8') or starts-with($current-style-data,'&9')">
  5781.                 <xsl:variable name="font-size-length">
  5782.                     <xsl:call-template name="get-digit-length">
  5783.                         <xsl:with-param name="complexive-string" select="substring-after($current-style-data,'&')"/>
  5784.                     </xsl:call-template>
  5785.                 </xsl:variable>
  5786.                 <xsl:attribute name="fo:font-size"><xsl:value-of select="concat(substring($current-style-data,2,$font-size-length),'pt')"/></xsl:attribute>
  5787.                 <xsl:call-template name="process-header-footer-style-properties">
  5788.                     <xsl:with-param name="style-data" select="$style-data"/>
  5789.                     <xsl:with-param name="current-pos" select="$current-pos + 1 + $font-size-length"/>
  5790.                 </xsl:call-template>
  5791.             </xsl:when>
  5792.             <!-- dont' consider tangled or adjoined '&X' and '&Y', '&U' & '&E', processing-check is necessary, too complex. :( glu -->
  5793.             <xsl:when test="starts-with($current-style-data,'&X')">
  5794.                 <xsl:variable name="superscript-count-before">
  5795.                     <xsl:call-template name="get-substyle-count-in-data">
  5796.                         <xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
  5797.                         <xsl:with-param name="substyle" select="'&X'"/>
  5798.                         <xsl:with-param name="count" select="0"/>
  5799.                     </xsl:call-template>
  5800.                 </xsl:variable>
  5801.                 <xsl:if test="$superscript-count-before mod 2 = 0">
  5802.                     <xsl:attribute name="style:text-position">33% 58%</xsl:attribute>
  5803.                 </xsl:if>
  5804.                 <xsl:call-template name="process-header-footer-style-properties">
  5805.                     <xsl:with-param name="style-data" select="$style-data"/>
  5806.                     <xsl:with-param name="current-pos" select="$current-pos + 2"/>
  5807.                 </xsl:call-template>
  5808.             </xsl:when>
  5809.             <xsl:when test="starts-with($current-style-data,'&B')">
  5810.                 <xsl:variable name="subscript-count-before">
  5811.                     <xsl:call-template name="get-substyle-count-in-data">
  5812.                         <xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
  5813.                         <xsl:with-param name="substyle" select="'&B'"/>
  5814.                         <xsl:with-param name="count" select="0"/>
  5815.                     </xsl:call-template>
  5816.                 </xsl:variable>
  5817.                 <xsl:if test="$subscript-count-before mod 2 = 0">
  5818.                     <xsl:attribute name="fo:font-weight">bold</xsl:attribute>
  5819.                     <xsl:attribute name="style:font-weight-asian">bold</xsl:attribute>
  5820.                     <xsl:attribute name="style:font-weight-complex">bold</xsl:attribute>
  5821.                 </xsl:if>
  5822.                 <xsl:call-template name="process-header-footer-style-properties">
  5823.                     <xsl:with-param name="style-data" select="$style-data"/>
  5824.                     <xsl:with-param name="current-pos" select="$current-pos + 2"/>
  5825.                 </xsl:call-template>
  5826.             </xsl:when>
  5827.             <xsl:when test="starts-with($current-style-data,'&Y')">
  5828.                 <xsl:variable name="subscript-count-before">
  5829.                     <xsl:call-template name="get-substyle-count-in-data">
  5830.                         <xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
  5831.                         <xsl:with-param name="substyle" select="'&Y'"/>
  5832.                         <xsl:with-param name="count" select="0"/>
  5833.                     </xsl:call-template>
  5834.                 </xsl:variable>
  5835.                 <xsl:if test="$subscript-count-before mod 2 = 0">
  5836.                     <xsl:attribute name="style:text-position">-33% 58%</xsl:attribute>
  5837.                 </xsl:if>
  5838.                 <xsl:call-template name="process-header-footer-style-properties">
  5839.                     <xsl:with-param name="style-data" select="$style-data"/>
  5840.                     <xsl:with-param name="current-pos" select="$current-pos + 2"/>
  5841.                 </xsl:call-template>
  5842.             </xsl:when>
  5843.             <xsl:when test="starts-with($current-style-data,'&S')">
  5844.                 <xsl:variable name="strikethrough-count-before">
  5845.                     <xsl:call-template name="get-substyle-count-in-data">
  5846.                         <xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
  5847.                         <xsl:with-param name="substyle" select="'&S'"/>
  5848.                         <xsl:with-param name="count" select="0"/>
  5849.                     </xsl:call-template>
  5850.                 </xsl:variable>
  5851.                 <xsl:if test="$strikethrough-count-before mod 2 = 0">
  5852.                     <xsl:attribute name="style:text-crossing-out">single-line</xsl:attribute>
  5853.                 </xsl:if>
  5854.                 <xsl:call-template name="process-header-footer-style-properties">
  5855.                     <xsl:with-param name="style-data" select="$style-data"/>
  5856.                     <xsl:with-param name="current-pos" select="$current-pos + 2"/>
  5857.                 </xsl:call-template>
  5858.             </xsl:when>
  5859.             <xsl:when test="starts-with($current-style-data,'&U')">
  5860.                 <xsl:variable name="single-underline-count-before">
  5861.                     <xsl:call-template name="get-substyle-count-in-data">
  5862.                         <xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
  5863.                         <xsl:with-param name="substyle" select="'&U'"/>
  5864.                         <xsl:with-param name="count" select="0"/>
  5865.                     </xsl:call-template>
  5866.                 </xsl:variable>
  5867.                 <xsl:if test="$single-underline-count-before mod 2 = 0">
  5868.                     <xsl:attribute name="style:text-underline">single</xsl:attribute>
  5869.                 </xsl:if>
  5870.                 <xsl:call-template name="process-header-footer-style-properties">
  5871.                     <xsl:with-param name="style-data" select="$style-data"/>
  5872.                     <xsl:with-param name="current-pos" select="$current-pos + 2"/>
  5873.                 </xsl:call-template>
  5874.             </xsl:when>
  5875.             <xsl:when test="starts-with($current-style-data,'&E')">
  5876.                 <xsl:variable name="double-underline-count-before">
  5877.                     <xsl:call-template name="get-substyle-count-in-data">
  5878.                         <xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
  5879.                         <xsl:with-param name="substyle" select="'&E'"/>
  5880.                         <xsl:with-param name="count" select="0"/>
  5881.                     </xsl:call-template>
  5882.                 </xsl:variable>
  5883.                 <xsl:if test="$double-underline-count-before mod 2 = 0">
  5884.                     <xsl:attribute name="style:text-underline">double</xsl:attribute>
  5885.                 </xsl:if>
  5886.                 <xsl:call-template name="process-header-footer-style-properties">
  5887.                     <xsl:with-param name="style-data" select="$style-data"/>
  5888.                     <xsl:with-param name="current-pos" select="$current-pos + 2"/>
  5889.                 </xsl:call-template>
  5890.             </xsl:when>
  5891.             <xsl:otherwise/>
  5892.         </xsl:choose>
  5893.     </xsl:template>
  5894.     <xsl:template name="get-substyle-count-in-data">
  5895.         <xsl:param name="style-data"/>
  5896.         <xsl:param name="substyle"/>
  5897.         <xsl:param name="count"/>
  5898.         <xsl:choose>
  5899.             <xsl:when test="contains($style-data,$substyle)">
  5900.                 <xsl:call-template name="get-substyle-count-in-data">
  5901.                     <xsl:with-param name="style-data" select="substring-after($style-data,$substyle)"/>
  5902.                     <xsl:with-param name="substyle" select="$substyle"/>
  5903.                     <xsl:with-param name="count" select="$count+1"/>
  5904.                 </xsl:call-template>
  5905.             </xsl:when>
  5906.             <xsl:otherwise>
  5907.                 <xsl:value-of select="$count"/>
  5908.             </xsl:otherwise>
  5909.         </xsl:choose>
  5910.     </xsl:template>
  5911.     <xsl:template name="get-current-content-pos">
  5912.         <xsl:param name="style-data"/>
  5913.         <xsl:param name="current-pos"/>
  5914.         <xsl:variable name="current-style-data">
  5915.             <xsl:value-of select="substring($style-data,$current-pos)"/>
  5916.         </xsl:variable>
  5917.         <xsl:choose>
  5918.             <xsl:when test="starts-with($current-style-data,'&X') or starts-with($current-style-data,'&Y') or starts-with($current-style-data,'&S') or starts-with($current-style-data,'&U') or starts-with($current-style-data,'&E') or starts-with($current-style-data,'&B')">
  5919.                 <xsl:call-template name="get-current-content-pos">
  5920.                     <xsl:with-param name="style-data" select="$style-data"/>
  5921.                     <xsl:with-param name="current-pos" select="$current-pos+2"/>
  5922.                 </xsl:call-template>
  5923.             </xsl:when>
  5924.             <xsl:when test="starts-with($current-style-data,'&0') or starts-with($current-style-data,'&1') or starts-with($current-style-data,'&2') or starts-with($current-style-data,'&3') or starts-with($current-style-data,'&4') or starts-with($current-style-data,'&5') or starts-with($current-style-data,'&6') or starts-with($current-style-data,'&7') or starts-with($current-style-data,'&8') or starts-with($current-style-data,'&9')">
  5925.                 <xsl:variable name="font-size-length">
  5926.                     <xsl:call-template name="get-digit-length">
  5927.                         <xsl:with-param name="complexive-string" select="substring-after($current-style-data,'&')"/>
  5928.                     </xsl:call-template>
  5929.                 </xsl:variable>
  5930.                 <xsl:call-template name="get-current-content-pos">
  5931.                     <xsl:with-param name="style-data" select="$style-data"/>
  5932.                     <xsl:with-param name="current-pos" select="$current-pos+1+$font-size-length"/>
  5933.                 </xsl:call-template>
  5934.             </xsl:when>
  5935.             <xsl:when test="starts-with($current-style-data,'&"')">
  5936.                 <xsl:variable name="temp" select="substring-before(substring($style-data,$current-pos+2),'"')"/>
  5937.                 <xsl:call-template name="get-current-content-pos">
  5938.                     <xsl:with-param name="style-data" select="$style-data"/>
  5939.                     <xsl:with-param name="current-pos" select="string-length($temp)+$current-pos+3"/>
  5940.                 </xsl:call-template>
  5941.             </xsl:when>
  5942.             <xsl:otherwise>
  5943.                 <xsl:value-of select="$current-pos"/>
  5944.             </xsl:otherwise>
  5945.         </xsl:choose>
  5946.     </xsl:template>
  5947.     <xsl:template name="translate-expression">
  5948.         <xsl:param name="cell-row-pos"/>
  5949.         <xsl:param name="cell-column-pos"/>
  5950.         <xsl:param name="expression"/>
  5951.         <xsl:choose>
  5952.             <xsl:when test="contains($expression,'R') and contains(substring-after($expression,'R'),'C')">
  5953.                 <!-- process the row part. glu -->
  5954.                 <xsl:variable name="after-R">
  5955.                     <xsl:value-of select="substring(substring-after($expression,'R'),1,1)"/>
  5956.                 </xsl:variable>
  5957.                 <xsl:choose>
  5958.                     <!-- found one cell unit. glu -->
  5959.                     <xsl:when test="$after-R='C' or $after-R='[' or $after-R='0' or $after-R='1' or $after-R='2' or $after-R='3' or $after-R='4' or $after-R='5' or $after-R='6' or $after-R='7' or $after-R='8' or $after-R='9'">
  5960.                         <xsl:value-of select="translate( substring-before($expression,'R'),',!', ';.')"/>
  5961.                         <xsl:variable name="row-pos">
  5962.                             <xsl:choose>
  5963.                                 <xsl:when test="$after-R='['">
  5964.                                     <xsl:value-of select="$cell-row-pos+substring-before( substring-after($expression,'R['),']')"/>
  5965.                                 </xsl:when>
  5966.                                 <xsl:when test="$after-R='C'">
  5967.                                     <xsl:value-of select="$cell-row-pos"/>
  5968.                                 </xsl:when>
  5969.                                 <xsl:otherwise>
  5970.                                     <xsl:value-of select="substring-before(substring-after($expression,'R'),'C')"/>
  5971.                                 </xsl:otherwise>
  5972.                             </xsl:choose>
  5973.                         </xsl:variable>
  5974.                         <xsl:variable name="row-pos-style">
  5975.                             <xsl:choose>
  5976.                                 <xsl:when test="$after-R='[' or $after-R='C'">relative</xsl:when>
  5977.                                 <xsl:otherwise>absolute</xsl:otherwise>
  5978.                             </xsl:choose>
  5979.                         </xsl:variable>
  5980.                         <!-- process the column part. glu -->
  5981.                         <xsl:variable name="after-C">
  5982.                             <xsl:value-of select="substring(substring-after(substring-after($expression,'R'),'C'),1,1)"/>
  5983.                         </xsl:variable>
  5984.                         <xsl:variable name="column-digit-length">
  5985.                             <xsl:choose>
  5986.                                 <xsl:when test="$after-C='0' or $after-C='1' or $after-C='2' or $after-C='3' or $after-C='4' or $after-C='5' or $after-C='6' or $after-C='7' or $after-C='8' or $after-C='9'">
  5987.                                     <xsl:call-template name="get-digit-length">
  5988.                                         <xsl:with-param name="complexive-string" select="substring-after(substring-after($expression,'R'),'C')"/>
  5989.                                     </xsl:call-template>
  5990.                                 </xsl:when>
  5991.                             </xsl:choose>
  5992.                         </xsl:variable>
  5993.                         <xsl:variable name="column-pos">
  5994.                             <xsl:choose>
  5995.                                 <xsl:when test="$after-C='['">
  5996.                                     <xsl:value-of select="$cell-column-pos + substring-before(substring-after(substring-after($expression,'R'),'C['),']')"/>
  5997.                                 </xsl:when>
  5998.                                 <xsl:when test="$after-C='0' or $after-C='1' or $after-C='2' or $after-C='3' or $after-C='4' or $after-C='5' or $after-C='6' or $after-C='7' or $after-C='8' or $after-C='9'">
  5999.                                     <xsl:value-of select="substring(substring-after(substring-after($expression,'R'),'C'),1,$column-digit-length)"/>
  6000.                                 </xsl:when>
  6001.                                 <xsl:otherwise>
  6002.                                     <xsl:value-of select="$cell-column-pos"/>
  6003.                                 </xsl:otherwise>
  6004.                             </xsl:choose>
  6005.                         </xsl:variable>
  6006.                         <xsl:variable name="column-pos-style">
  6007.                             <xsl:choose>
  6008.                                 <xsl:when test="$after-C='0' or $after-C='1' or $after-C='2' or $after-C='3' or $after-C='4' or $after-C='5' or $after-C='6' or $after-C='7' or $after-C='8' or $after-C='9'">absolute</xsl:when>
  6009.                                 <xsl:otherwise>relative</xsl:otherwise>
  6010.                             </xsl:choose>
  6011.                         </xsl:variable>
  6012.                         <xsl:call-template name="translate-unit">
  6013.                             <xsl:with-param name="column-number" select="$column-pos"/>
  6014.                             <xsl:with-param name="row-number" select="$row-pos"/>
  6015.                             <xsl:with-param name="column-pos-style" select="$column-pos-style"/>
  6016.                             <xsl:with-param name="row-pos-style" select="$row-pos-style"/>
  6017.                         </xsl:call-template>
  6018.                         <xsl:variable name="post-unit">
  6019.                             <xsl:choose>
  6020.                                 <xsl:when test="$column-pos-style='absolute'">
  6021.                                     <xsl:value-of select="substring(substring-after(substring-after($expression,'R'),'C'),$column-digit-length+1)"/>
  6022.                                 </xsl:when>
  6023.                                 <xsl:when test="$after-C='['">
  6024.                                     <xsl:value-of select="substring-after(substring-after(substring-after($expression,'R'),'C['),']')"/>
  6025.                                 </xsl:when>
  6026.                                 <xsl:otherwise>
  6027.                                     <xsl:value-of select="substring-after(substring-after($expression,'R'),'C')"/>
  6028.                                 </xsl:otherwise>
  6029.                             </xsl:choose>
  6030.                         </xsl:variable>
  6031.                         <xsl:call-template name="translate-expression">
  6032.                             <xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
  6033.                             <xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
  6034.                             <xsl:with-param name="expression" select="$post-unit"/>
  6035.                         </xsl:call-template>
  6036.                     </xsl:when>
  6037.                     <xsl:otherwise>
  6038.                         <xsl:value-of select="concat(translate( substring-before($expression,'R'),',!', ';.'),'R')"/>
  6039.                         <xsl:call-template name="translate-expression">
  6040.                             <xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
  6041.                             <xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
  6042.                             <xsl:with-param name="expression" select="substring-after($expression,'R')"/>
  6043.                         </xsl:call-template>
  6044.                     </xsl:otherwise>
  6045.                 </xsl:choose>
  6046.             </xsl:when>
  6047.             <xsl:otherwise>
  6048.                 <xsl:value-of select="translate( $expression,',!', ';.')"/>
  6049.             </xsl:otherwise>
  6050.         </xsl:choose>
  6051.     </xsl:template>
  6052.     <xsl:template name="translate-unit">
  6053.         <xsl:param name="column-number"/>
  6054.         <xsl:param name="row-number"/>
  6055.         <xsl:param name="column-pos-style"/>
  6056.         <xsl:param name="row-pos-style"/>
  6057.         <xsl:variable name="column-number1">
  6058.             <xsl:value-of select="floor( $column-number div 26 )"/>
  6059.         </xsl:variable>
  6060.         <xsl:variable name="column-number2">
  6061.             <xsl:value-of select="$column-number mod 26"/>
  6062.         </xsl:variable>
  6063.         <xsl:variable name="column-character1">
  6064.             <xsl:call-template name="number-to-character">
  6065.                 <xsl:with-param name="number" select="$column-number1"/>
  6066.             </xsl:call-template>
  6067.         </xsl:variable>
  6068.         <xsl:variable name="column-character2">
  6069.             <xsl:call-template name="number-to-character">
  6070.                 <xsl:with-param name="number" select="$column-number2"/>
  6071.             </xsl:call-template>
  6072.         </xsl:variable>
  6073.         <!-- position styles are 'absolute' or 'relative', glu -->
  6074.         <xsl:choose>
  6075.             <xsl:when test="$column-pos-style = 'absolute'">
  6076.                 <xsl:value-of select="concat( '$', $column-character1, $column-character2)"/>
  6077.             </xsl:when>
  6078.             <xsl:otherwise>
  6079.                 <xsl:value-of select="concat( $column-character1, $column-character2)"/>
  6080.             </xsl:otherwise>
  6081.         </xsl:choose>
  6082.         <xsl:choose>
  6083.             <xsl:when test="$row-pos-style ='absolute'">
  6084.                 <xsl:value-of select="concat( '$', $row-number)"/>
  6085.             </xsl:when>
  6086.             <xsl:otherwise>
  6087.                 <xsl:value-of select="$row-number"/>
  6088.             </xsl:otherwise>
  6089.         </xsl:choose>
  6090.     </xsl:template>
  6091.     <xsl:template name="number-to-character">
  6092.         <xsl:param name="number"/>
  6093.         <xsl:choose>
  6094.             <xsl:when test="$number =  0"/>
  6095.             <xsl:when test="$number =  1">A</xsl:when>
  6096.             <xsl:when test="$number =  2">B</xsl:when>
  6097.             <xsl:when test="$number =  3">C</xsl:when>
  6098.             <xsl:when test="$number =  4">D</xsl:when>
  6099.             <xsl:when test="$number =  5">E</xsl:when>
  6100.             <xsl:when test="$number =  6">F</xsl:when>
  6101.             <xsl:when test="$number =  7">G</xsl:when>
  6102.             <xsl:when test="$number =  8">H</xsl:when>
  6103.             <xsl:when test="$number =  9">I</xsl:when>
  6104.             <xsl:when test="$number = 10">J</xsl:when>
  6105.             <xsl:when test="$number = 11">K</xsl:when>
  6106.             <xsl:when test="$number = 12">L</xsl:when>
  6107.             <xsl:when test="$number = 13">M</xsl:when>
  6108.             <xsl:when test="$number = 14">N</xsl:when>
  6109.             <xsl:when test="$number = 15">O</xsl:when>
  6110.             <xsl:when test="$number = 16">P</xsl:when>
  6111.             <xsl:when test="$number = 17">Q</xsl:when>
  6112.             <xsl:when test="$number = 18">R</xsl:when>
  6113.             <xsl:when test="$number = 19">S</xsl:when>
  6114.             <xsl:when test="$number = 20">T</xsl:when>
  6115.             <xsl:when test="$number = 21">U</xsl:when>
  6116.             <xsl:when test="$number = 22">V</xsl:when>
  6117.             <xsl:when test="$number = 23">W</xsl:when>
  6118.             <xsl:when test="$number = 24">X</xsl:when>
  6119.             <xsl:when test="$number = 25">Y</xsl:when>
  6120.             <xsl:when test="$number = 26">Z</xsl:when>
  6121.             <xsl:otherwise/>
  6122.         </xsl:choose>
  6123.     </xsl:template>
  6124.     <xsl:template name="get-digit-length">
  6125.         <xsl:param name="complexive-string"/>
  6126.         <xsl:variable name="first-char">
  6127.             <xsl:value-of select="substring( $complexive-string, 1, 1)"/>
  6128.         </xsl:variable>
  6129.         <xsl:choose>
  6130.             <xsl:when test="$first-char = '1' or $first-char =  '2' or $first-char =  '3' or $first-char =  '4' or $first-char =  '5' or $first-char =  '6' or $first-char = '7' or $first-char =  '8' or $first-char =  '9' or $first-char = '0' ">
  6131.                 <xsl:variable name="temp">
  6132.                     <xsl:call-template name="get-digit-length">
  6133.                         <xsl:with-param name="complexive-string" select="substring( $complexive-string, 2)"/>
  6134.                     </xsl:call-template>
  6135.                 </xsl:variable>
  6136.                 <xsl:value-of select="$temp+1"/>
  6137.             </xsl:when>
  6138.             <xsl:otherwise>0</xsl:otherwise>
  6139.         </xsl:choose>
  6140.     </xsl:template>
  6141.     <xsl:template name="current-cell-pos">
  6142.         <xsl:param name="current-cell-list"/>
  6143.         <xsl:choose>
  6144.             <xsl:when test="$current-cell-list">
  6145.                 <xsl:variable name="current-cell" select="$current-cell-list[position()=last()]"/>
  6146.                 <xsl:choose>
  6147.                     <xsl:when test="$current-cell/@ss:Index">
  6148.                         <xsl:choose>
  6149.                             <xsl:when test="$current-cell/@ss:MergeAcross">
  6150.                                 <xsl:value-of select="$current-cell/@ss:MergeAcross + $current-cell/@ss:Index"/>
  6151.                             </xsl:when>
  6152.                             <xsl:otherwise>
  6153.                                 <xsl:value-of select="$current-cell/@ss:Index"/>
  6154.                             </xsl:otherwise>
  6155.                         </xsl:choose>
  6156.                     </xsl:when>
  6157.                     <xsl:otherwise>
  6158.                         <xsl:variable name="preceding-cell">
  6159.                             <xsl:call-template name="current-cell-pos">
  6160.                                 <xsl:with-param name="current-cell-list" select="$current-cell-list[position()!=last()]"/>
  6161.                             </xsl:call-template>
  6162.                         </xsl:variable>
  6163.                         <xsl:choose>
  6164.                             <xsl:when test="$current-cell/@ss:MergeAcross">
  6165.                                 <xsl:value-of select="1 + $current-cell/@ss:MergeAcross + $preceding-cell"/>
  6166.                             </xsl:when>
  6167.                             <xsl:otherwise>
  6168.                                 <xsl:value-of select="1 + $preceding-cell"/>
  6169.                             </xsl:otherwise>
  6170.                         </xsl:choose>
  6171.                     </xsl:otherwise>
  6172.                 </xsl:choose>
  6173.             </xsl:when>
  6174.             <xsl:otherwise>0</xsl:otherwise>
  6175.         </xsl:choose>
  6176.     </xsl:template>
  6177.     <xsl:template match="ss:Comment">
  6178.         <xsl:element name="office:annotation">
  6179.             <xsl:if test="@ss:Author">
  6180.                 <xsl:attribute name="office:author"><xsl:value-of select="@ss:Author"/></xsl:attribute>
  6181.             </xsl:if>
  6182.             <xsl:if test="@ss:ShowAlways = '1'">
  6183.                 <xsl:attribute name="office:display">true</xsl:attribute>
  6184.             </xsl:if>
  6185.             <xsl:if test="ss:Data">
  6186.                 <text:p>
  6187.                     <xsl:value-of select="ss:Data"/>
  6188.                 </text:p>
  6189.             </xsl:if>
  6190.         </xsl:element>
  6191.     </xsl:template>
  6192.     <xsl:template name="Names">
  6193.         <xsl:if test="//ss:NamedRange">
  6194.             <table:named-expressions>
  6195.                 <xsl:for-each select="//ss:NamedRange">
  6196.                     <xsl:choose>
  6197.                         <xsl:when test="contains( @ss:RefersTo, '!R')">
  6198.                             <xsl:variable name="referto">
  6199.                                 <xsl:call-template name="translate-expression">
  6200.                                     <xsl:with-param name="cell-row-pos" select="0"/>
  6201.                                     <xsl:with-param name="cell-column-pos" select="0"/>
  6202.                                     <xsl:with-param name="expression" select="@ss:RefersTo"/>
  6203.                                 </xsl:call-template>
  6204.                             </xsl:variable>
  6205.                             <xsl:element name="table:named-range">
  6206.                                 <xsl:attribute name="table:name"><xsl:value-of select="@ss:Name"/></xsl:attribute>
  6207.                                 <xsl:attribute name="table:base-cell-address"><xsl:value-of select="translate( $referto, '=', '$')"/></xsl:attribute>
  6208.                                 <xsl:attribute name="table:cell-range-address"><xsl:value-of select="translate( $referto, '=', '$')"/></xsl:attribute>
  6209.                                 <xsl:if test="@ss:Name = 'Print_Area'">
  6210.                                     <xsl:attribute name="table:range-usable-as">print-range</xsl:attribute>
  6211.                                 </xsl:if>
  6212.                             </xsl:element>
  6213.                         </xsl:when>
  6214.                         <xsl:otherwise>
  6215.                             <xsl:variable name="expression-name">
  6216.                                 <xsl:value-of select="@ss:Name"/>
  6217.                             </xsl:variable>
  6218.                             <xsl:element name="table:named-expression">
  6219.                                 <xsl:attribute name="table:name"><xsl:value-of select="@ss:Name"/></xsl:attribute>
  6220.                                 <!-- just set '$Sheet1.$A$1' as named-expressions virtual base-cell-address. glu -->
  6221.                                 <xsl:attribute name="table:base-cell-address">$Sheet1.$A$1</xsl:attribute>
  6222.                                 <xsl:attribute name="table:expression"><xsl:value-of select="substring( @ss:RefersTo, 2)"/></xsl:attribute>
  6223.                             </xsl:element>
  6224.                         </xsl:otherwise>
  6225.                     </xsl:choose>
  6226.                 </xsl:for-each>
  6227.             </table:named-expressions>
  6228.         </xsl:if>
  6229.     </xsl:template>
  6230.     <xsl:template match="x:AutoFilter">
  6231.         <xsl:element name="table:database-range">
  6232.             <xsl:attribute name="table:name"><xsl:value-of select="concat(../@ss:Name,'_',@x:Range)"/></xsl:attribute>
  6233.             <xsl:variable name="range">
  6234.                 <xsl:call-template name="translate-expression">
  6235.                     <xsl:with-param name="cell-row-pos" select="0"/>
  6236.                     <xsl:with-param name="cell-column-pos" select="0"/>
  6237.                     <xsl:with-param name="expression" select="@x:Range"/>
  6238.                 </xsl:call-template>
  6239.             </xsl:variable>
  6240.             <xsl:attribute name="table:target-range-address"><xsl:value-of select="concat('$',../@ss:Name,'.',$range)"/></xsl:attribute>
  6241.             <xsl:attribute name="table:display-filter-buttons">true</xsl:attribute>
  6242.         </xsl:element>
  6243.     </xsl:template>
  6244.     <xsl:template name="set-calculation">
  6245.         <xsl:element name="table:calculation-settings">
  6246.             <xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:PrecisionAsDisplayed">
  6247.                 <xsl:attribute name="table:precision-as-shown">true</xsl:attribute>
  6248.             </xsl:if>
  6249.             <xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:Date1904">
  6250.                 <table:null-date table:date-value="1904-01-01"/>
  6251.             </xsl:if>
  6252.             <xsl:element name="table:iteration">
  6253.                 <xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:Iteration">
  6254.                     <xsl:attribute name="table:status">enable</xsl:attribute>
  6255.                 </xsl:if>
  6256.                 <xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:MaxIterations">
  6257.                     <xsl:attribute name="table:steps"><xsl:value-of select="/ss:Workbook/x:ExcelWorkbook/x:MaxIterations"/></xsl:attribute>
  6258.                 </xsl:if>
  6259.                 <xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:MaxChange">
  6260.                     <xsl:attribute name="table:maximum-difference"><xsl:value-of select="/ss:Workbook/x:ExcelWorkbook/x:MaxChange"/></xsl:attribute>
  6261.                 </xsl:if>
  6262.             </xsl:element>
  6263.         </xsl:element>
  6264.     </xsl:template>
  6265. </xsl:stylesheet>
  6266.