1<?xml version="1.0" encoding="UTF-8"?>
2<!--***********************************************************
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 *
21 ***********************************************************-->
22
23
24<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:SL="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" exclude-result-prefixes="aml dt html o ss SL v w10 w wx x">
25	<!--+++++ INCLUDED XSL MODULES +++++-->
26	<!-- helper collection, to convert measures (e.g. inch to pixel using DPI (dots per inch) parameter)-->
27	<xsl:import href="../../common/measure_conversion.xsl"/>
28	<xsl:output indent="no" version="1.0" encoding="UTF-8" method="xml"/>
29	<xsl:template match="/">
30		<office:document office:mimetype="application/vnd.oasis.opendocument.spreadsheet" office:version="1.0">
31			<xsl:apply-templates select="ss:Workbook/o:DocumentProperties"/>
32			<xsl:apply-templates select="ss:Workbook/x:ExcelWorkbook"/>
33			<xsl:call-template name="font-declaration"/>
34			<xsl:apply-templates select="ss:Workbook/ss:Worksheet[1]" mode="styles"/>
35			<xsl:element name="office:body">
36				<xsl:element name="office:spreadsheet">
37					<xsl:call-template name="set-calculation"/>
38					<!-- for DataValidation -->
39					<xsl:if test="ss:Workbook/ss:Worksheet/x:DataValidation">
40						<xsl:element name="table:content-validations">
41							<xsl:apply-templates select="ss:Workbook/ss:Worksheet/x:DataValidation"/>
42						</xsl:element>
43					</xsl:if>
44					<xsl:apply-templates select="ss:Workbook/ss:Worksheet"/>
45					<xsl:call-template name="Names"/>
46					<xsl:element name="table:database-ranges">
47						<!-- these descriptions located in every Worksheet in Excel, but at the same path in Calc -->
48						<xsl:for-each select="ss:Workbook/ss:Worksheet">
49							<xsl:apply-templates select="./x:Sorting"/>
50							<xsl:apply-templates select="./x:AutoFilter"/>
51							<!-- for Advanced Filter.the position is same as AutoFilter -->
52							<xsl:if test="./ss:Names/ss:NamedRange and ./ss:Names/ss:NamedRange/@ss:Name='_FilterDatabase'">
53								<xsl:call-template name="transform-advanced-filter">
54									<xsl:with-param name="target-value" select="substring-after(./ss:Names/ss:NamedRange[@ss:Name='_FilterDatabase']/@ss:RefersTo, '=')"/>
55									<xsl:with-param name="condition-pos" select="substring-after(./ss:Names/ss:NamedRange[@ss:Name='Criteria']/@ss:RefersTo, '=')"/>
56								</xsl:call-template>
57							</xsl:if>
58						</xsl:for-each>
59					</xsl:element>
60				</xsl:element>
61			</xsl:element>
62		</office:document>
63	</xsl:template>
64	<xsl:template match="o:DocumentProperties">
65		<office:meta>
66			<meta:generator>Microsoft Excel 2003</meta:generator>
67			<xsl:if test="o:Title">
68				<dc:title>
69					<xsl:value-of select="o:Title"/>
70				</dc:title>
71			</xsl:if>
72			<xsl:if test="o:Description">
73				<dc:description>
74					<xsl:value-of select="o:Description"/>
75				</dc:description>
76			</xsl:if>
77			<xsl:if test="o:Subject">
78				<dc:subject>
79					<xsl:value-of select="o:Subject"/>
80				</dc:subject>
81			</xsl:if>
82			<xsl:if test="o:Author">
83				<meta:initial-creator>
84					<xsl:value-of select="o:Author"/>
85				</meta:initial-creator>
86			</xsl:if>
87			<xsl:if test="o:Created">
88				<meta:creation-date>
89					<xsl:value-of select="substring-before( o:Created, 'Z')"/>
90				</meta:creation-date>
91			</xsl:if>
92			<xsl:if test="o:LastAuthor">
93				<dc:creator>
94					<xsl:value-of select="o:LastAuthor"/>
95				</dc:creator>
96			</xsl:if>
97			<xsl:if test="o:LastSaved">
98				<dc:date>
99					<xsl:value-of select="substring-before( o:LastSaved, 'Z')"/>
100				</dc:date>
101			</xsl:if>
102			<!--
103			<meta:printed-by/>
104			<meta:print-date/>
105				<!~~ removed in OASIS Open Office XML
106				<meta:keywords>
107					<meta:keyword>
108						<xsl:value-of select="o:Keywords" />
109					</meta:keyword>
110				</meta:keywords>
111				~~>
112			<dc:language/>
113			-->
114			<xsl:if test="o:Revision">
115				<meta:editing-cycles>
116					<xsl:value-of select="o:Revision"/>
117				</meta:editing-cycles>
118			</xsl:if>
119			<xsl:if test="o:TotalTime">
120				<meta:editing-duration>
121					<xsl:value-of select="concat('PT', floor(o:TotalTime div 60), 'H', o:TotalTime mod 60, 'M0S')"/>
122				</meta:editing-duration>
123			</xsl:if>
124			<xsl:if test="o:Category">
125				<meta:user-defined meta:name="Category">
126					<xsl:value-of select="o:Category"/>
127				</meta:user-defined>
128			</xsl:if>
129			<xsl:if test="o:Manager">
130				<meta:user-defined meta:name="Manager">
131					<xsl:value-of select="o:Manager"/>
132				</meta:user-defined>
133			</xsl:if>
134			<xsl:if test="o:Company">
135				<meta:user-defined meta:name="Company">
136					<xsl:value-of select="o:Company"/>
137				</meta:user-defined>
138			</xsl:if>
139			<xsl:if test="o:Version">
140				<meta:user-defined meta:name="Version">
141					<xsl:value-of select="o:Version"/>
142				</meta:user-defined>
143			</xsl:if>
144			<xsl:if test="o:HyperlinkBase">
145				<meta:user-defined meta:name="HyperlinkBase">
146					<xsl:value-of select="o:HyperlinkBase"/>
147				</meta:user-defined>
148			</xsl:if>
149			<xsl:apply-templates select="../o:CustomDocumentProperties"/>
150			<!--Note:  <meta:document-statistic/>-->
151		</office:meta>
152	</xsl:template>
153	<xsl:template match="o:CustomDocumentProperties">
154		<xsl:for-each select="node()[@dt:dt]">
155			<meta:user-defined meta:name="{name()}">
156				<xsl:value-of select="."/>
157			</meta:user-defined>
158		</xsl:for-each>
159	</xsl:template>
160	<xsl:template match="x:ExcelWorkbook">
161		<!-- Configuration in 'ooo:view-settings' and 'ooo:configuration-settings'
162		"GridColor"
163		"HasColumnRowHeaders"
164		"HasSheetTabs"
165		"IsOutlineSymbolsSet"
166		"IsRasterAxisSynchronized"
167		"IsSnapToRaster"
168		"RasterIsVisible"
169		"RasterResolutionX"
170		"RasterResolutionY"
171		"RasterSubdivisionX"
172		"RasterSubdivisionY"
173		"ShowGrid"
174		"ShowNotes"
175		"ShowPageBreaks"
176		"ShowZeroValues"
177		-->
178		<xsl:variable name="sharedConfiguration">
179			<xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:GridlineColor">
180				<config:config-item config:name="GridColor" config:type="long">
181					<xsl:variable name="temp-code" select="substring-after(normalize-space(../ss:Worksheet/x:WorksheetOptions/x:GridlineColor), '#')"/>
182					<xsl:variable name="temp-value">
183						<xsl:call-template name="hex2decimal">
184							<xsl:with-param name="hex-number" select="$temp-code"/>
185							<xsl:with-param name="index" select="1"/>
186							<xsl:with-param name="str-length" select="string-length($temp-code)"/>
187							<xsl:with-param name="last-value" select="0"/>
188						</xsl:call-template>
189					</xsl:variable>
190					<xsl:value-of select="$temp-value"/>
191				</config:config-item>
192			</xsl:if>
193			<xsl:choose>
194				<xsl:when test="../ss:Worksheet/x:WorksheetOptions/x:DoNotDisplayHeadings">
195					<config:config-item config:name="HasColumnRowHeaders" config:type="boolean">false</config:config-item>
196				</xsl:when>
197				<xsl:otherwise>
198					<config:config-item config:name="HasColumnRowHeaders" config:type="boolean">true</config:config-item>
199				</xsl:otherwise>
200			</xsl:choose>
201			<xsl:choose>
202				<xsl:when test="x:HideWorkbookTabs">
203					<config:config-item config:name="HasSheetTabs" config:type="boolean">false</config:config-item>
204				</xsl:when>
205				<xsl:otherwise>
206					<config:config-item config:name="HasSheetTabs" config:type="boolean">true</config:config-item>
207				</xsl:otherwise>
208			</xsl:choose>
209			<xsl:choose>
210			<xsl:when test="../ss:Worksheet/x:WorksheetOptions/x:DoNotDisplayOutline">
211				<config:config-item config:name="IsOutlineSymbolsSet" config:type="boolean">false</config:config-item>
212			</xsl:when>
213				<xsl:otherwise>
214				<config:config-item config:name="IsOutlineSymbolsSet" config:type="boolean">true</config:config-item>
215				</xsl:otherwise>
216			</xsl:choose>
217			<xsl:choose>
218				<xsl:when test="../ss:Worksheet/x:WorksheetOptions/x:DoNotDisplayGridlines">
219					<config:config-item config:name="ShowGrid" config:type="boolean">false</config:config-item>
220				</xsl:when>
221				<xsl:otherwise>
222					<config:config-item config:name="ShowGrid" config:type="boolean">true</config:config-item>
223				</xsl:otherwise>
224			</xsl:choose>
225			<xsl:choose>
226				<xsl:when test="../ss:Worksheet/x:WorksheetOptions/x:DoNotDisplayZeros">
227					<config:config-item config:name="ShowZeroValues" config:type="boolean">false</config:config-item>
228				</xsl:when>
229				<xsl:otherwise>
230					<config:config-item config:name="ShowZeroValues" config:type="boolean">true</config:config-item>
231				</xsl:otherwise>
232			</xsl:choose>
233		</xsl:variable>
234		<office:settings>
235			<config:config-item-set config:name="ooo:view-settings">
236				<config:config-item config:type="int" config:name="VisibleAreaTop">
237					<xsl:value-of select="x:WindowTopY"/>
238				</config:config-item>
239				<config:config-item config:name="VisibleAreaLeft" config:type="int">
240					<xsl:value-of select="x:WindowTopX"/>
241				</config:config-item>
242				<config:config-item config:name="VisibleAreaWidth" config:type="int">
243					<xsl:value-of select="x:WindowWidth"/>
244				</config:config-item>
245				<config:config-item config:name="VisibleAreaHeight" config:type="int">
246					<xsl:value-of select="x:WindowHeight"/>
247				</config:config-item>
248				<xsl:variable name="ratio" select="15"/>
249				<config:config-item-map-indexed config:name="Views">
250					<config:config-item-map-entry>
251						<config:config-item config:name="ViewId" config:type="string">View1</config:config-item>
252						<config:config-item-map-named config:name="Tables">
253							<!--  The panes of a table is like 3   |   1   or  3 |  1, or   3 , while 3 is the default one. glu
254													 - - - -        - - -
255													2  |  0         2    -->
256							<xsl:for-each select="../ss:Worksheet">
257								<config:config-item-map-entry config:name="{@ss:Name}">
258									<xsl:variable name="active-pane">
259										<xsl:choose>
260											<xsl:when test="x:WorksheetOptions/x:ActivePane">
261												<xsl:value-of select="x:WorksheetOptions/x:ActivePane"/>
262											</xsl:when>
263											<xsl:otherwise/>
264										</xsl:choose>
265									</xsl:variable>
266									<xsl:if test="not( $active-pane = '' ) and ( x:WorksheetOptions/x:SplitVertical or x:WorksheetOptions/x:SplitHorizontal )">
267										<config:config-item config:name="ActiveSplitRange" config:type="short">
268											<xsl:choose>
269												<xsl:when test="x:WorksheetOptions/x:SplitVertical and not(x:WorksheetOptions/x:SplitHorizontal)">
270													<xsl:value-of select="'3'"/>
271												</xsl:when>
272												<xsl:otherwise>
273													<xsl:value-of select="$active-pane"/>
274												</xsl:otherwise>
275											</xsl:choose>
276										</config:config-item>
277									</xsl:if>
278									<xsl:choose>
279										<xsl:when test="not( $active-pane = '')">
280											<config:config-item config:name="CursorPositionX" config:type="int">
281												<xsl:value-of select="x:WorksheetOptions/x:Panes/x:Pane[x:Number = $active-pane ]/x:ActiveCol"/>
282											</config:config-item>
283											<config:config-item config:name="CursorPositionY" config:type="int">
284												<xsl:value-of select="x:WorksheetOptions/x:Panes/x:Pane[x:Number = $active-pane ]/x:ActiveRow"/>
285											</config:config-item>
286										</xsl:when>
287										<xsl:otherwise>
288											<config:config-item config:name="CursorPositionX" config:type="int">
289												<xsl:value-of select="x:WorksheetOptions/x:Panes/x:Pane/x:ActiveCol"/>
290											</config:config-item>
291											<config:config-item config:name="CursorPositionY" config:type="int">
292												<xsl:value-of select="x:WorksheetOptions/x:Panes/x:Pane/x:ActiveRow"/>
293											</config:config-item>
294										</xsl:otherwise>
295									</xsl:choose>
296									<xsl:variable name="position-left">
297										<xsl:choose>
298											<xsl:when test="x:WorksheetOptions/x:LeftColumnVisible">
299												<xsl:value-of select="x:WorksheetOptions/x:LeftColumnVisible"/>
300											</xsl:when>
301											<xsl:otherwise>0</xsl:otherwise>
302										</xsl:choose>
303									</xsl:variable>
304									<config:config-item config:name="PositionLeft" config:type="int">
305										<xsl:value-of select="$position-left"/>
306									</config:config-item>
307									<xsl:variable name="position-top">
308										<xsl:choose>
309											<xsl:when test="x:WorksheetOptions/x:TopRowVisible">
310												<xsl:value-of select="x:WorksheetOptions/x:TopRowVisible"/>
311											</xsl:when>
312											<xsl:otherwise>0</xsl:otherwise>
313										</xsl:choose>
314									</xsl:variable>
315									<xsl:choose>
316										<xsl:when test="x:WorksheetOptions/x:SplitVertical and not(x:WorksheetOptions/x:SplitHorizontal)">
317											<config:config-item config:name="PositionBottom" config:type="int">
318												<xsl:value-of select="$position-top"/>
319											</config:config-item>
320										</xsl:when>
321										<xsl:otherwise>
322											<config:config-item config:name="PositionTop" config:type="int">
323												<xsl:value-of select="$position-top"/>
324											</config:config-item>
325										</xsl:otherwise>
326									</xsl:choose>
327									<xsl:choose>
328										<xsl:when test="x:WorksheetOptions/x:SplitVertical">
329											<config:config-item config:name="HorizontalSplitMode" config:type="short">
330												<xsl:choose>
331													<xsl:when test="x:WorksheetOptions/x:FreezePanes">2</xsl:when>
332													<xsl:otherwise>1</xsl:otherwise>
333												</xsl:choose>
334											</config:config-item>
335											<config:config-item config:name="HorizontalSplitPosition" config:type="int">
336												<xsl:choose>
337													<xsl:when test="x:WorksheetOptions/x:FreezePanes">
338														<xsl:value-of select="x:WorksheetOptions/x:SplitVertical + $position-left"/>
339													</xsl:when>
340													<xsl:otherwise>
341														<xsl:value-of select="floor( x:WorksheetOptions/x:SplitVertical div $ratio )"/>
342													</xsl:otherwise>
343												</xsl:choose>
344											</config:config-item>
345											<config:config-item config:name="PositionRight" config:type="int">
346												<xsl:value-of select="x:WorksheetOptions/x:LeftColumnRightPane"/>
347											</config:config-item>
348										</xsl:when>
349										<xsl:otherwise>
350											<config:config-item config:name="HorizontalSplitMode" config:type="short">0</config:config-item>
351										</xsl:otherwise>
352									</xsl:choose>
353									<xsl:choose>
354										<xsl:when test="x:WorksheetOptions/x:SplitHorizontal">
355											<config:config-item config:name="VerticalSplitMode" config:type="short">
356												<xsl:choose>
357													<xsl:when test="x:WorksheetOptions/x:FreezePanes">2</xsl:when>
358													<xsl:otherwise>1</xsl:otherwise>
359												</xsl:choose>
360											</config:config-item>
361											<config:config-item config:name="VerticalSplitPosition" config:type="int">
362												<xsl:choose>
363													<xsl:when test="x:WorksheetOptions/x:FreezePanes">
364														<xsl:value-of select="x:WorksheetOptions/x:SplitHorizontal + $position-top"/>
365													</xsl:when>
366													<xsl:otherwise>
367														<xsl:value-of select="floor( x:WorksheetOptions/x:SplitHorizontal div $ratio )"/>
368													</xsl:otherwise>
369												</xsl:choose>
370											</config:config-item>
371											<config:config-item config:name="PositionBottom" config:type="int">
372												<xsl:value-of select="x:WorksheetOptions/x:TopRowBottomPane"/>
373											</config:config-item>
374										</xsl:when>
375										<xsl:otherwise>
376											<config:config-item config:name="VerticalSplitMode" config:type="short">0</config:config-item>
377										</xsl:otherwise>
378									</xsl:choose>
379									<xsl:copy-of select="$sharedConfiguration"/>
380                                    <xsl:if test="x:WorksheetOptions/x:TabColorIndex">
381                                        <config:config-item config:name="TabColor" config:type="int">
382                                            <xsl:variable name="temp-value">
383                                                <xsl:call-template name="colorindex2decimal">
384                                                    <xsl:with-param name="colorindex" select="x:WorksheetOptions/x:TabColorIndex"/>
385                                                </xsl:call-template>
386                                            </xsl:variable>
387                                            <xsl:value-of select="$temp-value"/>
388                                        </config:config-item>
389                                    </xsl:if>
390								</config:config-item-map-entry>
391							</xsl:for-each>
392						</config:config-item-map-named>
393						<xsl:if test="x:ActiveSheet">
394							<config:config-item config:name="ActiveTable" config:type="string">
395								<xsl:value-of select="../ss:Worksheet[/ss:Workbook/x:ExcelWorkbook/x:ActiveSheet+1]/@ss:Name"/>
396							</config:config-item>
397						</xsl:if>
398						<config:config-item config:name="HorizontalScrollbarWidth" config:type="int">555</config:config-item>
399						<!-- following are some table setting from Excel, but transformed to global setting, due to limit of Calc -->
400						<xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:ShowPageBreakZoom">
401							<config:config-item config:name="ShowPageBreakPreview" config:type="boolean">true</config:config-item>
402						</xsl:if>
403						<xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:PageBreakZoom">
404							<config:config-item config:name="PageViewZoomValue" config:type="int">
405								<xsl:value-of select="../ss:Worksheet/x:WorksheetOptions/x:PageBreakZoom"/>
406							</config:config-item>
407						</xsl:if>
408						<xsl:if test="../ss:Worksheet/x:WorksheetOptions/x:Zoom">
409							<config:config-item config:name="ZoomValue" config:type="int">
410								<xsl:value-of select="../ss:Worksheet/x:WorksheetOptions/x:Zoom"/>
411							</config:config-item>
412						</xsl:if>
413						<!-- several properties are not saved in Calc XML but setting, whereas vice versa. :( So just to be expanded, glu -->
414					</config:config-item-map-entry>
415				</config:config-item-map-indexed>
416			</config:config-item-set>
417			<config:config-item-set config:name="ooo:configuration-settings">
418				<xsl:copy-of select="$sharedConfiguration"/>
419			</config:config-item-set>
420			<!-- printer setting, not finished yet. glu
421			<config:config-item-set config:name="configuration-settings" />
422			-->
423		</office:settings>
424	</xsl:template>
425	<!-- Key all attributes with the same name and same value -->
426	<xsl:key name="same-named-font" match="/ss:Workbook/ss:Styles/ss:Style/ss:Font" use="concat(@ss:FontName, @x:Family)"/>
427	<xsl:key name="same-named-face" match="/ss:Workbook/ss:Worksheet/ss:Table/ss:Row/ss:Cell//html:Font[@html:Face]" use="concat(@html:Face, @x:Family)"/>
428	<xsl:template name="font-declaration">
429		<office:font-face-decls>
430			<xsl:if test="/ss:Workbook/ss:Styles/ss:Style/ss:Font">
431				<xsl:for-each select="/ss:Workbook/ss:Styles/ss:Style/ss:Font[ generate-id(.) = generate-id(key('same-named-font', concat(@ss:FontName, @x:Family))[1])]">
432					<xsl:sort select="name()"/>
433					<xsl:element name="style:font-face">
434						<xsl:if test="@ss:FontName">
435							<xsl:attribute name="style:name">
436								<xsl:value-of select="@ss:FontName"/>
437							</xsl:attribute>
438							<xsl:attribute name="svg:font-family">
439								<xsl:value-of select="@ss:FontName"/>
440							</xsl:attribute>
441						</xsl:if>
442						<xsl:if test="@x:Family">
443							<xsl:attribute name="style:font-family-generic">
444								<xsl:call-template name="translate-font-family-generic">
445									<xsl:with-param name="family" select="@x:Family"/>
446								</xsl:call-template>
447							</xsl:attribute>
448						</xsl:if>
449					</xsl:element>
450				</xsl:for-each>
451			</xsl:if>
452			<xsl:for-each select="/ss:Workbook/ss:Worksheet/ss:Table/ss:Row/ss:Cell/descendant::html:Font[@html:Face][ generate-id(.) = generate-id(key('same-named-face', concat(@html:Face, @x:Family))[1])]">
453				<xsl:sort select="name()"/>
454				<xsl:element name="style:font-face">
455					<xsl:attribute name="style:name">
456						<xsl:value-of select="@html:Face"/>
457					</xsl:attribute>
458					<xsl:attribute name="svg:font-family">
459						<xsl:value-of select="@html:Face"/>
460					</xsl:attribute>
461					<xsl:attribute name="style:font-family-generic">
462						<xsl:call-template name="translate-font-family-generic">
463							<xsl:with-param name="family" select="@x:Family"/>
464						</xsl:call-template>
465					</xsl:attribute>
466				</xsl:element>
467			</xsl:for-each>
468		</office:font-face-decls>
469	</xsl:template>
470	<xsl:template name="translate-font-family-generic">
471		<xsl:param name="family"/>
472		<xsl:choose>
473			<xsl:when test="$family='Swiss'">swiss</xsl:when>
474			<xsl:when test="$family='Modern'">modern</xsl:when>
475			<xsl:when test="$family='Roman'">roman</xsl:when>
476			<xsl:when test="$family='Script'">script</xsl:when>
477			<xsl:when test="$family='Decorative'">decorative</xsl:when>
478			<!-- change 'System' to 'Automatic' for Excel -->
479			<xsl:when test="$family='Automatic'">system</xsl:when>
480			<xsl:otherwise>system</xsl:otherwise>
481		</xsl:choose>
482	</xsl:template>
483	<xsl:template match="ss:Workbook/ss:Worksheet" mode="styles">
484		<office:styles>
485			<xsl:apply-templates select="/ss:Workbook/ss:Styles/ss:Style[@ss:Name]"/>
486			<xsl:apply-templates select="/ss:Workbook/ss:Styles/ss:Style/ss:NumberFormat[@ss:Format]"/>
487			<!-- if ConditionalFormatting exists,it should generate some styles for style:style -->
488			<xsl:if test="/ss:Workbook/ss:Worksheet/x:ConditionalFormatting">
489				<xsl:call-template name="CondFormat_office_style"/>
490			</xsl:if>
491		</office:styles>
492		<office:automatic-styles>
493			<xsl:apply-templates select="/ss:Workbook/ss:Worksheet/ss:Table"/>
494			<xsl:apply-templates select="/ss:Workbook/ss:Styles/ss:Style[not(@ss:Name)]"/>
495			<xsl:apply-templates select="/ss:Workbook/ss:Styles/ss:Style/ss:Font[@ss:VerticalAlign]"/>
496			<!-- applying to ss:Data (but *, as also ss:Data nested in ss:Comments -->
497			<xsl:apply-templates select="/ss:Workbook/ss:Worksheet/ss:Table/ss:Row/ss:Cell/*[descendant-or-self::*[namespace-uri()='http://www.w3.org/TR/REC-html40']]"/>
498			<xsl:apply-templates select="/ss:Workbook/ss:Worksheet/x:WorksheetOptions/x:PageSetup//@x:Data"/>
499			<!-- if ConditionalFormatting exists,transforing the styles -->
500			<xsl:if test="/ss:Workbook/ss:Worksheet/x:ConditionalFormatting">
501				<xsl:call-template name="CondFormat_automatic_style"/>
502			</xsl:if>
503			<xsl:call-template name="create-page-master">
504				<xsl:with-param name="worksheetoptions" select="/ss:Workbook/ss:Worksheet/x:WorksheetOptions"/>
505			</xsl:call-template>
506		</office:automatic-styles>
507		<office:master-styles>
508			<xsl:call-template name="create-master-styles">
509				<xsl:with-param name="worksheetoptions" select="/ss:Workbook/ss:Worksheet/x:WorksheetOptions"/>
510			</xsl:call-template>
511		</office:master-styles>
512	</xsl:template>
513	<xsl:template name="CondFormat_office_style">
514		<!-- translate the ConditionalFormatting style,including font,size,color,etc -->
515		<xsl:for-each select="/ss:Workbook/ss:Worksheet/x:ConditionalFormatting">
516			<xsl:variable name="table-pos" select="count(../preceding-sibling::ss:Worksheet)+1"/>
517			<xsl:variable name="conditions" select="count(preceding-sibling::x:ConditionalFormatting)+1"/>
518			<!-- Matching multiple styles, but automatic styles are not allowed to inherit from another automatic style
519			<xsl:for-each select="key('tableStyleIDs', key('tableWithConditional', .))
520				[generate-id(.) =
521				 generate-id(key('styleId', .)[1])] ">
522				 <xsl:sort select="." />
523
524				 <xsl:apply-templates select="/ss:Workbook/ss:Styles/ss:Style[@ss:ID = current()/.]"/>
525			</xsl:for-each>
526			-->
527			<xsl:for-each select="x:Condition">
528				<xsl:variable name="condition-number" select="count(preceding-sibling::x:Condition)+1"/>
529				<xsl:element name="style:style">
530					<xsl:attribute name="style:name">
531						<xsl:call-template name="encode-as-nc-name">
532							<xsl:with-param name="string" select="concat('Excel_CondFormat_',$table-pos,'_',$conditions,'_',$condition-number)"/>
533						</xsl:call-template>
534					</xsl:attribute>
535					<xsl:attribute name="style:family">table-cell</xsl:attribute>
536					<xsl:apply-templates select="@ss:Name" />
537					<xsl:element name="style:table-cell-properties">
538						<xsl:choose>
539							<xsl:when test="x:Format/@Style">
540								<xsl:variable name="stylevalue" select="./x:Format/@Style"/>
541								<xsl:call-template name="recursion-condformat-style-table-cell">
542									<xsl:with-param name="style-value-t">
543										<xsl:choose>
544											<xsl:when test="substring($stylevalue,string-length($stylevalue),1) != ';'">
545												<xsl:value-of select="concat($stylevalue,';')"/>
546											</xsl:when>
547											<xsl:otherwise>
548												<xsl:value-of select="$stylevalue"/>
549											</xsl:otherwise>
550										</xsl:choose>
551									</xsl:with-param>
552								</xsl:call-template>
553							</xsl:when>
554						</xsl:choose>
555					</xsl:element>
556					<xsl:element name="style:text-properties">
557						<xsl:choose>
558							<xsl:when test="x:Format/@Style">
559								<xsl:variable name="stylevalue" select="./x:Format/@Style"/>
560								<xsl:call-template name="recursion-condformat-style-text">
561									<xsl:with-param name="style-value-t">
562										<xsl:choose>
563											<xsl:when test="substring($stylevalue,string-length($stylevalue),1) != ';'">
564												<xsl:value-of select="concat($stylevalue,';')"/>
565											</xsl:when>
566											<xsl:otherwise>
567												<xsl:value-of select="$stylevalue"/>
568											</xsl:otherwise>
569										</xsl:choose>
570									</xsl:with-param>
571								</xsl:call-template>
572							</xsl:when>
573							<xsl:otherwise>
574								<xsl:attribute name="fo:font-style">
575									<xsl:value-of select="'italic'"/>
576								</xsl:attribute>
577								<xsl:attribute name="style:text-underline-type">
578									<xsl:value-of select="'single'"/>
579								</xsl:attribute>
580								<xsl:attribute name="style:text-underline-color">
581									<xsl:value-of select="'font-color'"/>
582								</xsl:attribute>
583								<xsl:attribute name="fo:font-weight">
584									<xsl:value-of select="'bold'"/>
585								</xsl:attribute>
586							</xsl:otherwise>
587						</xsl:choose>
588					</xsl:element>
589				</xsl:element>
590			</xsl:for-each>
591		</xsl:for-each>
592	</xsl:template>
593	<xsl:template match="@ss:Name">
594		<xsl:attribute name="style:display-name">
595			<xsl:value-of select="."/>
596		</xsl:attribute>
597	</xsl:template>
598	<xsl:template name="recursion-condformat-style-table-cell">
599		<!-- generates style:style for ConditionalFormatting -->
600		<xsl:param name="style-value-t"/>
601		<xsl:variable name="style-value" select="normalize-space($style-value-t)"/>
602		<xsl:choose>
603			<xsl:when test="starts-with($style-value,'background')">
604				<xsl:choose>
605					<xsl:when test="contains($style-value,'mso-pattern')">
606						<xsl:variable name="color-value">
607							<xsl:call-template name="translate-color-style">
608								<xsl:with-param name="source-str" select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/>
609							</xsl:call-template>
610						</xsl:variable>
611						<xsl:variable name="mso-value">
612							<xsl:call-template name="translate-color-style">
613								<xsl:with-param name="source-str" select="normalize-space(substring-after($style-value,'mso-pattern'))"/>
614							</xsl:call-template>
615						</xsl:variable>
616						<xsl:variable name="mso-color" select="substring-after($mso-value,'#')"/>
617						<xsl:variable name="pattern-color-value" select="substring($mso-color,1,6)"/>
618						<xsl:variable name="pattern" select="concat('0.',normalize-space(substring-before(substring-after($mso-color,'gray-'),';')))"/>
619						<xsl:variable name="pattern-color">
620							<xsl:call-template name="cell-pattern-color">
621								<xsl:with-param name="pattern" select="$pattern"/>
622								<xsl:with-param name="color-value" select="$color-value"/>
623								<xsl:with-param name="pattern-color-value" select="concat('#',$pattern-color-value)"/>
624							</xsl:call-template>
625						</xsl:variable>
626						<xsl:attribute name="fo:background-color">
627							<xsl:value-of select="normalize-space($pattern-color)"/>
628						</xsl:attribute>
629					</xsl:when>
630					<xsl:otherwise>
631						<xsl:attribute name="fo:background-color">
632							<xsl:call-template name="translate-color-style">
633								<xsl:with-param name="source-str" select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/>
634							</xsl:call-template>
635						</xsl:attribute>
636					</xsl:otherwise>
637				</xsl:choose>
638			</xsl:when>
639			<xsl:when test="starts-with($style-value,'border')">
640				<xsl:attribute name="fo:border">
641					<xsl:value-of select="'0.002cm solid #000000'"/>
642				</xsl:attribute>
643			</xsl:when>
644		</xsl:choose>
645		<xsl:if test="contains($style-value,':')">
646			<xsl:call-template name="recursion-condformat-style-table-cell">
647				<xsl:with-param name="style-value-t" select="substring-after($style-value,';')"/>
648			</xsl:call-template>
649		</xsl:if>
650	</xsl:template>
651	<xsl:template name="recursion-condformat-style-text">
652		<!-- generates style:style for ConditionalFormatting -->
653		<xsl:param name="style-value-t"/>
654		<xsl:variable name="style-value" select="normalize-space($style-value-t)"/>
655		<xsl:choose>
656			<xsl:when test="starts-with($style-value,'color')">
657				<xsl:attribute name="fo:color">
658					<xsl:call-template name="translate-color-style">
659						<xsl:with-param name="source-str" select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/>
660					</xsl:call-template>
661				</xsl:attribute>
662			</xsl:when>
663			<xsl:when test="starts-with($style-value,'font-style')">
664				<xsl:attribute name="fo:font-style">
665					<xsl:value-of select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/>
666				</xsl:attribute>
667			</xsl:when>
668			<xsl:when test="starts-with($style-value,'font-weight')">
669				<xsl:variable name="font-weight" select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/>
670				<xsl:attribute name="fo:font-weight">
671					<xsl:choose>
672						<xsl:when test="($font-weight &gt; 300) and ($font-weight &lt; 500)">
673							<xsl:value-of select="'normal'"/>
674						</xsl:when>
675						<xsl:when test="($font-weight &gt; 500) or ($font-weight = 500)">
676							<xsl:value-of select="'bold'"/>
677						</xsl:when>
678						<xsl:otherwise>
679							<xsl:value-of select="'0'"/>
680						</xsl:otherwise>
681					</xsl:choose>
682				</xsl:attribute>
683			</xsl:when>
684			<xsl:when test="starts-with($style-value,'text-underline-style')">
685				<xsl:attribute name="style:text-underline-type">
686					<xsl:value-of select="normalize-space(substring-before(substring-after($style-value,':'),';'))"/>
687				</xsl:attribute>
688				<xsl:attribute name="style:text-underline-color">
689					<xsl:value-of select="'#000000'"/>
690				</xsl:attribute>
691			</xsl:when>
692		</xsl:choose>
693		<xsl:if test="contains($style-value,':')">
694			<xsl:call-template name="recursion-condformat-style-text">
695				<xsl:with-param name="style-value-t" select="substring-after($style-value,';')"/>
696			</xsl:call-template>
697		</xsl:if>
698	</xsl:template>
699	<xsl:template name="translate-color-style">
700		<!-- translate the word of color to hex code of color -->
701		<xsl:param name="source-str"/>
702		<xsl:choose>
703			<xsl:when test="starts-with($source-str,'#')">
704				<xsl:value-of select="$source-str"/>
705			</xsl:when>
706			<xsl:otherwise>
707				<xsl:choose>
708					<xsl:when test="starts-with($source-str,'black')">
709						<xsl:value-of select="'#000000'"/>
710					</xsl:when>
711					<xsl:when test="starts-with($source-str,'maroon')">
712						<xsl:value-of select="'#800000'"/>
713					</xsl:when>
714					<xsl:when test="starts-with($source-str,'red')">
715						<xsl:value-of select="'#FF0000'"/>
716					</xsl:when>
717					<xsl:when test="starts-with($source-str,'fuchsia')">
718						<xsl:value-of select="'#FF00FF'"/>
719					</xsl:when>
720					<xsl:when test="starts-with($source-str,'olive')">
721						<xsl:value-of select="'#808000'"/>
722					</xsl:when>
723					<xsl:when test="starts-with($source-str,'yellow')">
724						<xsl:value-of select="'#FFFF00'"/>
725					</xsl:when>
726					<xsl:when test="starts-with($source-str,'green')">
727						<xsl:value-of select="'#008000'"/>
728					</xsl:when>
729					<xsl:when test="starts-with($source-str,'lime')">
730						<xsl:value-of select="'#00FF00'"/>
731					</xsl:when>
732					<xsl:when test="starts-with($source-str,'teal')">
733						<xsl:value-of select="'#008080'"/>
734					</xsl:when>
735					<xsl:when test="starts-with($source-str,'aqua')">
736						<xsl:value-of select="'#00FFFF'"/>
737					</xsl:when>
738					<xsl:when test="starts-with($source-str,'navy')">
739						<xsl:value-of select="'#000080'"/>
740					</xsl:when>
741					<xsl:when test="starts-with($source-str,'blue')">
742						<xsl:value-of select="'#0000FF'"/>
743					</xsl:when>
744					<xsl:when test="starts-with($source-str,'purple')">
745						<xsl:value-of select="'#800080'"/>
746					</xsl:when>
747					<xsl:when test="starts-with($source-str,'gray')">
748						<xsl:value-of select="'#808080'"/>
749					</xsl:when>
750					<xsl:when test="starts-with($source-str,'silver')">
751						<xsl:value-of select="'#C0C0C0'"/>
752					</xsl:when>
753					<xsl:when test="starts-with($source-str,'white')">
754						<xsl:value-of select="'#FFFFFF'"/>
755					</xsl:when>
756					<xsl:otherwise>
757						<xsl:value-of select="'#FFFFFF'"/>
758					</xsl:otherwise>
759				</xsl:choose>
760			</xsl:otherwise>
761		</xsl:choose>
762	</xsl:template>
763	<xsl:key match="/ss:Workbook/ss:Worksheet/ss:Table" name="tableWithConditional" use="following-sibling::x:ConditionalFormatting"/>
764	<xsl:key match="ss:Table/ss:Row/ss:Cell/@ss:StyleID" name="tableStyleIDs" use="ancestor::ss:Table"/>
765	<xsl:key name="styleId" match="@ss:StyleID" use="."/>
766	<xsl:template name="CondFormat_automatic_style">
767		<!-- For each conditionalFormatting We inject a new style, which is a child of the current found style -->
768		<xsl:for-each select="/ss:Workbook/ss:Worksheet/x:ConditionalFormatting">
769			<xsl:variable name="table-pos" select="count(../preceding-sibling::ss:Worksheet)+1"/>
770			<xsl:variable name="conditions" select="count(preceding-sibling::x:ConditionalFormatting)+1"/>
771			<xsl:variable name="conditionalFormatting" select="."/>
772			<!-- for all 'ssStyle/@ss:ID's, which are in tables connected within this conditional formatting  -->
773			<xsl:for-each select="key('tableStyleIDs', key('tableWithConditional', .)) [generate-id(.) = generate-id(key('styleId', .)[1])] ">
774				<!-- sort the style ID by their naming -->
775				<xsl:sort select="."/>
776				<xsl:element name="style:style">
777					<xsl:attribute name="style:name">
778						<xsl:call-template name="encode-as-nc-name">
779							<xsl:with-param name="string" select="concat(.,'-ce',$table-pos,'-',$conditions)"/>
780						</xsl:call-template>
781					</xsl:attribute>
782					<xsl:attribute name="style:family">table-cell</xsl:attribute>
783					<xsl:variable name="style" select="key('Style', .)" />
784					<xsl:choose>
785						<xsl:when test="$style/@ss:Name">
786							<xsl:attribute name="style:parent-style-name">
787								<xsl:call-template name="encode-as-nc-name">
788									<xsl:with-param name="string" select="."/>
789								</xsl:call-template>
790							</xsl:attribute>
791						</xsl:when>
792						<!-- as we create an automatic style, the parent is not allowed to be an automatic style as well
793							 if the parent would be a automatic (unnamed) style, the style information have to be embedded to this style -->
794						<xsl:otherwise>
795							<xsl:attribute name="style:parent-style-name">
796								<xsl:call-template name="encode-as-nc-name">
797									<xsl:with-param name="string" select="$style/@ss:Parent"/>
798								</xsl:call-template>
799							</xsl:attribute>
800							<xsl:if test="$style/ss:NumberFormat/@ss:Format">
801								<xsl:attribute name="style:data-style-name">
802									<xsl:value-of select="concat($style/@ss:ID, 'F')"/>
803								</xsl:attribute>
804							</xsl:if>
805							<xsl:apply-templates select="$style" mode="style-style-content"/>
806						</xsl:otherwise>
807					</xsl:choose>
808					<xsl:for-each select="$conditionalFormatting/x:Condition">
809						<xsl:variable name="condition-number" select="count(preceding-sibling::x:Condition)+1"/>
810						<xsl:variable name="base-address">
811							<xsl:choose>
812								<xsl:when test="contains(../x:Range,',')">
813									<xsl:choose>
814										<xsl:when test="contains(substring-before(../x:Range,','),':')">
815											<xsl:value-of select="substring-before(substring-after(../x:Range,':'),',')"/>
816										</xsl:when>
817										<xsl:otherwise>
818											<xsl:value-of select="substring-before(../x:Range,',')"/>
819										</xsl:otherwise>
820									</xsl:choose>
821								</xsl:when>
822								<xsl:otherwise>
823									<xsl:value-of select="../x:Range"/>
824								</xsl:otherwise>
825							</xsl:choose>
826						</xsl:variable>
827						<xsl:variable name="columnNumber">
828							<xsl:choose>
829								<xsl:when test="contains($base-address, ':')">
830									<xsl:value-of select="substring-after(substring-after($base-address, ':'),'C')"/>
831								</xsl:when>
832								<xsl:otherwise>
833									<xsl:value-of select="substring-after($base-address,'C')"/>
834								</xsl:otherwise>
835							</xsl:choose>
836						</xsl:variable>
837						<xsl:variable name="rowNumber">
838							<xsl:choose>
839								<xsl:when test="contains($base-address, ':')">
840									<xsl:value-of select="substring-before(substring-after(substring-after($base-address, ':'),'R'),'C')"/>
841								</xsl:when>
842								<xsl:otherwise>
843									<xsl:value-of select="substring-before(substring-after($base-address,'R'),'C')"/>
844								</xsl:otherwise>
845							</xsl:choose>
846						</xsl:variable>
847						<xsl:variable name="base-cell-address">
848							<xsl:call-template name="translate-unit">
849								<xsl:with-param name="column-number" select="$columnNumber"/>
850								<xsl:with-param name="row-number" select="$rowNumber"/>
851								<xsl:with-param name="column-pos-style" select="'relative'"/>
852								<xsl:with-param name="row-pos-style" select="'relative'"/>
853							</xsl:call-template>
854						</xsl:variable>
855						<xsl:variable name="condition-value">
856							<xsl:call-template name="translate-condition">
857								<xsl:with-param name="cell-column-pos" select="$columnNumber"/>
858								<xsl:with-param name="cell-row-pos" select="$rowNumber"/>
859							</xsl:call-template>
860						</xsl:variable>
861						<xsl:element name="style:map">
862							<xsl:attribute name="style:condition">
863								<xsl:value-of select="$condition-value"/>
864							</xsl:attribute>
865							<xsl:attribute name="style:apply-style-name">
866								<xsl:value-of select="concat('Excel_CondFormat_',$table-pos,'_',$conditions,'_',$condition-number)"/>
867							</xsl:attribute>
868							<xsl:attribute name="style:base-cell-address">
869								<xsl:value-of select="concat(../../@ss:Name,'.',$base-cell-address)"/>
870							</xsl:attribute>
871						</xsl:element>
872					</xsl:for-each>
873				</xsl:element>
874			</xsl:for-each>
875		</xsl:for-each>
876	</xsl:template>
877	<xsl:template name="translate-condition">
878		<xsl:param name="cell-row-pos"/>
879		<xsl:param name="cell-column-pos"/>
880		<!-- translates the condition to generate formula -->
881		<xsl:variable name="address-value">
882			<xsl:call-template name="translate-expression">
883				<xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
884				<xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
885				<xsl:with-param name="expression" select="x:Value1"/>
886				<xsl:with-param name="return-value" select="''"/>
887			</xsl:call-template>
888		</xsl:variable>
889		<xsl:choose>
890			<xsl:when test="x:Qualifier">
891				<xsl:variable name="qualifier" select="x:Qualifier"/>
892				<xsl:variable name="first-value" select="x:Value1"/>
893				<xsl:choose>
894					<xsl:when test="$qualifier = 'Equal'">
895						<xsl:choose>
896							<xsl:when test="starts-with($first-value,'&quot;')">
897								<xsl:value-of select="concat('cell-content()=',$address-value)"/>
898							</xsl:when>
899							<xsl:otherwise>
900								<xsl:value-of select="concat('cell-content()=[',$address-value,']')"/>
901							</xsl:otherwise>
902						</xsl:choose>
903					</xsl:when>
904					<xsl:when test="$qualifier = 'Less'">
905						<xsl:value-of select="concat('cell-content()&lt;[',$address-value,']')"/>
906					</xsl:when>
907					<xsl:when test="$qualifier = 'Greater'">
908						<xsl:value-of select="concat('cell-content()&gt;[',$address-value,']')"/>
909					</xsl:when>
910					<xsl:when test="$qualifier = 'LessOrEqual'">
911						<xsl:value-of select="concat('cell-content()&lt;=[',$address-value,']')"/>
912					</xsl:when>
913					<xsl:when test="$qualifier = 'GreaterOrEqual'">
914						<xsl:value-of select="concat('cell-content()&gt;=[',$address-value,']')"/>
915					</xsl:when>
916					<xsl:when test="$qualifier = 'NotEqual'">
917						<xsl:value-of select="concat('cell-content()!=[',$address-value,']')"/>
918					</xsl:when>
919					<xsl:when test="$qualifier = 'Between'">
920						<xsl:variable name="second-value">
921							<xsl:call-template name="translate-expression">
922								<xsl:with-param name="cell-row-pos" select="0"/>
923								<xsl:with-param name="cell-column-pos" select="0"/>
924								<xsl:with-param name="expression" select="x:Value2"/>
925								<xsl:with-param name="return-value" select="''"/>
926							</xsl:call-template>
927						</xsl:variable>
928						<xsl:value-of select="concat('cell-content-is-between([',$address-value,'],[',$second-value,'])')"/>
929					</xsl:when>
930					<xsl:when test="$qualifier = 'NotBetween'">
931						<xsl:variable name="second-value">
932							<xsl:call-template name="translate-expression">
933								<xsl:with-param name="cell-row-pos" select="0"/>
934								<xsl:with-param name="cell-column-pos" select="0"/>
935								<xsl:with-param name="expression" select="x:Value2"/>
936								<xsl:with-param name="return-value" select="''"/>
937							</xsl:call-template>
938						</xsl:variable>
939						<xsl:value-of select="concat('cell-content-is-not-between([',$address-value,'],[',$second-value,'])')"/>
940					</xsl:when>
941				</xsl:choose>
942			</xsl:when>
943			<xsl:otherwise>
944				<xsl:value-of select="concat('is-true-formula(',$address-value,')')"/>
945			</xsl:otherwise>
946		</xsl:choose>
947	</xsl:template>
948	<!-- Used in case of 'style:map', conditional formatting, where a style references to another -->
949	<xsl:key match="/ss:Workbook/ss:Worksheet/ss:Table/ss:Row/ss:Cell" name="cells" use="@ss:StyleID"/>
950	<xsl:template match="ss:NumberFormat">
951		<xsl:variable name="unit-count" select="string-length(@ss:Format) - string-length(translate(@ss:Format,';','')) + 1"/>
952		<xsl:variable name="proto-style-id" select="../@ss:ID"/>
953		<xsl:call-template name="process-number-format-unit">
954			<xsl:with-param name="number-format-unit" select="@ss:Format"/>
955			<xsl:with-param name="style-id" select="concat($proto-style-id,'F')"/>
956			<xsl:with-param name="format-type" select="key('cells', $proto-style-id)/ss:Data/@ss:Type"/>
957			<xsl:with-param name="total-unit" select="$unit-count"/>
958			<xsl:with-param name="current-unit" select="0"/>
959		</xsl:call-template>
960	</xsl:template>
961	<!-- Note: conditions appearing only once at the beginning are mixed with others -->
962	<xsl:template name="process-number-format-unit">
963		<xsl:param name="number-format-unit"/>
964		<xsl:param name="style-id"/>
965		<xsl:param name="format-type"/>
966		<xsl:param name="total-unit"/>
967		<xsl:param name="current-unit"/>
968		<xsl:choose>
969			<!-- if total-unit > 1 and the last unit is just @, delete it -->
970			<xsl:when test="$current-unit = 0 and $total-unit &gt; 1 and substring( $number-format-unit, string-length($number-format-unit) - 1) = ';@'">
971				<xsl:call-template name="process-number-format-unit">
972					<xsl:with-param name="number-format-unit" select="substring( $number-format-unit, 1, string-length($number-format-unit) - 2)"/>
973					<xsl:with-param name="style-id" select="$style-id"/>
974					<xsl:with-param name="format-type" select="$format-type"/>
975					<xsl:with-param name="total-unit" select="$total-unit - 1"/>
976					<xsl:with-param name="current-unit" select="0"/>
977				</xsl:call-template>
978			</xsl:when>
979			<!-- $number-format-unit enum values: General, General Number, General Date, Long Date, Medium Date, Short Date, Long Time,
980			 Medium Time, Short Time, Currency, Euro Currency, Fixed, Standard, Percent, Scientific, Yes/No, True/False, On/Off -->
981			<xsl:when test="$number-format-unit = 'Currency'">
982				<number:currency-style style:name="{concat( $style-id, 'P1')}" style:volatile="true">
983					<number:text>$</number:text>
984					<number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
985				</number:currency-style>
986				<number:currency-style style:name="{$style-id}">
987					<style:text-properties fo:color="#ff0000"/>
988					<number:text>$-</number:text>
989					<number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
990					<style:map style:condition="value()&gt;=0" style:apply-style-name="{concat( $style-id, 'P1')}"/>
991				</number:currency-style>
992			</xsl:when>
993			<xsl:when test="$number-format-unit = 'Euro Currency'">
994				<number:currency-style style:name="{concat( $style-id, 'P1')}" style:volatile="true">
995					<number:text>€ </number:text>
996					<number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
997				</number:currency-style>
998				<number:currency-style style:name="{$style-id}">
999					<style:text-properties fo:color="#ff0000"/>
1000					<number:text>(€ </number:text>
1001					<number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
1002					<number:text>)</number:text>
1003					<style:map style:condition="value()&gt;=0" style:apply-style-name="{concat( $style-id, 'P1')}"/>
1004				</number:currency-style>
1005			</xsl:when>
1006			<xsl:when test="$number-format-unit = 'Yes/No' or $number-format-unit = 'True/False' or $number-format-unit = 'On/Off'">
1007				<xsl:variable name="left-code" select="substring-before( $number-format-unit, '/')"/>
1008				<xsl:variable name="right-code" select="substring-after( $number-format-unit, '/')"/>
1009				<number:number-style style:name="{concat( $style-id, 'P1')}" style:volatile="true">
1010					<number:text>
1011						<xsl:value-of select="$left-code"/>
1012					</number:text>
1013				</number:number-style>
1014				<number:number-style style:name="{concat( $style-id, 'P2')}" style:volatile="true">
1015					<number:text>
1016						<xsl:value-of select="$left-code"/>
1017					</number:text>
1018				</number:number-style>
1019				<number:number-style style:name="{$style-id}">
1020					<number:text>
1021						<xsl:value-of select="$right-code"/>
1022					</number:text>
1023					<style:map style:condition="value()&gt;0" style:apply-style-name="{concat( $style-id, 'P1')}"/>
1024					<style:map style:condition="value()&lt;0" style:apply-style-name="{concat( $style-id, 'P2')}"/>
1025				</number:number-style>
1026			</xsl:when>
1027			<xsl:otherwise>
1028				<xsl:if test="$total-unit &gt; 1 and $current-unit = 0">
1029					<!-- still complete number format string of multiple sub-formats, split them out -->
1030					<xsl:call-template name="process-number-format-unit">
1031						<xsl:with-param name="number-format-unit" select="substring-before($number-format-unit,';')"/>
1032						<xsl:with-param name="style-id" select="concat($style-id,'P1')"/>
1033						<xsl:with-param name="format-type" select="$format-type"/>
1034						<xsl:with-param name="total-unit" select="$total-unit"/>
1035						<xsl:with-param name="current-unit" select="1"/>
1036					</xsl:call-template>
1037					<xsl:if test="$total-unit &gt; 2">
1038						<xsl:call-template name="process-number-format-unit">
1039							<xsl:with-param name="number-format-unit" select="substring-before(substring-after($number-format-unit,';'),';')"/>
1040							<xsl:with-param name="style-id" select="concat($style-id,'P2')"/>
1041							<xsl:with-param name="format-type" select="$format-type"/>
1042							<xsl:with-param name="total-unit" select="$total-unit"/>
1043							<xsl:with-param name="current-unit" select="2"/>
1044						</xsl:call-template>
1045					</xsl:if>
1046					<xsl:if test="$total-unit &gt; 3">
1047						<!-- four sub number format -->
1048						<xsl:call-template name="process-number-format-unit">
1049							<xsl:with-param name="number-format-unit" select="substring-before(substring-after(substring-after($number-format-unit,';'),';'),';')"/>
1050							<xsl:with-param name="style-id" select="concat($style-id,'P3')"/>
1051							<xsl:with-param name="format-type" select="$format-type"/>
1052							<xsl:with-param name="total-unit" select="$total-unit"/>
1053							<xsl:with-param name="current-unit" select="3"/>
1054						</xsl:call-template>
1055					</xsl:if>
1056				</xsl:if>
1057				<!-- symbol number format converted, below deal with ordinary number formatting -->
1058				<xsl:variable name="current-number-format-unit">
1059					<xsl:choose>
1060						<xsl:when test="$total-unit = 1 and $current-unit = 0">
1061							<xsl:value-of select="$number-format-unit"/>
1062						</xsl:when>
1063						<xsl:when test="$total-unit = 2 and $current-unit = 0">
1064							<xsl:value-of select="substring-after($number-format-unit,';')"/>
1065						</xsl:when>
1066						<xsl:when test="$total-unit = 3 and $current-unit = 0">
1067							<xsl:value-of select="substring-after(substring-after($number-format-unit,';'),';')"/>
1068						</xsl:when>
1069						<xsl:when test="$current-unit = 0">
1070							<!-- the forth sub number format -->
1071							<xsl:value-of select="substring-after(substring-after(substring-after($number-format-unit,';'),';'),';')"/>
1072						</xsl:when>
1073						<xsl:otherwise>
1074							<!-- not the default sub number format, glu -->
1075							<xsl:value-of select="$number-format-unit"/>
1076						</xsl:otherwise>
1077					</xsl:choose>
1078				</xsl:variable>
1079				<xsl:variable name="style-type-name">
1080					<xsl:choose>
1081						<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>
1082						<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>
1083						<xsl:when test="($format-type = 'DateTime' or $format-type = 'String') 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>
1084						<xsl:when test="($format-type = 'DateTime' or $format-type = 'String') 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>
1085						<xsl:when test="contains($current-number-format-unit, 'Number') or contains($current-number-format-unit, 'General') 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,'#') or contains($current-number-format-unit,'0') or contains($current-number-format-unit,'?') )">number:number-style</xsl:when>
1086						<xsl:when test="$format-type = 'Boolean'">number:boolean-style</xsl:when>
1087						<xsl:otherwise>number:text-style</xsl:otherwise>
1088					</xsl:choose>
1089				</xsl:variable>
1090				<xsl:element name="{$style-type-name}">
1091					<xsl:attribute name="style:name">
1092						<xsl:value-of select="$style-id"/>
1093					</xsl:attribute>
1094					<xsl:apply-templates select="@ss:Name" />
1095					<!-- removed in OASIS XML
1096					<xsl:attribute name="style:family">data-style</xsl:attribute>-->
1097					<xsl:if test="$current-unit &gt; 0">
1098						<xsl:attribute name="style:volatile">true</xsl:attribute>
1099					</xsl:if>
1100					<xsl:if test="contains ( $current-number-format-unit, '[h]') or contains ( $current-number-format-unit, '[m]') or contains ( $current-number-format-unit, '[s]')">
1101						<xsl:attribute name="number:truncate-on-overflow">false</xsl:attribute>
1102					</xsl:if>
1103					<xsl:if test="contains($current-number-format-unit,'[$') or contains($current-number-format-unit, '[DBNum')">
1104						<xsl:call-template name="create-language-country-attribute">
1105							<xsl:with-param name="attribute-code" select="substring-before(substring-after(substring-after($current-number-format-unit,'[$'),'-'),']')"/>
1106							<xsl:with-param name="number-code-style" select="substring-before( substring-after($current-number-format-unit,'[DBNum'),']')"/>
1107						</xsl:call-template>
1108					</xsl:if>
1109					<xsl:if test="contains( $current-number-format-unit, '[')">
1110						<xsl:element name="style:text-properties">
1111							<xsl:choose>
1112								<xsl:when test="contains( $current-number-format-unit, '[Red')">
1113									<xsl:attribute name="fo:color">#ff0000</xsl:attribute>
1114								</xsl:when>
1115								<xsl:when test="contains( $current-number-format-unit, '[Black')">
1116									<xsl:attribute name="fo:color">#000000</xsl:attribute>
1117								</xsl:when>
1118								<xsl:when test="contains( $current-number-format-unit, '[Blue')">
1119									<xsl:attribute name="fo:color">#0000ff</xsl:attribute>
1120								</xsl:when>
1121								<xsl:when test="contains( $current-number-format-unit, '[Cyan')">
1122									<xsl:attribute name="fo:color">#00ffff</xsl:attribute>
1123								</xsl:when>
1124								<xsl:when test="contains( $current-number-format-unit, '[Green')">
1125									<xsl:attribute name="fo:color">#00ff00</xsl:attribute>
1126								</xsl:when>
1127								<xsl:when test="contains( $current-number-format-unit, '[Magenta')">
1128									<xsl:attribute name="fo:color">#ff00ff</xsl:attribute>
1129								</xsl:when>
1130								<xsl:when test="contains( $current-number-format-unit, '[White')">
1131									<xsl:attribute name="fo:color">#ffffff</xsl:attribute>
1132								</xsl:when>
1133								<xsl:when test="contains( $current-number-format-unit, '[Yellow')">
1134									<xsl:attribute name="fo:color">#ffff00</xsl:attribute>
1135								</xsl:when>
1136							</xsl:choose>
1137						</xsl:element>
1138					</xsl:if>
1139					<!-- the type of condition-pos:1,the former third part of General; 2, the last General. the methods handling diffirent -->
1140					<xsl:call-template name="create-number-format-content">
1141						<xsl:with-param name="style-type-name" select="$style-type-name"/>
1142						<xsl:with-param name="number-format-unit" select="$current-number-format-unit"/>
1143						<xsl:with-param name="unit-pos" select="1"/>
1144						<xsl:with-param name="condition-pos">
1145							<xsl:choose>
1146								<xsl:when test="$current-unit = 1 or $current-unit = 2 or $current-unit = 3">
1147									<xsl:value-of select="1"/>
1148								</xsl:when>
1149								<xsl:when test="$current-unit = 0 and not(contains($number-format-unit, ';'))">
1150									<xsl:value-of select="1"/>
1151								</xsl:when>
1152								<xsl:otherwise>
1153									<xsl:value-of select="2"/>
1154								</xsl:otherwise>
1155							</xsl:choose>
1156						</xsl:with-param>
1157					</xsl:call-template>
1158					<!-- creat style:map for other sub number formats -->
1159					<xsl:if test="$current-unit = 0 and $total-unit &gt; 1">
1160						<xsl:variable name="style-condition1">
1161							<xsl:call-template name="get-number-format-condition">
1162								<xsl:with-param name="number-format-unit" select="substring-before($number-format-unit,';')"/>
1163							</xsl:call-template>
1164						</xsl:variable>
1165						<xsl:choose>
1166							<xsl:when test="string-length($style-condition1) &gt; 0">
1167								<style:map style:condition="{concat('value()',$style-condition1)}" style:apply-style-name="{concat($style-id,'P1')}"/>
1168							</xsl:when>
1169							<xsl:otherwise>
1170								<xsl:choose>
1171									<xsl:when test="$total-unit = 2">
1172										<style:map style:condition="value()&gt;=0" style:apply-style-name="{concat($style-id,'P1')}"/>
1173									</xsl:when>
1174									<xsl:otherwise>
1175										<style:map style:condition="value()&gt;0" style:apply-style-name="{concat($style-id,'P1')}"/>
1176									</xsl:otherwise>
1177								</xsl:choose>
1178							</xsl:otherwise>
1179						</xsl:choose>
1180						<xsl:if test="$total-unit &gt; 2">
1181							<xsl:variable name="style-condition2">
1182								<xsl:call-template name="get-number-format-condition">
1183									<xsl:with-param name="number-format-unit" select="substring-before(substring-after($number-format-unit,';'),';')"/>
1184								</xsl:call-template>
1185							</xsl:variable>
1186							<xsl:choose>
1187								<xsl:when test="string-length($style-condition2) &gt; 0">
1188									<style:map style:condition="{concat('value()',$style-condition2)}" style:apply-style-name="{concat($style-id,'P2')}"/>
1189								</xsl:when>
1190								<xsl:otherwise>
1191									<style:map style:condition="value()&lt;0" style:apply-style-name="{concat($style-id,'P2')}"/>
1192								</xsl:otherwise>
1193							</xsl:choose>
1194						</xsl:if>
1195						<xsl:if test="$total-unit &gt; 3">
1196							<!-- four sub number formats, glu -->
1197							<xsl:variable name="style-condition3">
1198								<xsl:call-template name="get-number-format-condition">
1199									<xsl:with-param name="number-format-unit" select="substring-before(substring-after(substring-after($number-format-unit,';'),';'),';')"/>
1200								</xsl:call-template>
1201							</xsl:variable>
1202							<xsl:choose>
1203								<xsl:when test="string-length($style-condition3) &gt; 0">
1204									<style:map style:condition="{concat('value()',$style-condition3)}" style:apply-style-name="{concat($style-id,'P3')}"/>
1205								</xsl:when>
1206								<xsl:otherwise>
1207									<style:map style:condition="value()=0" style:apply-style-name="{concat($style-id,'P3')}"/>
1208								</xsl:otherwise>
1209							</xsl:choose>
1210						</xsl:if>
1211					</xsl:if>
1212				</xsl:element>
1213			</xsl:otherwise>
1214		</xsl:choose>
1215	</xsl:template>
1216	<xsl:template name="create-language-country-attribute">
1217		<xsl:param name="attribute-code"/>
1218		<xsl:param name="number-code-style"/>
1219		<!-- convert Microsoft List of Locale ID (LCID) to language and country codes according to ISO-639 and ISO-3166.
1220			Reference:
1221			http://www.loc.gov/standards/iso639-2/langcodes.html
1222			http://etext.lib.virginia.edu/tei/iso639.html
1223			http://nl.ijs.si/gnusl/cee/std/ISO_3166.html
1224			http://xml.coverpages.org/ripe3166.txt
1225			http://www.worldlanguage.com/
1226			http://www.ethnologue.com/
1227		glu -->
1228		<!-- the variables of language-country-code and number-shape-code transformed to decimal format -->
1229		<xsl:variable name="language-country-code">
1230			<xsl:variable name="temp-code">
1231				<xsl:choose>
1232					<xsl:when test="string-length($attribute-code) &lt;= 4">
1233						<xsl:value-of select="$attribute-code"/>
1234					</xsl:when>
1235					<xsl:otherwise>
1236						<xsl:value-of select="substring($attribute-code,string-length($attribute-code) - 3)"/>
1237					</xsl:otherwise>
1238				</xsl:choose>
1239			</xsl:variable>
1240			<xsl:call-template name="hex2decimal">
1241				<xsl:with-param name="hex-number" select="$temp-code"/>
1242				<xsl:with-param name="index" select="1"/>
1243				<xsl:with-param name="str-length" select="string-length($temp-code)"/>
1244				<xsl:with-param name="last-value" select="0"/>
1245			</xsl:call-template>
1246		</xsl:variable>
1247		<xsl:if test="string-length($attribute-code) &gt; 4 or string-length($number-code-style) &gt; 0">
1248			<xsl:variable name="number-shape-code">
1249				<xsl:variable name="temp-code">
1250					<xsl:choose>
1251						<xsl:when test="string-length($attribute-code) &gt; 4">
1252							<xsl:value-of select="substring($attribute-code, 1, string-length($attribute-code) - 6)"/>
1253						</xsl:when>
1254						<xsl:otherwise>0</xsl:otherwise>
1255					</xsl:choose>
1256				</xsl:variable>
1257				<xsl:call-template name="hex2decimal">
1258					<xsl:with-param name="hex-number" select="$temp-code"/>
1259					<xsl:with-param name="index" select="1"/>
1260					<xsl:with-param name="str-length" select="string-length($temp-code)"/>
1261					<xsl:with-param name="last-value" select="0"/>
1262				</xsl:call-template>
1263			</xsl:variable>
1264			<xsl:attribute name="number:transliteration-style">long</xsl:attribute>
1265			<xsl:choose>
1266				<!-- Western, #01 -->
1267				<xsl:when test="$number-shape-code = 1"/>
1268				<!-- Arabic Indic, #02 -->
1269				<xsl:when test="$number-shape-code = 2"/>
1270				<!-- Extended Arabic Indic, #03 -->
1271				<xsl:when test="$number-shape-code = 3"/>
1272				<!-- Devanagari (Sanskrit - India), #04-->
1273				<xsl:when test="$number-shape-code = 4">
1274					<xsl:attribute name="number:transliteration-language">sa</xsl:attribute>
1275					<xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
1276				</xsl:when>
1277				<!-- Bengali (India), #05 -->
1278				<xsl:when test="$number-shape-code = 5">
1279					<xsl:attribute name="number:transliteration-language">bn</xsl:attribute>
1280					<xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
1281				</xsl:when>
1282				<!-- Gurmukhi (Punjabi - India), #06 -->
1283				<xsl:when test="$number-shape-code = 6">
1284					<xsl:attribute name="number:transliteration-language">pa</xsl:attribute>
1285					<xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
1286				</xsl:when>
1287				<!-- Gujarati (India), #07 -->
1288				<xsl:when test="$number-shape-code = 7">
1289					<xsl:attribute name="number:transliteration-language">gu</xsl:attribute>
1290					<xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
1291				</xsl:when>
1292				<!-- Oriya (India), #08 -->
1293				<xsl:when test="$number-shape-code = 8">
1294					<xsl:attribute name="number:transliteration-language">or</xsl:attribute>
1295					<xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
1296				</xsl:when>
1297				<!-- Tamil (India), #09 -->
1298				<xsl:when test="$number-shape-code = 9">
1299					<xsl:attribute name="number:transliteration-language">ta</xsl:attribute>
1300					<xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
1301				</xsl:when>
1302				<!-- Telugu (India), #0a -->
1303				<xsl:when test="$number-shape-code = 10">
1304					<xsl:attribute name="number:transliteration-language">te</xsl:attribute>
1305					<xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
1306				</xsl:when>
1307				<!-- Kannada (India), #0b -->
1308				<xsl:when test="$number-shape-code = 11">
1309					<xsl:attribute name="number:transliteration-language">kn</xsl:attribute>
1310					<xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
1311				</xsl:when>
1312				<!-- Malayalam (India), #0c -->
1313				<xsl:when test="$number-shape-code = 12">
1314					<xsl:attribute name="number:transliteration-language">ml</xsl:attribute>
1315					<xsl:attribute name="number:transliteration-country">IN</xsl:attribute>
1316				</xsl:when>
1317				<!-- Thai, #0d -->
1318				<xsl:when test="$number-shape-code = 13">
1319					<xsl:attribute name="number:transliteration-language">th</xsl:attribute>
1320					<xsl:attribute name="number:transliteration-country">TH</xsl:attribute>
1321				</xsl:when>
1322				<!-- Lao, #0e -->
1323				<xsl:when test="$number-shape-code = 14">
1324					<xsl:attribute name="number:transliteration-language">lo</xsl:attribute>
1325					<xsl:attribute name="number:transliteration-country">LA</xsl:attribute>
1326				</xsl:when>
1327				<!-- Tibetan (China), #0f -->
1328				<xsl:when test="$number-shape-code = 15">
1329					<xsl:attribute name="number:transliteration-language">bo</xsl:attribute>
1330					<xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
1331				</xsl:when>
1332				<!-- Myanmar (Burma), #10 -->
1333				<xsl:when test="$number-shape-code = 16">
1334					<xsl:attribute name="number:transliteration-language">my</xsl:attribute>
1335					<xsl:attribute name="number:transliteration-country">MM</xsl:attribute>
1336				</xsl:when>
1337				<!-- Ethiopic (Geez), #11 -->
1338				<xsl:when test="$number-shape-code = 17">
1339					<xsl:attribute name="number:transliteration-language">gez</xsl:attribute>
1340					<xsl:attribute name="number:transliteration-country">ET</xsl:attribute>
1341				</xsl:when>
1342				<!-- Khmer (Cambodian), #12-->
1343				<xsl:when test="$number-shape-code = 18">
1344					<xsl:attribute name="number:transliteration-language">km</xsl:attribute>
1345					<xsl:attribute name="number:transliteration-country">KH</xsl:attribute>
1346				</xsl:when>
1347				<!-- Mongolian, #13 -->
1348				<xsl:when test="$number-shape-code = 19">
1349					<xsl:attribute name="number:transliteration-language">mn</xsl:attribute>
1350					<xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
1351				</xsl:when>
1352				<!-- Japanese 1 ([DBNum1]) , #1b, #0411 -->
1353				<xsl:when test="$number-shape-code = 27 or ($number-code-style = '1' and $language-country-code = 1041)">
1354					<xsl:attribute name="number:transliteration-format">一</xsl:attribute>
1355					<xsl:attribute name="number:transliteration-language">ja</xsl:attribute>
1356					<xsl:attribute name="number:transliteration-country">JP</xsl:attribute>
1357				</xsl:when>
1358				<!-- Japanese 2 ([DBNum2]) ,#1c, #0411 -->
1359				<xsl:when test="$number-shape-code = 28 or ($number-code-style = '2' and $language-country-code = 1041 )">
1360					<xsl:attribute name="number:transliteration-format">壹</xsl:attribute>
1361					<xsl:attribute name="number:transliteration-language">ja</xsl:attribute>
1362					<xsl:attribute name="number:transliteration-country">JP</xsl:attribute>
1363				</xsl:when>
1364				<!-- Japanese 3 ([DBNum3]), #1d, #0411 -->
1365				<xsl:when test="$number-shape-code = 29 or ($number-code-style = '3' and $language-country-code = 1041 )">
1366					<xsl:attribute name="number:transliteration-format">1</xsl:attribute>
1367					<xsl:attribute name="number:transliteration-language">ja</xsl:attribute>
1368					<xsl:attribute name="number:transliteration-country">JP</xsl:attribute>
1369				</xsl:when>
1370				<!-- Simplified Chinese 1 ([DBNum1]), #1e, #0804 -->
1371				<xsl:when test="$number-shape-code = 30 or ($number-code-style = '1' and $language-country-code = 2052 )">
1372					<xsl:attribute name="number:transliteration-format">一</xsl:attribute>
1373					<xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
1374					<xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
1375				</xsl:when>
1376				<!-- Simplified Chinese 2 ([DBNum2]),#1f,#0804 -->
1377				<xsl:when test="$number-shape-code = 31 or ($number-code-style = '2' and $language-country-code = 2052 )">
1378					<xsl:attribute name="number:transliteration-format">壹</xsl:attribute>
1379					<xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
1380					<xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
1381				</xsl:when>
1382				<!-- Simplified Chinese 3 ([DBNum3]), #20,#0804 -->
1383				<xsl:when test="$number-shape-code = 32 or ($number-code-style = '3' and $language-country-code = 2052 )">
1384					<xsl:attribute name="number:transliteration-format">1</xsl:attribute>
1385					<xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
1386					<xsl:attribute name="number:transliteration-country">CN</xsl:attribute>
1387				</xsl:when>
1388				<!-- Traditional Chinese 1 ([DBNum1]), #21, #0404 -->
1389				<xsl:when test="$number-shape-code = 33 or ($number-code-style = '1' and $language-country-code = 1028 )">
1390					<xsl:attribute name="number:transliteration-format">一</xsl:attribute>
1391					<xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
1392					<xsl:attribute name="number:transliteration-country">TW</xsl:attribute>
1393				</xsl:when>
1394				<!-- Traditional Chinese 2 ([DBNum2]), #22, #0404 -->
1395				<xsl:when test="$number-shape-code = 34 or ($number-code-style = '2' and $language-country-code = 1028 )">
1396					<xsl:attribute name="number:transliteration-format">壹</xsl:attribute>
1397					<xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
1398					<xsl:attribute name="number:transliteration-country">TW</xsl:attribute>
1399				</xsl:when>
1400				<!-- Traditional Chinese 3 ([DBNum3]),#23, #0404  -->
1401				<xsl:when test="$number-shape-code = 35 or ($number-code-style = '3' and $language-country-code = 1028 )">
1402					<xsl:attribute name="number:transliteration-format">1</xsl:attribute>
1403					<xsl:attribute name="number:transliteration-language">zh</xsl:attribute>
1404					<xsl:attribute name="number:transliteration-country">TW</xsl:attribute>
1405				</xsl:when>
1406				<!-- Korean 1 ([DBNum1]), #24, #0412 -->
1407				<xsl:when test="$number-shape-code = 36 or ($number-code-style = '1' and $language-country-code = 1042 )">
1408					<xsl:attribute name="number:transliteration-format">一</xsl:attribute>
1409					<xsl:attribute name="number:transliteration-language">ko</xsl:attribute>
1410					<xsl:attribute name="number:transliteration-country">KR</xsl:attribute>
1411				</xsl:when>
1412				<!-- Korean 2 ([DBNum2]), #25, #0412 -->
1413				<xsl:when test="$number-shape-code = 37 or ($number-code-style = '2' and $language-country-code = 1042 )">
1414					<xsl:attribute name="number:transliteration-format">壹</xsl:attribute>
1415					<xsl:attribute name="number:transliteration-language">ko</xsl:attribute>
1416					<xsl:attribute name="number:transliteration-country">KR</xsl:attribute>
1417				</xsl:when>
1418				<!-- Korean 3 ([DBNum3]), #26, #0412 -->
1419				<xsl:when test="$number-shape-code = 38 or ($number-code-style = '3' and $language-country-code = 1042 )">
1420					<xsl:attribute name="number:transliteration-format">1</xsl:attribute>
1421					<xsl:attribute name="number:transliteration-language">ko</xsl:attribute>
1422					<xsl:attribute name="number:transliteration-country">KR</xsl:attribute>
1423				</xsl:when>
1424				<!-- Korean 4 ([DBNum4]), #27, #0412 -->
1425				<xsl:when test="$number-shape-code = 39 or ($number-code-style = '4' and $language-country-code = 1042 )">
1426					<xsl:attribute name="number:transliteration-format">1</xsl:attribute>
1427					<xsl:attribute name="number:transliteration-language">ko</xsl:attribute>
1428					<xsl:attribute name="number:transliteration-country">KR</xsl:attribute>
1429				</xsl:when>
1430			</xsl:choose>
1431		</xsl:if>
1432		<!-- components of a format code: two digits  for number shape codes, two for calendar types, four for LCID -->
1433		<xsl:choose>
1434			<!-- totally 223 language-country LCID codes, manually created, among which MS Office 2003 supports 134, OOo supports 91 -->
1435			<xsl:when test="$language-country-code = 1078">
1436				<!-- Afrikaans - South Africa, #0436 -->
1437				<xsl:attribute name="number:language">af</xsl:attribute>
1438				<xsl:attribute name="number:country">ZA</xsl:attribute>
1439			</xsl:when>
1440			<xsl:when test="$language-country-code = 1052">
1441				<!-- Albanian - Albania, #041c -->
1442				<xsl:attribute name="number:language">sq</xsl:attribute>
1443				<xsl:attribute name="number:country">AL</xsl:attribute>
1444			</xsl:when>
1445			<xsl:when test="$language-country-code = 1118">
1446				<!-- Amharic - Ethiopia, #045e -->
1447				<xsl:attribute name="number:language">am</xsl:attribute>
1448				<xsl:attribute name="number:country">ET</xsl:attribute>
1449			</xsl:when>
1450			<xsl:when test="$language-country-code = 1025">
1451				<!-- Arabic - Saudi Arabia, #0401 -->
1452				<xsl:attribute name="number:language">ar</xsl:attribute>
1453				<xsl:attribute name="number:country">SA</xsl:attribute>
1454			</xsl:when>
1455			<xsl:when test="$language-country-code = 5121">
1456				<!-- Arabic - Algeria, #1401 -->
1457				<xsl:attribute name="number:language">ar</xsl:attribute>
1458				<xsl:attribute name="number:country">DZ</xsl:attribute>
1459			</xsl:when>
1460			<xsl:when test="$language-country-code = 15361">
1461				<!-- Arabic - Bahrain, #3c01 -->
1462				<xsl:attribute name="number:language">ar</xsl:attribute>
1463				<xsl:attribute name="number:country">BH</xsl:attribute>
1464			</xsl:when>
1465			<xsl:when test="$language-country-code = 3073">
1466				<!-- Arabic - Egypt, #0c01 -->
1467				<xsl:attribute name="number:language">ar</xsl:attribute>
1468				<xsl:attribute name="number:country">EG</xsl:attribute>
1469			</xsl:when>
1470			<xsl:when test="$language-country-code = 2049">
1471				<!-- Arabic - Iraq, #0801 -->
1472				<xsl:attribute name="number:language">ar</xsl:attribute>
1473				<xsl:attribute name="number:country">IQ</xsl:attribute>
1474			</xsl:when>
1475			<xsl:when test="$language-country-code = 11265">
1476				<!-- Arabic - Jordan, #2c01 -->
1477				<xsl:attribute name="number:language">ar</xsl:attribute>
1478				<xsl:attribute name="number:country">JO</xsl:attribute>
1479			</xsl:when>
1480			<xsl:when test="$language-country-code = 13313">
1481				<!-- Arabic - Kuwait, #3401 -->
1482				<xsl:attribute name="number:language">ar</xsl:attribute>
1483				<xsl:attribute name="number:country">KW</xsl:attribute>
1484			</xsl:when>
1485			<xsl:when test="$language-country-code = 12289">
1486				<!-- Arabic - Lebanon, #3001 -->
1487				<xsl:attribute name="number:language">ar</xsl:attribute>
1488				<xsl:attribute name="number:country">LB</xsl:attribute>
1489			</xsl:when>
1490			<xsl:when test="$language-country-code = 4097">
1491				<!-- Arabic - Libya, #1001 -->
1492				<xsl:attribute name="number:language">ar</xsl:attribute>
1493				<xsl:attribute name="number:country">LY</xsl:attribute>
1494			</xsl:when>
1495			<xsl:when test="$language-country-code = 6145">
1496				<!-- Arabic - Morocco, #1801 -->
1497				<xsl:attribute name="number:language">ar</xsl:attribute>
1498				<xsl:attribute name="number:country">MA</xsl:attribute>
1499			</xsl:when>
1500			<xsl:when test="$language-country-code = 8193">
1501				<!-- Arabic - Oman, #2001 -->
1502				<xsl:attribute name="number:language">ar</xsl:attribute>
1503				<xsl:attribute name="number:country">OM</xsl:attribute>
1504			</xsl:when>
1505			<xsl:when test="$language-country-code = 16385">
1506				<!-- Arabic - Qatar, #4001 -->
1507				<xsl:attribute name="number:language">ar</xsl:attribute>
1508				<xsl:attribute name="number:country">QA</xsl:attribute>
1509			</xsl:when>
1510			<xsl:when test="$language-country-code = 10241">
1511				<!-- Arabic - Syria, #2801 -->
1512				<xsl:attribute name="number:language">ar</xsl:attribute>
1513				<xsl:attribute name="number:country">SY</xsl:attribute>
1514			</xsl:when>
1515			<xsl:when test="$language-country-code = 7169">
1516				<!-- Arabic - Tunisia, #1c01 -->
1517				<xsl:attribute name="number:language">ar</xsl:attribute>
1518				<xsl:attribute name="number:country">TN</xsl:attribute>
1519			</xsl:when>
1520			<xsl:when test="$language-country-code = 14337">
1521				<!-- Arabic - U.A.E., #3801 -->
1522				<xsl:attribute name="number:language">ar</xsl:attribute>
1523				<xsl:attribute name="number:country">AE</xsl:attribute>
1524			</xsl:when>
1525			<xsl:when test="$language-country-code = 9217">
1526				<!-- Arabic - Yemen, #2401 -->
1527				<xsl:attribute name="number:language">ar</xsl:attribute>
1528				<xsl:attribute name="number:country">YE</xsl:attribute>
1529			</xsl:when>
1530			<xsl:when test="$language-country-code = 1067">
1531				<!-- Armenian - Armenia, #042b -->
1532				<xsl:attribute name="number:language">hy</xsl:attribute>
1533				<xsl:attribute name="number:country">AM</xsl:attribute>
1534			</xsl:when>
1535			<xsl:when test="$language-country-code = 1101">
1536				<!-- Assamese, #044d -->
1537				<xsl:attribute name="number:language">as</xsl:attribute>
1538				<xsl:attribute name="number:country">IN</xsl:attribute>
1539			</xsl:when>
1540			<xsl:when test="$language-country-code = 2092">
1541				<!-- Azeri - Cyrillic, #082c -->
1542				<xsl:attribute name="number:language">az</xsl:attribute>
1543				<xsl:attribute name="number:country">AZ</xsl:attribute>
1544			</xsl:when>
1545			<xsl:when test="$language-country-code = 1068">
1546				<!-- Azeri - Latin, #042c -->
1547				<xsl:attribute name="number:language">az</xsl:attribute>
1548				<xsl:attribute name="number:country">AZ</xsl:attribute>
1549			</xsl:when>
1550			<xsl:when test="$language-country-code = 1069">
1551				<!-- Basque - France/Spain, #042d -->
1552				<xsl:attribute name="number:language">eu</xsl:attribute>
1553				<xsl:attribute name="number:country">ES</xsl:attribute>
1554			</xsl:when>
1555			<xsl:when test="$language-country-code = 1059">
1556				<!-- Belarusian - Belarus, #0423 -->
1557				<xsl:attribute name="number:language">be</xsl:attribute>
1558				<xsl:attribute name="number:country">BY</xsl:attribute>
1559			</xsl:when>
1560			<xsl:when test="$language-country-code = 1093">
1561				<!-- Bengali (India), #0445 -->
1562				<xsl:attribute name="number:language">bn</xsl:attribute>
1563				<xsl:attribute name="number:country">IN</xsl:attribute>
1564			</xsl:when>
1565			<xsl:when test="$language-country-code = 2117">
1566				<!-- Bengali (Bangladesh), #0845 -->
1567				<xsl:attribute name="number:language">bn</xsl:attribute>
1568				<xsl:attribute name="number:country">BD</xsl:attribute>
1569			</xsl:when>
1570			<xsl:when test="$language-country-code = 5146">
1571				<!-- Bosnian (Bosnia/Herzegovina), #141a -->
1572				<xsl:attribute name="number:language">bs</xsl:attribute>
1573				<xsl:attribute name="number:country">BA</xsl:attribute>
1574			</xsl:when>
1575			<xsl:when test="$language-country-code = 1026">
1576				<!-- Bulgarian, #0402 -->
1577				<xsl:attribute name="number:language">bg</xsl:attribute>
1578				<xsl:attribute name="number:country">BG</xsl:attribute>
1579			</xsl:when>
1580			<xsl:when test="$language-country-code = 1109">
1581				<!-- Burmese (Burma/Myanmar), #0455 -->
1582				<xsl:attribute name="number:language">my</xsl:attribute>
1583				<xsl:attribute name="number:country">MM</xsl:attribute>
1584			</xsl:when>
1585			<xsl:when test="$language-country-code = 1027">
1586				<!-- Catalan - Spain, #0403 -->
1587				<xsl:attribute name="number:language">ca</xsl:attribute>
1588				<xsl:attribute name="number:country">ES</xsl:attribute>
1589			</xsl:when>
1590			<xsl:when test="$language-country-code = 1116">
1591				<!-- Cherokee - United States, #045c -->
1592				<xsl:attribute name="number:language">chr</xsl:attribute>
1593				<xsl:attribute name="number:country">US</xsl:attribute>
1594			</xsl:when>
1595			<xsl:when test="$language-country-code = 2052">
1596				<!-- Chinese - People's Republic of China, #0804 -->
1597				<xsl:attribute name="number:language">zh</xsl:attribute>
1598				<xsl:attribute name="number:country">CN</xsl:attribute>
1599			</xsl:when>
1600			<xsl:when test="$language-country-code = 4100">
1601				<!-- Chinese - Singapore, #1004 -->
1602				<xsl:attribute name="number:language">zh</xsl:attribute>
1603				<xsl:attribute name="number:country">SG</xsl:attribute>
1604			</xsl:when>
1605			<xsl:when test="$language-country-code = 1028">
1606				<!-- Chinese - Taiwan, #0404 -->
1607				<xsl:attribute name="number:language">zh</xsl:attribute>
1608				<xsl:attribute name="number:country">TW</xsl:attribute>
1609			</xsl:when>
1610			<xsl:when test="$language-country-code = 3076">
1611				<!-- Chinese - Hong Kong SAR, #0c04 -->
1612				<xsl:attribute name="number:language">zh</xsl:attribute>
1613				<xsl:attribute name="number:country">HK</xsl:attribute>
1614			</xsl:when>
1615			<xsl:when test="$language-country-code = 5124">
1616				<!-- Chinese - Macao SAR, #1404 -->
1617				<xsl:attribute name="number:language">zh</xsl:attribute>
1618				<xsl:attribute name="number:country">MO</xsl:attribute>
1619			</xsl:when>
1620			<xsl:when test="$language-country-code = 1050">
1621				<!-- Croatian (Croatia), #041a -->
1622				<xsl:attribute name="number:language">hr</xsl:attribute>
1623				<xsl:attribute name="number:country">HR</xsl:attribute>
1624			</xsl:when>
1625			<xsl:when test="$language-country-code = 4122">
1626				<!-- Croatian (Bosnia/Herzegovina), #101a -->
1627				<xsl:attribute name="number:language">hr</xsl:attribute>
1628				<xsl:attribute name="number:country">BA</xsl:attribute>
1629			</xsl:when>
1630			<xsl:when test="$language-country-code = 1029">
1631				<!-- Czech, #0405 -->
1632				<xsl:attribute name="number:language">cs</xsl:attribute>
1633				<xsl:attribute name="number:country">CZ</xsl:attribute>
1634			</xsl:when>
1635			<xsl:when test="$language-country-code = 1030">
1636				<!-- Danish, #0406 -->
1637				<xsl:attribute name="number:language">da</xsl:attribute>
1638				<xsl:attribute name="number:country">DK</xsl:attribute>
1639			</xsl:when>
1640			<xsl:when test="$language-country-code = 1125">
1641				<!-- Divehi, #0465 -->
1642				<xsl:attribute name="number:language">dv</xsl:attribute>
1643				<xsl:attribute name="number:country">MV</xsl:attribute>
1644			</xsl:when>
1645			<xsl:when test="$language-country-code = 1043">
1646				<!-- Dutch - Netherlands, #0413 -->
1647				<xsl:attribute name="number:language">nl</xsl:attribute>
1648				<xsl:attribute name="number:country">NL</xsl:attribute>
1649			</xsl:when>
1650			<xsl:when test="$language-country-code = 2067">
1651				<!-- Dutch - Belgium, #0813 -->
1652				<xsl:attribute name="number:language">nl</xsl:attribute>
1653				<xsl:attribute name="number:country">BE</xsl:attribute>
1654			</xsl:when>
1655			<xsl:when test="$language-country-code = 1126">
1656				<!-- Edo (Bini - Nigeria), #0466 -->
1657				<xsl:attribute name="number:language">bin</xsl:attribute>
1658				<xsl:attribute name="number:country">NG</xsl:attribute>
1659			</xsl:when>
1660			<xsl:when test="$language-country-code = 1033">
1661				<!-- English - United States, #0409 -->
1662				<xsl:attribute name="number:language">en</xsl:attribute>
1663				<xsl:attribute name="number:country">US</xsl:attribute>
1664			</xsl:when>
1665			<xsl:when test="$language-country-code = 2057">
1666				<!-- English - United Kingdom, #0809 -->
1667				<xsl:attribute name="number:language">en</xsl:attribute>
1668				<xsl:attribute name="number:country">GB</xsl:attribute>
1669			</xsl:when>
1670			<xsl:when test="$language-country-code = 3081">
1671				<!-- English - Australia, #0c09 -->
1672				<xsl:attribute name="number:language">en</xsl:attribute>
1673				<xsl:attribute name="number:country">AU</xsl:attribute>
1674			</xsl:when>
1675			<xsl:when test="$language-country-code = 10249">
1676				<!-- English - Belize, #2809 -->
1677				<xsl:attribute name="number:language">en</xsl:attribute>
1678				<xsl:attribute name="number:country">BZ</xsl:attribute>
1679			</xsl:when>
1680			<xsl:when test="$language-country-code = 4105">
1681				<!-- English - Canada, #1009 -->
1682				<xsl:attribute name="number:language">en</xsl:attribute>
1683				<xsl:attribute name="number:country">CA</xsl:attribute>
1684			</xsl:when>
1685			<xsl:when test="$language-country-code = 9225">
1686				<!-- English - Caribbean (Cuba), #2409 -->
1687				<xsl:attribute name="number:language">en</xsl:attribute>
1688				<xsl:attribute name="number:country">CU</xsl:attribute>
1689			</xsl:when>
1690			<xsl:when test="$language-country-code = 15369">
1691				<!-- English - Hong Kong SAR, #3c09 -->
1692				<xsl:attribute name="number:language">en</xsl:attribute>
1693				<xsl:attribute name="number:country">HK</xsl:attribute>
1694			</xsl:when>
1695			<xsl:when test="$language-country-code = 16393">
1696				<!-- English - India, #4009 -->
1697				<xsl:attribute name="number:language">en</xsl:attribute>
1698				<xsl:attribute name="number:country">IN</xsl:attribute>
1699			</xsl:when>
1700			<xsl:when test="$language-country-code = 14345">
1701				<!-- English - Indonesia, #3809 -->
1702				<xsl:attribute name="number:language">en</xsl:attribute>
1703				<xsl:attribute name="number:country">ID</xsl:attribute>
1704			</xsl:when>
1705			<xsl:when test="$language-country-code = 6153">
1706				<!-- English - Ireland, #1809 -->
1707				<xsl:attribute name="number:language">en</xsl:attribute>
1708				<xsl:attribute name="number:country">IE</xsl:attribute>
1709			</xsl:when>
1710			<xsl:when test="$language-country-code = 8201">
1711				<!-- English - Jamaica, #2009 -->
1712				<xsl:attribute name="number:language">en</xsl:attribute>
1713				<xsl:attribute name="number:country">JM</xsl:attribute>
1714			</xsl:when>
1715			<xsl:when test="$language-country-code = 17417">
1716				<!-- English - Malaysia, #4409 -->
1717				<xsl:attribute name="number:language">en</xsl:attribute>
1718				<xsl:attribute name="number:country">MY</xsl:attribute>
1719			</xsl:when>
1720			<xsl:when test="$language-country-code = 5129">
1721				<!-- English - New Zealand, #1409 -->
1722				<xsl:attribute name="number:language">en</xsl:attribute>
1723				<xsl:attribute name="number:country">NZ</xsl:attribute>
1724			</xsl:when>
1725			<xsl:when test="$language-country-code = 13321">
1726				<!-- English - Philippines, #3409 -->
1727				<xsl:attribute name="number:language">en</xsl:attribute>
1728				<xsl:attribute name="number:country">PH</xsl:attribute>
1729			</xsl:when>
1730			<xsl:when test="$language-country-code = 18441">
1731				<!-- English - Singapore, #4809 -->
1732				<xsl:attribute name="number:language">en</xsl:attribute>
1733				<xsl:attribute name="number:country">SG</xsl:attribute>
1734			</xsl:when>
1735			<xsl:when test="$language-country-code = 7177">
1736				<!-- English - South Africa, #1c09 -->
1737				<xsl:attribute name="number:language">en</xsl:attribute>
1738				<xsl:attribute name="number:country">ZA</xsl:attribute>
1739			</xsl:when>
1740			<xsl:when test="$language-country-code = 11273">
1741				<!-- English - Trinidad, #2c09 -->
1742				<xsl:attribute name="number:language">en</xsl:attribute>
1743				<xsl:attribute name="number:country">TT</xsl:attribute>
1744			</xsl:when>
1745			<xsl:when test="$language-country-code = 12297">
1746				<!-- English - Zimbabwe, #3009 -->
1747				<xsl:attribute name="number:language">en</xsl:attribute>
1748				<xsl:attribute name="number:country">ZW</xsl:attribute>
1749			</xsl:when>
1750			<xsl:when test="$language-country-code = 1061">
1751				<!-- Estonian (Estonia), #0425 -->
1752				<xsl:attribute name="number:language">et</xsl:attribute>
1753				<xsl:attribute name="number:country">EE</xsl:attribute>
1754			</xsl:when>
1755			<xsl:when test="$language-country-code = 1080">
1756				<!-- Faroese (Faroe Islands), #0438 -->
1757				<xsl:attribute name="number:language">fo</xsl:attribute>
1758				<xsl:attribute name="number:country">FO</xsl:attribute>
1759			</xsl:when>
1760			<xsl:when test="$language-country-code = 1065">
1761				<!-- Farsi (Persian/Iran), #0429 -->
1762				<xsl:attribute name="number:language">fa</xsl:attribute>
1763				<xsl:attribute name="number:country">IR</xsl:attribute>
1764			</xsl:when>
1765			<xsl:when test="$language-country-code = 1124">
1766				<!-- Filipino (Philippine), #0464 -->
1767				<xsl:attribute name="number:language">phi</xsl:attribute>
1768				<xsl:attribute name="number:country">PH</xsl:attribute>
1769			</xsl:when>
1770			<xsl:when test="$language-country-code = 1035">
1771				<!-- Finnish, #040b -->
1772				<xsl:attribute name="number:language">fi</xsl:attribute>
1773				<xsl:attribute name="number:country">FI</xsl:attribute>
1774			</xsl:when>
1775			<xsl:when test="$language-country-code = 1036">
1776				<!-- French - France, #040c -->
1777				<xsl:attribute name="number:language">fr</xsl:attribute>
1778				<xsl:attribute name="number:country">FR</xsl:attribute>
1779			</xsl:when>
1780			<xsl:when test="$language-country-code = 2060">
1781				<!-- French - Belgium, #080c -->
1782				<xsl:attribute name="number:language">fr</xsl:attribute>
1783				<xsl:attribute name="number:country">BE</xsl:attribute>
1784			</xsl:when>
1785			<xsl:when test="$language-country-code = 11276">
1786				<!-- French - Cameroon, #2c0c -->
1787				<xsl:attribute name="number:language">fr</xsl:attribute>
1788				<xsl:attribute name="number:country">CM</xsl:attribute>
1789			</xsl:when>
1790			<xsl:when test="$language-country-code = 3084">
1791				<!-- French - Canada, #0c0c -->
1792				<xsl:attribute name="number:language">fr</xsl:attribute>
1793				<xsl:attribute name="number:country">CA</xsl:attribute>
1794			</xsl:when>
1795			<xsl:when test="$language-country-code = 9228">
1796				<!-- French - Congo, #240c -->
1797				<xsl:attribute name="number:language">fr</xsl:attribute>
1798				<xsl:attribute name="number:country">CG</xsl:attribute>
1799			</xsl:when>
1800			<xsl:when test="$language-country-code = 12300">
1801				<!-- French - Cote d'Ivoire, #300c -->
1802				<xsl:attribute name="number:language">fr</xsl:attribute>
1803				<xsl:attribute name="number:country">CI</xsl:attribute>
1804			</xsl:when>
1805			<xsl:when test="$language-country-code = 15372">
1806				<!-- French - Haiti, #3c0c -->
1807				<xsl:attribute name="number:language">fr</xsl:attribute>
1808				<xsl:attribute name="number:country">HT</xsl:attribute>
1809			</xsl:when>
1810			<xsl:when test="$language-country-code = 5132">
1811				<!-- French - Luxembourg, #140c -->
1812				<xsl:attribute name="number:language">fr</xsl:attribute>
1813				<xsl:attribute name="number:country">LU</xsl:attribute>
1814			</xsl:when>
1815			<xsl:when test="$language-country-code = 13324">
1816				<!-- French - Mali, #340c -->
1817				<xsl:attribute name="number:language">fr</xsl:attribute>
1818				<xsl:attribute name="number:country">ML</xsl:attribute>
1819			</xsl:when>
1820			<xsl:when test="$language-country-code = 6156">
1821				<!-- French - Monaco, #180c -->
1822				<xsl:attribute name="number:language">fr</xsl:attribute>
1823				<xsl:attribute name="number:country">MC</xsl:attribute>
1824			</xsl:when>
1825			<xsl:when test="$language-country-code = 14348">
1826				<!-- French - Morocco, #380c -->
1827				<xsl:attribute name="number:language">fr</xsl:attribute>
1828				<xsl:attribute name="number:country">MA</xsl:attribute>
1829			</xsl:when>
1830			<xsl:when test="$language-country-code = 58380">
1831				<!-- French - North Africa (Algeria), #e40c -->
1832				<xsl:attribute name="number:language">fr</xsl:attribute>
1833				<xsl:attribute name="number:country">DZ</xsl:attribute>
1834			</xsl:when>
1835			<xsl:when test="$language-country-code = 8204">
1836				<!-- French - Reunion, #200c -->
1837				<xsl:attribute name="number:language">fr</xsl:attribute>
1838				<xsl:attribute name="number:country">RE</xsl:attribute>
1839			</xsl:when>
1840			<xsl:when test="$language-country-code = 10252">
1841				<!-- French - Senegal, #280c -->
1842				<xsl:attribute name="number:language">fr</xsl:attribute>
1843				<xsl:attribute name="number:country">SN</xsl:attribute>
1844			</xsl:when>
1845			<xsl:when test="$language-country-code = 4108">
1846				<!-- French - Switzerland, #100c -->
1847				<xsl:attribute name="number:language">fr</xsl:attribute>
1848				<xsl:attribute name="number:country">CH</xsl:attribute>
1849			</xsl:when>
1850			<xsl:when test="$language-country-code = 1122">
1851				<!-- Frisian - Netherlands, #0462 -->
1852				<xsl:attribute name="number:language">fy</xsl:attribute>
1853				<xsl:attribute name="number:country">NL</xsl:attribute>
1854			</xsl:when>
1855			<xsl:when test="$language-country-code = 1127">
1856				<!-- Fulfude (Fulah) - Nigeria, #0467 -->
1857				<xsl:attribute name="number:language">ff</xsl:attribute>
1858				<xsl:attribute name="number:country">NG</xsl:attribute>
1859			</xsl:when>
1860			<xsl:when test="$language-country-code = 1071">
1861				<!-- FYRO Macedonian, #042f -->
1862				<xsl:attribute name="number:language">mk</xsl:attribute>
1863				<xsl:attribute name="number:country">MK</xsl:attribute>
1864			</xsl:when>
1865			<xsl:when test="$language-country-code = 2108">
1866				<!-- Gaelic (Ireland), #083c -->
1867				<xsl:attribute name="number:language">gd</xsl:attribute>
1868				<xsl:attribute name="number:country">IE</xsl:attribute>
1869			</xsl:when>
1870			<xsl:when test="$language-country-code = 1084">
1871				<!-- Gaelic (Scotland), #043c -->
1872				<xsl:attribute name="number:language">gd</xsl:attribute>
1873				<xsl:attribute name="number:country">GB</xsl:attribute>
1874			</xsl:when>
1875			<xsl:when test="$language-country-code = 1110">
1876				<!-- Galician (Gallegan) - Spain, #0456 -->
1877				<xsl:attribute name="number:language">gl</xsl:attribute>
1878				<xsl:attribute name="number:country">ES</xsl:attribute>
1879			</xsl:when>
1880			<xsl:when test="$language-country-code = 1079">
1881				<!-- Georgian - Georgia, #0437 -->
1882				<xsl:attribute name="number:language">ka</xsl:attribute>
1883				<xsl:attribute name="number:country">GE</xsl:attribute>
1884			</xsl:when>
1885			<xsl:when test="$language-country-code = 1031">
1886				<!-- German - Germany, #0407 -->
1887				<xsl:attribute name="number:language">de</xsl:attribute>
1888				<xsl:attribute name="number:country">DE</xsl:attribute>
1889			</xsl:when>
1890			<xsl:when test="$language-country-code = 3079">
1891				<!-- German - Austria, #0c07 -->
1892				<xsl:attribute name="number:language">de</xsl:attribute>
1893				<xsl:attribute name="number:country">AT</xsl:attribute>
1894			</xsl:when>
1895			<xsl:when test="$language-country-code = 5127">
1896				<!-- German - Liechtenstein, #1407 -->
1897				<xsl:attribute name="number:language">de</xsl:attribute>
1898				<xsl:attribute name="number:country">LI</xsl:attribute>
1899			</xsl:when>
1900			<xsl:when test="$language-country-code = 4103">
1901				<!-- German - Luxembourg, #1007 -->
1902				<xsl:attribute name="number:language">de</xsl:attribute>
1903				<xsl:attribute name="number:country">LU</xsl:attribute>
1904			</xsl:when>
1905			<xsl:when test="$language-country-code = 2055">
1906				<!-- German - Switzerland, #0807 -->
1907				<xsl:attribute name="number:language">de</xsl:attribute>
1908				<xsl:attribute name="number:country">CH</xsl:attribute>
1909			</xsl:when>
1910			<xsl:when test="$language-country-code = 1032">
1911				<!-- Greek, #0408 -->
1912				<xsl:attribute name="number:language">el</xsl:attribute>
1913				<xsl:attribute name="number:country">GR</xsl:attribute>
1914			</xsl:when>
1915			<xsl:when test="$language-country-code = 1140">
1916				<!-- Guarani - Paraguay, #0474 -->
1917				<xsl:attribute name="number:language">gn</xsl:attribute>
1918				<xsl:attribute name="number:country">PY</xsl:attribute>
1919			</xsl:when>
1920			<xsl:when test="$language-country-code = 1095">
1921				<!-- Gujarati - India, #0447 -->
1922				<xsl:attribute name="number:language">gu</xsl:attribute>
1923				<xsl:attribute name="number:country">IN</xsl:attribute>
1924			</xsl:when>
1925			<xsl:when test="$language-country-code = 1128">
1926				<!-- Hausa - Nigeria, #0468 -->
1927				<xsl:attribute name="number:language">ha</xsl:attribute>
1928				<xsl:attribute name="number:country">NG</xsl:attribute>
1929			</xsl:when>
1930			<xsl:when test="$language-country-code = 1141">
1931				<!-- Hawaiian - US, #0475 -->
1932				<xsl:attribute name="number:language">haw</xsl:attribute>
1933				<xsl:attribute name="number:country">US</xsl:attribute>
1934			</xsl:when>
1935			<xsl:when test="$language-country-code = 1037">
1936				<!-- Hebrew, #040d -->
1937				<xsl:attribute name="number:language">he</xsl:attribute>
1938				<xsl:attribute name="number:country">IL</xsl:attribute>
1939			</xsl:when>
1940			<xsl:when test="$language-country-code = 1081">
1941				<!-- Hindi (India), #0439 -->
1942				<xsl:attribute name="number:language">hi</xsl:attribute>
1943				<xsl:attribute name="number:country">IN</xsl:attribute>
1944			</xsl:when>
1945			<xsl:when test="$language-country-code = 1038">
1946				<!-- Hungarian - Hungary, #040e -->
1947				<xsl:attribute name="number:language">hu</xsl:attribute>
1948				<xsl:attribute name="number:country">HU</xsl:attribute>
1949			</xsl:when>
1950			<xsl:when test="$language-country-code = 1129">
1951				<!-- Ibibio (Niger-Kordofanian) - Nigeria, #0469 -->
1952				<xsl:attribute name="number:language">nic</xsl:attribute>
1953				<xsl:attribute name="number:country">NG</xsl:attribute>
1954			</xsl:when>
1955			<xsl:when test="$language-country-code = 1039">
1956				<!-- Icelandic, #040f -->
1957				<xsl:attribute name="number:language">is</xsl:attribute>
1958				<xsl:attribute name="number:country">IS</xsl:attribute>
1959			</xsl:when>
1960			<xsl:when test="$language-country-code = 1136">
1961				<!-- Igbo - Nigeria, #0470 -->
1962				<xsl:attribute name="number:language">ig</xsl:attribute>
1963				<xsl:attribute name="number:country">NG</xsl:attribute>
1964			</xsl:when>
1965			<xsl:when test="$language-country-code = 1057">
1966				<!-- Indonesian, #0421 -->
1967				<xsl:attribute name="number:language">id</xsl:attribute>
1968				<xsl:attribute name="number:country">ID</xsl:attribute>
1969			</xsl:when>
1970			<xsl:when test="$language-country-code = 1117">
1971				<!-- Inuktitut - US, #045d -->
1972				<xsl:attribute name="number:language">iu</xsl:attribute>
1973				<xsl:attribute name="number:country">US</xsl:attribute>
1974			</xsl:when>
1975			<xsl:when test="$language-country-code = 1040">
1976				<!-- Italian - Italy, #0410 -->
1977				<xsl:attribute name="number:language">it</xsl:attribute>
1978				<xsl:attribute name="number:country">IT</xsl:attribute>
1979			</xsl:when>
1980			<xsl:when test="$language-country-code = 2064">
1981				<!-- Italian - Switzerland, #0810 -->
1982				<xsl:attribute name="number:language">it</xsl:attribute>
1983				<xsl:attribute name="number:country">CH</xsl:attribute>
1984			</xsl:when>
1985			<xsl:when test="$language-country-code = 1041">
1986				<!-- Japanese, #0411 -->
1987				<xsl:attribute name="number:language">ja</xsl:attribute>
1988				<xsl:attribute name="number:country">JP</xsl:attribute>
1989			</xsl:when>
1990			<xsl:when test="$language-country-code = 1099">
1991				<!-- Kannada (India), #044b -->
1992				<xsl:attribute name="number:language">kn</xsl:attribute>
1993				<xsl:attribute name="number:country">IN</xsl:attribute>
1994			</xsl:when>
1995			<xsl:when test="$language-country-code = 1137">
1996				<!-- Kanuri - Nigeria, #0471 -->
1997				<xsl:attribute name="number:language">kr</xsl:attribute>
1998				<xsl:attribute name="number:country">NG</xsl:attribute>
1999			</xsl:when>
2000			<xsl:when test="$language-country-code = 2144">
2001				<!-- Kashmiri (India), #0860 -->
2002				<xsl:attribute name="number:language">ks</xsl:attribute>
2003				<xsl:attribute name="number:country">IN</xsl:attribute>
2004			</xsl:when>
2005			<xsl:when test="$language-country-code = 1120">
2006				<!-- Kashmiri (Arabic), #0460 -->
2007				<xsl:attribute name="number:language">ks</xsl:attribute>
2008				<xsl:attribute name="number:country">PK</xsl:attribute>
2009			</xsl:when>
2010			<xsl:when test="$language-country-code = 1087">
2011				<!-- Kazakh, #043f -->
2012				<xsl:attribute name="number:language">kk</xsl:attribute>
2013				<xsl:attribute name="number:country">KZ</xsl:attribute>
2014			</xsl:when>
2015			<xsl:when test="$language-country-code = 1107">
2016				<!-- Khmer (Cambodian), #0453 -->
2017				<xsl:attribute name="number:language">km</xsl:attribute>
2018				<xsl:attribute name="number:country">KH</xsl:attribute>
2019			</xsl:when>
2020			<xsl:when test="$language-country-code = 1111">
2021				<!-- Konkani (India), #0457 -->
2022				<xsl:attribute name="number:language">kok</xsl:attribute>
2023				<xsl:attribute name="number:country">IN</xsl:attribute>
2024			</xsl:when>
2025			<xsl:when test="$language-country-code = 1042">
2026				<!-- Korean, #0412 -->
2027				<xsl:attribute name="number:language">ko</xsl:attribute>
2028				<xsl:attribute name="number:country">KR</xsl:attribute>
2029			</xsl:when>
2030			<xsl:when test="$language-country-code = 1088">
2031				<!-- Kyrgyz ( Kirgiz / Cyrillic), #0440 -->
2032				<xsl:attribute name="number:language">ky</xsl:attribute>
2033				<xsl:attribute name="number:country">KG</xsl:attribute>
2034			</xsl:when>
2035			<xsl:when test="$language-country-code = 1108">
2036				<!-- Lao, #0454 -->
2037				<xsl:attribute name="number:language">lo</xsl:attribute>
2038				<xsl:attribute name="number:country">LA</xsl:attribute>
2039			</xsl:when>
2040			<xsl:when test="$language-country-code = 1142">
2041				<!-- Latin, #0476 -->
2042				<xsl:attribute name="number:language">la</xsl:attribute>
2043				<xsl:attribute name="number:country">IT</xsl:attribute>
2044			</xsl:when>
2045			<xsl:when test="$language-country-code = 1062">
2046				<!-- Latvian, #0426 -->
2047				<xsl:attribute name="number:language">lv</xsl:attribute>
2048				<xsl:attribute name="number:country">LV</xsl:attribute>
2049			</xsl:when>
2050			<xsl:when test="$language-country-code = 1063">
2051				<!-- Lithuanian, #0427 -->
2052				<xsl:attribute name="number:language">lt</xsl:attribute>
2053				<xsl:attribute name="number:country">LT</xsl:attribute>
2054			</xsl:when>
2055			<xsl:when test="$language-country-code = 1086">
2056				<!-- Malay - Malaysia, #043e -->
2057				<xsl:attribute name="number:language">ms</xsl:attribute>
2058				<xsl:attribute name="number:country">MY</xsl:attribute>
2059			</xsl:when>
2060			<xsl:when test="$language-country-code = 2110">
2061				<!-- Malay - Brunei Darussalam, #083e -->
2062				<xsl:attribute name="number:language">ms</xsl:attribute>
2063				<xsl:attribute name="number:country">BN</xsl:attribute>
2064			</xsl:when>
2065			<xsl:when test="$language-country-code = 1071">
2066				<!-- Macedonian (FYROM), #042f -->
2067				<xsl:attribute name="number:language">mk</xsl:attribute>
2068				<xsl:attribute name="number:country">MK</xsl:attribute>
2069			</xsl:when>
2070			<xsl:when test="$language-country-code = 1100">
2071				<!-- Malayalam (India), #044c -->
2072				<xsl:attribute name="number:language">ml</xsl:attribute>
2073				<xsl:attribute name="number:country">IN</xsl:attribute>
2074			</xsl:when>
2075			<xsl:when test="$language-country-code = 1082">
2076				<!-- Maltese, #043a -->
2077				<xsl:attribute name="number:language">mt</xsl:attribute>
2078				<xsl:attribute name="number:country">MT</xsl:attribute>
2079			</xsl:when>
2080			<xsl:when test="$language-country-code = 1112">
2081				<!-- Manipuri (India), #0458 -->
2082				<xsl:attribute name="number:language">mni</xsl:attribute>
2083				<xsl:attribute name="number:country">IN</xsl:attribute>
2084			</xsl:when>
2085			<xsl:when test="$language-country-code = 1153">
2086				<!-- Maori - New Zealand, #0481 -->
2087				<xsl:attribute name="number:language">mi</xsl:attribute>
2088				<xsl:attribute name="number:country">NZ</xsl:attribute>
2089			</xsl:when>
2090			<xsl:when test="$language-country-code = 1102">
2091				<!-- Marathi (India), #044e -->
2092				<xsl:attribute name="number:language">mr</xsl:attribute>
2093				<xsl:attribute name="number:country">IN</xsl:attribute>
2094			</xsl:when>
2095			<xsl:when test="$language-country-code = 1104">
2096				<!-- Mongolian (Cyrillic), #0450 -->
2097				<xsl:attribute name="number:language">mn</xsl:attribute>
2098				<xsl:attribute name="number:country">MN</xsl:attribute>
2099			</xsl:when>
2100			<xsl:when test="$language-country-code = 2128">
2101				<!-- Mongolian (Mongolian), #0850 -->
2102				<xsl:attribute name="number:language">mn</xsl:attribute>
2103				<xsl:attribute name="number:country">CN</xsl:attribute>
2104			</xsl:when>
2105			<xsl:when test="$language-country-code = 1121">
2106				<!-- Nepali, #0461 -->
2107				<xsl:attribute name="number:language">ne</xsl:attribute>
2108				<xsl:attribute name="number:country">NP</xsl:attribute>
2109			</xsl:when>
2110			<xsl:when test="$language-country-code = 2145">
2111				<!-- Nepali (India), #0861 -->
2112				<xsl:attribute name="number:language">ne</xsl:attribute>
2113				<xsl:attribute name="number:country">IN</xsl:attribute>
2114			</xsl:when>
2115			<xsl:when test="$language-country-code = 1044">
2116				<!-- Norwegian (Bokmal), #0414 -->
2117				<xsl:attribute name="number:language">nb</xsl:attribute>
2118				<xsl:attribute name="number:country">NO</xsl:attribute>
2119			</xsl:when>
2120			<xsl:when test="$language-country-code = 2068">
2121				<!-- Norwegian (Nynorsk), #0814 -->
2122				<xsl:attribute name="number:language">nn</xsl:attribute>
2123				<xsl:attribute name="number:country">NO</xsl:attribute>
2124			</xsl:when>
2125			<xsl:when test="$language-country-code = 1096">
2126				<!-- Oriya (India), #0448 -->
2127				<xsl:attribute name="number:language">or</xsl:attribute>
2128				<xsl:attribute name="number:country">IN</xsl:attribute>
2129			</xsl:when>
2130			<xsl:when test="$language-country-code = 1138">
2131				<!-- Oromo (Ethiopia), #0472 -->
2132				<xsl:attribute name="number:language">om</xsl:attribute>
2133				<xsl:attribute name="number:country">ET</xsl:attribute>
2134			</xsl:when>
2135			<xsl:when test="$language-country-code = 1145">
2136				<!-- Papiamentu (Netherlands Antilles), #0479 -->
2137				<xsl:attribute name="number:language">pap</xsl:attribute>
2138				<xsl:attribute name="number:country">AN</xsl:attribute>
2139			</xsl:when>
2140			<xsl:when test="$language-country-code = 1123">
2141				<!-- Pashto (Afghanistan), #0463 -->
2142				<xsl:attribute name="number:language">ps</xsl:attribute>
2143				<xsl:attribute name="number:country">AF</xsl:attribute>
2144			</xsl:when>
2145			<xsl:when test="$language-country-code = 1045">
2146				<!-- Polish, #0415 -->
2147				<xsl:attribute name="number:language">pl</xsl:attribute>
2148				<xsl:attribute name="number:country">PL</xsl:attribute>
2149			</xsl:when>
2150			<xsl:when test="$language-country-code = 1046">
2151				<!-- Portuguese - Brazil, #0416 -->
2152				<xsl:attribute name="number:language">pt</xsl:attribute>
2153				<xsl:attribute name="number:country">BR</xsl:attribute>
2154			</xsl:when>
2155			<xsl:when test="$language-country-code = 2070">
2156				<!-- Portuguese - Portugal, #0816 -->
2157				<xsl:attribute name="number:language">pt</xsl:attribute>
2158				<xsl:attribute name="number:country">PT</xsl:attribute>
2159			</xsl:when>
2160			<xsl:when test="$language-country-code = 1094">
2161				<!-- Punjabi, #0446 -->
2162				<xsl:attribute name="number:language">pa</xsl:attribute>
2163				<xsl:attribute name="number:country">IN</xsl:attribute>
2164			</xsl:when>
2165			<xsl:when test="$language-country-code = 2118">
2166				<!-- Punjabi (Pakistan), #0846 -->
2167				<xsl:attribute name="number:language">pa</xsl:attribute>
2168				<xsl:attribute name="number:country">PK</xsl:attribute>
2169			</xsl:when>
2170			<xsl:when test="$language-country-code = 1131">
2171				<!-- Quecha - Blivia, #046b -->
2172				<xsl:attribute name="number:language">qu</xsl:attribute>
2173				<xsl:attribute name="number:country">BO</xsl:attribute>
2174			</xsl:when>
2175			<xsl:when test="$language-country-code = 2155">
2176				<!-- Quecha - Ecuador, #086b -->
2177				<xsl:attribute name="number:language">qu</xsl:attribute>
2178				<xsl:attribute name="number:country">EC</xsl:attribute>
2179			</xsl:when>
2180			<xsl:when test="$language-country-code = 3179">
2181				<!-- Quecha - peru, #0c6b -->
2182				<xsl:attribute name="number:language">qu</xsl:attribute>
2183				<xsl:attribute name="number:country">PE</xsl:attribute>
2184			</xsl:when>
2185			<xsl:when test="$language-country-code = 1047">
2186				<!-- Rhaeto-Romanic (Italy), #0417 -->
2187				<xsl:attribute name="number:language">rm</xsl:attribute>
2188				<xsl:attribute name="number:country">IT</xsl:attribute>
2189			</xsl:when>
2190			<xsl:when test="$language-country-code = 1048">
2191				<!-- Romanian, #0418 -->
2192				<xsl:attribute name="number:language">ro</xsl:attribute>
2193				<xsl:attribute name="number:country">RO</xsl:attribute>
2194			</xsl:when>
2195			<xsl:when test="$language-country-code = 2072">
2196				<!-- Romanian - Moldova, #0818 -->
2197				<xsl:attribute name="number:language">ro</xsl:attribute>
2198				<xsl:attribute name="number:country">MD</xsl:attribute>
2199			</xsl:when>
2200			<xsl:when test="$language-country-code = 1049">
2201				<!-- Russian, #0419 -->
2202				<xsl:attribute name="number:language">ru</xsl:attribute>
2203				<xsl:attribute name="number:country">RU</xsl:attribute>
2204			</xsl:when>
2205			<xsl:when test="$language-country-code = 2073">
2206				<!-- Russian - Moldova, #0819 -->
2207				<xsl:attribute name="number:language">ru</xsl:attribute>
2208				<xsl:attribute name="number:country">MD</xsl:attribute>
2209			</xsl:when>
2210			<xsl:when test="$language-country-code = 1083">
2211				<!-- Sami (Lappish), # (Northern Sami - Sweden), #043b -->
2212				<xsl:attribute name="number:language">se</xsl:attribute>
2213				<xsl:attribute name="number:country">SE</xsl:attribute>
2214			</xsl:when>
2215			<xsl:when test="$language-country-code = 1103">
2216				<!-- Sanskrit (India), #044f -->
2217				<xsl:attribute name="number:language">sa</xsl:attribute>
2218				<xsl:attribute name="number:country">IN</xsl:attribute>
2219			</xsl:when>
2220			<xsl:when test="$language-country-code = 1132">
2221				<!-- Sepedi (Northern Sotho - South Africa), #046c -->
2222				<xsl:attribute name="number:language">nso</xsl:attribute>
2223				<xsl:attribute name="number:country">ZA</xsl:attribute>
2224			</xsl:when>
2225			<xsl:when test="$language-country-code = 3098">
2226				<!-- Serbian (Cyrillic - Serbia Yugoslavia), #0c1a -->
2227				<xsl:attribute name="number:language">sr</xsl:attribute>
2228				<xsl:attribute name="number:country">YU</xsl:attribute>
2229			</xsl:when>
2230			<xsl:when test="$language-country-code = 2074">
2231				<!-- Serbian (Latin - Croatia), #081a -->
2232				<xsl:attribute name="number:language">sr</xsl:attribute>
2233				<xsl:attribute name="number:country">HR</xsl:attribute>
2234			</xsl:when>
2235			<xsl:when test="$language-country-code = 1113">
2236				<!-- Sindhi - India,#0459 -->
2237				<xsl:attribute name="number:language">sd</xsl:attribute>
2238				<xsl:attribute name="number:country">IN</xsl:attribute>
2239			</xsl:when>
2240			<xsl:when test="$language-country-code = 2137">
2241				<!-- Sindhi - Pakistan, #0859 -->
2242				<xsl:attribute name="number:language">sd</xsl:attribute>
2243				<xsl:attribute name="number:country">PK</xsl:attribute>
2244			</xsl:when>
2245			<xsl:when test="$language-country-code = 1115">
2246				<!-- Sinhalese - Sri Lanka, #045b -->
2247				<xsl:attribute name="number:language">si</xsl:attribute>
2248				<xsl:attribute name="number:country">LK</xsl:attribute>
2249			</xsl:when>
2250			<xsl:when test="$language-country-code = 1051">
2251				<!-- Slovak, #041b -->
2252				<xsl:attribute name="number:language">sk</xsl:attribute>
2253				<xsl:attribute name="number:country">SK</xsl:attribute>
2254			</xsl:when>
2255			<xsl:when test="$language-country-code = 1060">
2256				<!-- Slovenian, #0424 -->
2257				<xsl:attribute name="number:language">sl</xsl:attribute>
2258				<xsl:attribute name="number:country">SI</xsl:attribute>
2259			</xsl:when>
2260			<xsl:when test="$language-country-code = 1143">
2261				<!-- Somali, #0477 -->
2262				<xsl:attribute name="number:language">so</xsl:attribute>
2263				<xsl:attribute name="number:country">SO</xsl:attribute>
2264			</xsl:when>
2265			<xsl:when test="$language-country-code = 1070">
2266				<!-- Sorbian, #042e -->
2267				<xsl:attribute name="number:language">wen</xsl:attribute>
2268				<xsl:attribute name="number:country">DE</xsl:attribute>
2269			</xsl:when>
2270			<xsl:when test="$language-country-code = 3082">
2271				<!-- Spanish - Spain (Modern/International Sort), #0c0a -->
2272				<xsl:attribute name="number:language">es</xsl:attribute>
2273				<xsl:attribute name="number:country">ES</xsl:attribute>
2274			</xsl:when>
2275			<xsl:when test="$language-country-code = 1034">
2276				<!-- Spanish - Spain (Traditional Sort), #040a -->
2277				<xsl:attribute name="number:language">es</xsl:attribute>
2278				<xsl:attribute name="number:country">ES</xsl:attribute>
2279			</xsl:when>
2280			<xsl:when test="$language-country-code = 11274">
2281				<!-- Spanish - Argentina, #2c0a -->
2282				<xsl:attribute name="number:language">es</xsl:attribute>
2283				<xsl:attribute name="number:country">AR</xsl:attribute>
2284			</xsl:when>
2285			<xsl:when test="$language-country-code = 16394">
2286				<!-- Spanish - Bolivia, #400a -->
2287				<xsl:attribute name="number:language">es</xsl:attribute>
2288				<xsl:attribute name="number:country">BO</xsl:attribute>
2289			</xsl:when>
2290			<xsl:when test="$language-country-code = 13322">
2291				<!-- Spanish - Chile, #340a -->
2292				<xsl:attribute name="number:language">es</xsl:attribute>
2293				<xsl:attribute name="number:country">CL</xsl:attribute>
2294			</xsl:when>
2295			<xsl:when test="$language-country-code = 9226">
2296				<!-- Spanish - Colombia, #240a -->
2297				<xsl:attribute name="number:language">es</xsl:attribute>
2298				<xsl:attribute name="number:country">CO</xsl:attribute>
2299			</xsl:when>
2300			<xsl:when test="$language-country-code = 5130">
2301				<!-- Spanish - Costa Rica, #140a -->
2302				<xsl:attribute name="number:language">es</xsl:attribute>
2303				<xsl:attribute name="number:country">CR</xsl:attribute>
2304			</xsl:when>
2305			<xsl:when test="$language-country-code = 7178">
2306				<!-- Spanish - Dominican Republic, #1c0a -->
2307				<xsl:attribute name="number:language">es</xsl:attribute>
2308				<xsl:attribute name="number:country">DO</xsl:attribute>
2309			</xsl:when>
2310			<xsl:when test="$language-country-code = 12298">
2311				<!-- Spanish - Ecuador, #300a -->
2312				<xsl:attribute name="number:language">es</xsl:attribute>
2313				<xsl:attribute name="number:country">EC</xsl:attribute>
2314			</xsl:when>
2315			<xsl:when test="$language-country-code = 17418">
2316				<!-- Spanish - EL Salvador, #440a -->
2317				<xsl:attribute name="number:language">es</xsl:attribute>
2318				<xsl:attribute name="number:country">SV</xsl:attribute>
2319			</xsl:when>
2320			<xsl:when test="$language-country-code = 4106">
2321				<!-- Spanish - Guatemala, #100a -->
2322				<xsl:attribute name="number:language">es</xsl:attribute>
2323				<xsl:attribute name="number:country">GT</xsl:attribute>
2324			</xsl:when>
2325			<xsl:when test="$language-country-code = 18442">
2326				<!-- Spanish - Honduras, #480a -->
2327				<xsl:attribute name="number:language">es</xsl:attribute>
2328				<xsl:attribute name="number:country">HN</xsl:attribute>
2329			</xsl:when>
2330			<xsl:when test="$language-country-code = 58378">
2331				<!-- Spanish - Latin America (Argentina), #e40a -->
2332				<xsl:attribute name="number:language">es</xsl:attribute>
2333				<xsl:attribute name="number:country">AR</xsl:attribute>
2334			</xsl:when>
2335			<xsl:when test="$language-country-code = 2058">
2336				<!-- Spanish - Mexico, #080a -->
2337				<xsl:attribute name="number:language">es</xsl:attribute>
2338				<xsl:attribute name="number:country">MX</xsl:attribute>
2339			</xsl:when>
2340			<xsl:when test="$language-country-code = 19466">
2341				<!-- Spanish - Nicaragua, #4c0a -->
2342				<xsl:attribute name="number:language">es</xsl:attribute>
2343				<xsl:attribute name="number:country">NI</xsl:attribute>
2344			</xsl:when>
2345			<xsl:when test="$language-country-code = 6154">
2346				<!-- Spanish - Panama, #180a -->
2347				<xsl:attribute name="number:language">es</xsl:attribute>
2348				<xsl:attribute name="number:country">PA</xsl:attribute>
2349			</xsl:when>
2350			<xsl:when test="$language-country-code = 15370">
2351				<!-- Spanish - Paraguay, #3c0a -->
2352				<xsl:attribute name="number:language">es</xsl:attribute>
2353				<xsl:attribute name="number:country">PY</xsl:attribute>
2354			</xsl:when>
2355			<xsl:when test="$language-country-code = 10250">
2356				<!-- Spanish - Peru, #280a -->
2357				<xsl:attribute name="number:language">es</xsl:attribute>
2358				<xsl:attribute name="number:country">PE</xsl:attribute>
2359			</xsl:when>
2360			<xsl:when test="$language-country-code = 20490">
2361				<!-- Spanish - Puerto Rico, #500a -->
2362				<xsl:attribute name="number:language">es</xsl:attribute>
2363				<xsl:attribute name="number:country">PR</xsl:attribute>
2364			</xsl:when>
2365			<xsl:when test="$language-country-code = 21514">
2366				<!-- Spanish - US, #540a -->
2367				<xsl:attribute name="number:language">es</xsl:attribute>
2368				<xsl:attribute name="number:country">US</xsl:attribute>
2369			</xsl:when>
2370			<xsl:when test="$language-country-code = 14346">
2371				<!-- Spanish - Uruguay, #380a -->
2372				<xsl:attribute name="number:language">es</xsl:attribute>
2373				<xsl:attribute name="number:country">UY</xsl:attribute>
2374			</xsl:when>
2375			<xsl:when test="$language-country-code = 8202">
2376				<!-- Spanish - Venezuela, #200a -->
2377				<xsl:attribute name="number:language">es</xsl:attribute>
2378				<xsl:attribute name="number:country">VE</xsl:attribute>
2379			</xsl:when>
2380			<xsl:when test="$language-country-code = 1072">
2381				<!-- Sutu (Ngoni - Tanzania), #0430 -->
2382				<xsl:attribute name="number:language">bnt</xsl:attribute>
2383				<xsl:attribute name="number:country">TZ</xsl:attribute>
2384			</xsl:when>
2385			<xsl:when test="$language-country-code = 1089">
2386				<!-- Swahili (Tanzania), #0441 -->
2387				<xsl:attribute name="number:language">sw</xsl:attribute>
2388				<xsl:attribute name="number:country">TZ</xsl:attribute>
2389			</xsl:when>
2390			<xsl:when test="$language-country-code = 1053">
2391				<!-- Swedish (Sweden), #041d -->
2392				<xsl:attribute name="number:language">sv</xsl:attribute>
2393				<xsl:attribute name="number:country">SE</xsl:attribute>
2394			</xsl:when>
2395			<xsl:when test="$language-country-code = 2077">
2396				<!-- Swedish - Finland, #081d -->
2397				<xsl:attribute name="number:language">sv</xsl:attribute>
2398				<xsl:attribute name="number:country">FI</xsl:attribute>
2399			</xsl:when>
2400			<xsl:when test="$language-country-code = 1114">
2401				<!-- Syriac (Syria), #045a -->
2402				<xsl:attribute name="number:language">syr</xsl:attribute>
2403				<xsl:attribute name="number:country">SY</xsl:attribute>
2404			</xsl:when>
2405			<xsl:when test="$language-country-code = 1064">
2406				<!-- Tajik, #0428 -->
2407				<xsl:attribute name="number:language">tg</xsl:attribute>
2408				<xsl:attribute name="number:country">TJ</xsl:attribute>
2409			</xsl:when>
2410			<xsl:when test="$language-country-code = 1119">
2411				<!-- Tamazight (Arabic), #045f -->
2412				<xsl:attribute name="number:language">ber</xsl:attribute>
2413				<xsl:attribute name="number:country">ML</xsl:attribute>
2414			</xsl:when>
2415			<xsl:when test="$language-country-code = 2143">
2416				<!-- Tamazight (Latin), #085f -->
2417				<xsl:attribute name="number:language">ber</xsl:attribute>
2418				<xsl:attribute name="number:country">MA</xsl:attribute>
2419			</xsl:when>
2420			<xsl:when test="$language-country-code = 1097">
2421				<!-- Tamil (India), #0449 -->
2422				<xsl:attribute name="number:language">ta</xsl:attribute>
2423				<xsl:attribute name="number:country">IN</xsl:attribute>
2424			</xsl:when>
2425			<xsl:when test="$language-country-code = 1092">
2426				<!-- Tatar (Russia), #0444 -->
2427				<xsl:attribute name="number:language">tt</xsl:attribute>
2428				<xsl:attribute name="number:country">RU</xsl:attribute>
2429			</xsl:when>
2430			<xsl:when test="$language-country-code = 1098">
2431				<!-- Telugu (India), #044a -->
2432				<xsl:attribute name="number:language">te</xsl:attribute>
2433				<xsl:attribute name="number:country">IN</xsl:attribute>
2434			</xsl:when>
2435			<xsl:when test="$language-country-code = 1054">
2436				<!-- Thai, #041e -->
2437				<xsl:attribute name="number:language">th</xsl:attribute>
2438				<xsl:attribute name="number:country">TH</xsl:attribute>
2439			</xsl:when>
2440			<xsl:when test="$language-country-code = 2129">
2441				<!-- Tibetan - Bhutan, #0851 -->
2442				<xsl:attribute name="number:language">bo</xsl:attribute>
2443				<xsl:attribute name="number:country">BT</xsl:attribute>
2444			</xsl:when>
2445			<xsl:when test="$language-country-code = 1105">
2446				<!-- Tibetan - Peoples' Republic of China, #0451 -->
2447				<xsl:attribute name="number:language">bo</xsl:attribute>
2448				<xsl:attribute name="number:country">CN</xsl:attribute>
2449			</xsl:when>
2450			<xsl:when test="$language-country-code = 2163">
2451				<!-- Tigrigna (Tigrinya) - Eritrea, #0873 -->
2452				<xsl:attribute name="number:language">ti</xsl:attribute>
2453				<xsl:attribute name="number:country">ER</xsl:attribute>
2454			</xsl:when>
2455			<xsl:when test="$language-country-code = 1139">
2456				<!-- Tigrigna (Tigrinya) - Ethiopia, #0473 -->
2457				<xsl:attribute name="number:language">ti</xsl:attribute>
2458				<xsl:attribute name="number:country">ET</xsl:attribute>
2459			</xsl:when>
2460			<xsl:when test="$language-country-code = 1073">
2461				<!-- Tsonga (South Africa), #0431 -->
2462				<xsl:attribute name="number:language">ts</xsl:attribute>
2463				<xsl:attribute name="number:country">ZA</xsl:attribute>
2464			</xsl:when>
2465			<xsl:when test="$language-country-code = 1074">
2466				<!-- Tswana (South Africa), #0432 -->
2467				<xsl:attribute name="number:language">tn</xsl:attribute>
2468				<xsl:attribute name="number:country">ZA</xsl:attribute>
2469			</xsl:when>
2470			<xsl:when test="$language-country-code = 1055">
2471				<!-- Turkish, #041f -->
2472				<xsl:attribute name="number:language">tr</xsl:attribute>
2473				<xsl:attribute name="number:country">TR</xsl:attribute>
2474			</xsl:when>
2475			<xsl:when test="$language-country-code = 1090">
2476				<!-- Turkmen, #0442 -->
2477				<xsl:attribute name="number:language">tk</xsl:attribute>
2478				<xsl:attribute name="number:country">TM</xsl:attribute>
2479			</xsl:when>
2480			<xsl:when test="$language-country-code = 1152">
2481				<!-- Uighur - China, #0480 -->
2482				<xsl:attribute name="number:language">ug</xsl:attribute>
2483				<xsl:attribute name="number:country">CN</xsl:attribute>
2484			</xsl:when>
2485			<xsl:when test="$language-country-code = 1058">
2486				<!-- Ukrainian, #0422 -->
2487				<xsl:attribute name="number:language">uk</xsl:attribute>
2488				<xsl:attribute name="number:country">UA</xsl:attribute>
2489			</xsl:when>
2490			<xsl:when test="$language-country-code = 1056">
2491				<!-- Urdu (Pakistan), #0420 -->
2492				<xsl:attribute name="number:language">ur</xsl:attribute>
2493				<xsl:attribute name="number:country">PK</xsl:attribute>
2494			</xsl:when>
2495			<xsl:when test="$language-country-code = 2080">
2496				<!-- Urdu - India, #0820 -->
2497				<xsl:attribute name="number:language">ur</xsl:attribute>
2498				<xsl:attribute name="number:country">IN</xsl:attribute>
2499			</xsl:when>
2500			<xsl:when test="$language-country-code = 2115">
2501				<!-- Uzbek (Cyrillic), #0843 -->
2502				<xsl:attribute name="number:language">uz</xsl:attribute>
2503				<xsl:attribute name="number:country">UZ</xsl:attribute>
2504			</xsl:when>
2505			<xsl:when test="$language-country-code = 1091">
2506				<!-- Uzbek (Latin), #0443 -->
2507				<xsl:attribute name="number:language">uz</xsl:attribute>
2508				<xsl:attribute name="number:country">UZ</xsl:attribute>
2509			</xsl:when>
2510			<xsl:when test="$language-country-code = 1075">
2511				<!-- Venda (South Africa), #0433 -->
2512				<xsl:attribute name="number:language">ve</xsl:attribute>
2513				<xsl:attribute name="number:country">ZA</xsl:attribute>
2514			</xsl:when>
2515			<xsl:when test="$language-country-code = 1066">
2516				<!-- Vietnamese, #042a -->
2517				<xsl:attribute name="number:language">vi</xsl:attribute>
2518				<xsl:attribute name="number:country">VN</xsl:attribute>
2519			</xsl:when>
2520			<xsl:when test="$language-country-code = 1106">
2521				<!-- Welsh (UK), #0452 -->
2522				<xsl:attribute name="number:language">cy</xsl:attribute>
2523				<xsl:attribute name="number:country">UK</xsl:attribute>
2524			</xsl:when>
2525			<xsl:when test="$language-country-code = 1076">
2526				<!-- Xhosa (South Africa), #0434 -->
2527				<xsl:attribute name="number:language">xh</xsl:attribute>
2528				<xsl:attribute name="number:country">ZA</xsl:attribute>
2529			</xsl:when>
2530			<xsl:when test="$language-country-code = 1144">
2531				<!-- Yi (Sino-Tibetan - China), #0478 -->
2532				<xsl:attribute name="number:language">sit</xsl:attribute>
2533				<xsl:attribute name="number:country">CN</xsl:attribute>
2534			</xsl:when>
2535			<xsl:when test="$language-country-code = 1085">
2536				<!-- Yiddish (Jews - Israel), #043d -->
2537				<xsl:attribute name="number:language">yi</xsl:attribute>
2538				<xsl:attribute name="number:country">IL</xsl:attribute>
2539			</xsl:when>
2540			<xsl:when test="$language-country-code = 1130">
2541				<!-- Yoruba (Nigeria), #046a -->
2542				<xsl:attribute name="number:language">yo</xsl:attribute>
2543				<xsl:attribute name="number:country">NG</xsl:attribute>
2544			</xsl:when>
2545			<xsl:when test="$language-country-code = 1077">
2546				<!-- Zulu (South Africa), #0435 -->
2547				<xsl:attribute name="number:language">zu</xsl:attribute>
2548				<xsl:attribute name="number:country">ZA</xsl:attribute>
2549			</xsl:when>
2550		</xsl:choose>
2551	</xsl:template>
2552	<xsl:template name="get-number-format-condition">
2553		<xsl:param name="number-format-unit"/>
2554		<xsl:choose>
2555			<xsl:when test="contains($number-format-unit, '[&gt;')">
2556				<xsl:value-of select="concat('&gt;', substring-before( substring-after($number-format-unit,'[&gt;'), ']'))"/>
2557			</xsl:when>
2558			<xsl:when test="contains($number-format-unit, '[&lt;')">
2559				<xsl:value-of select="concat('&lt;', substring-before( substring-after($number-format-unit,'[&lt;'), ']'))"/>
2560			</xsl:when>
2561			<xsl:when test="contains($number-format-unit, '[=')">
2562				<xsl:value-of select="concat('=', substring-before( substring-after($number-format-unit,'[='), ']'))"/>
2563			</xsl:when>
2564			<xsl:otherwise/>
2565		</xsl:choose>
2566	</xsl:template>
2567	<xsl:template name="add-number-text-value">
2568		<xsl:param name="style-type-name"/>
2569		<xsl:param name="number-format-unit"/>
2570		<xsl:param name="unit-pos"/>
2571		<xsl:param name="condition-pos"/>
2572		<xsl:param name="isNumberTextElementOpened" select="false()"/>
2573		<xsl:param name="numberTextValue"/>
2574		<xsl:param name="posed-number-format-unit"/>
2575		<xsl:param name="finished" select="false()"/>
2576		<xsl:choose>
2577			<xsl:when test="not($finished)">
2578				<xsl:choose>
2579<!-- <xsl:when test="$style-type-name='number:text-style' or $style-type-name='number:date-style'"> -->
2580					<xsl:when test="$style-type-name='number:text-style'">
2581						<xsl:choose>
2582							<xsl:when test="$isNumberTextElementOpened">
2583								<number:text-content/>
2584								<number:text>
2585									<xsl:copy-of select="$numberTextValue"/>
2586								</number:text>
2587								<xsl:call-template name="get-number-text-content">
2588									<xsl:with-param name="style-type-name" select="$style-type-name"/>
2589									<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2590									<xsl:with-param name="unit-pos" select="$unit-pos"/>
2591									<xsl:with-param name="condition-pos" select="$condition-pos"/>
2592									<xsl:with-param name="isNumberTextElementOpened" select="true()"/>
2593									<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2594								</xsl:call-template>
2595							</xsl:when>
2596							<xsl:otherwise>
2597								<number:text>
2598									<xsl:copy-of select="$numberTextValue"/>
2599								</number:text>
2600								<xsl:call-template name="get-number-text-content">
2601									<xsl:with-param name="style-type-name" select="$style-type-name"/>
2602									<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2603									<xsl:with-param name="unit-pos" select="$unit-pos"/>
2604									<xsl:with-param name="condition-pos" select="$condition-pos"/>
2605									<xsl:with-param name="isNumberTextElementOpened" select="true()"/>
2606									<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2607								</xsl:call-template>
2608								<xsl:call-template name="get-number-text-content">
2609									<xsl:with-param name="style-type-name" select="$style-type-name"/>
2610									<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2611									<xsl:with-param name="unit-pos" select="$unit-pos"/>
2612									<xsl:with-param name="condition-pos" select="$condition-pos"/>
2613									<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2614									<xsl:with-param name="finished" select="true()"/>
2615								</xsl:call-template>
2616							</xsl:otherwise>
2617						</xsl:choose>
2618					</xsl:when>
2619					<xsl:when test="$style-type-name='number:number-style'">
2620						<xsl:choose>
2621							<xsl:when test="$isNumberTextElementOpened">
2622								<xsl:copy-of select="$numberTextValue"/>
2623								<xsl:call-template name="get-number-text-content">
2624									<xsl:with-param name="style-type-name" select="$style-type-name"/>
2625									<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2626									<xsl:with-param name="unit-pos" select="$unit-pos"/>
2627									<xsl:with-param name="condition-pos" select="$condition-pos"/>
2628									<xsl:with-param name="isNumberTextElementOpened" select="true()"/>
2629									<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2630								</xsl:call-template>
2631							</xsl:when>
2632							<xsl:otherwise>
2633								<number:text>
2634									<xsl:copy-of select="$numberTextValue"/>
2635									<xsl:call-template name="get-number-text-content">
2636										<xsl:with-param name="style-type-name" select="$style-type-name"/>
2637										<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2638										<xsl:with-param name="unit-pos" select="$unit-pos"/>
2639										<xsl:with-param name="condition-pos" select="$condition-pos"/>
2640										<xsl:with-param name="isNumberTextElementOpened" select="true()"/>
2641										<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2642									</xsl:call-template>
2643								</number:text>
2644								<xsl:call-template name="get-number-text-content">
2645									<xsl:with-param name="style-type-name" select="$style-type-name"/>
2646									<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2647									<xsl:with-param name="unit-pos" select="$unit-pos"/>
2648									<xsl:with-param name="condition-pos" select="$condition-pos"/>
2649									<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2650									<xsl:with-param name="finished" select="true()"/>
2651								</xsl:call-template>
2652							</xsl:otherwise>
2653						</xsl:choose>
2654					</xsl:when>
2655					<xsl:otherwise>
2656						<number:text>
2657							<xsl:copy-of select="$numberTextValue"/>
2658						</number:text>
2659						<xsl:choose>
2660							<xsl:when test="starts-with($posed-number-format-unit, '\')">
2661								<xsl:call-template name="get-number-text-content">
2662									<xsl:with-param name="style-type-name" select="$style-type-name"/>
2663									<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2664									<xsl:with-param name="unit-pos" select="$unit-pos"/>
2665									<xsl:with-param name="condition-pos" select="$condition-pos"/>
2666									<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2667									<xsl:with-param name="finished" select="false()" />
2668								</xsl:call-template>
2669							</xsl:when>
2670							<xsl:otherwise>
2671								<xsl:call-template name="get-number-text-content">
2672									<xsl:with-param name="style-type-name" select="$style-type-name"/>
2673									<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2674									<xsl:with-param name="unit-pos" select="$unit-pos"/>
2675									<xsl:with-param name="condition-pos" select="$condition-pos"/>
2676									<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2677									<xsl:with-param name="finished" select="true()" />
2678								</xsl:call-template>
2679							</xsl:otherwise>
2680						</xsl:choose>
2681					</xsl:otherwise>
2682				</xsl:choose>
2683			</xsl:when>
2684			<xsl:otherwise>
2685				<xsl:call-template name="get-number-text-content">
2686					<xsl:with-param name="style-type-name" select="$style-type-name"/>
2687					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2688					<xsl:with-param name="unit-pos" select="$unit-pos"/>
2689					<xsl:with-param name="condition-pos" select="$condition-pos"/>
2690					<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2691				</xsl:call-template>
2692			</xsl:otherwise>
2693		</xsl:choose>
2694	</xsl:template>
2695	<xsl:template name="get-number-text-content">
2696		<xsl:param name="style-type-name"/>
2697		<xsl:param name="number-format-unit"/>
2698		<xsl:param name="unit-pos"/>
2699		<xsl:param name="condition-pos"/>
2700		<xsl:param name="isNumberTextElementOpened" select="false()"/>
2701		<xsl:param name="finished" select="false()"/>
2702		<xsl:param name="posed-number-format-unit"/>
2703		<!-- process number-format-unit by character string parser -->
2704		<xsl:choose>
2705			<xsl:when test="starts-with( $posed-number-format-unit, '\') or starts-with( $posed-number-format-unit, '*')">
2706				<xsl:choose>
2707					<xsl:when test="not($finished)">
2708						<xsl:call-template name="add-number-text-value">
2709							<xsl:with-param name="style-type-name" select="$style-type-name"/>
2710							<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2711							<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
2712							<xsl:with-param name="condition-pos" select="$condition-pos"/>
2713							<xsl:with-param name="isNumberTextElementOpened" select="$isNumberTextElementOpened"/>
2714							<xsl:with-param name="posed-number-format-unit" select="substring($number-format-unit,$unit-pos + 2)"/>
2715							<!-- place '*' temparily here, because now StarCalc doesn't support variable filling character definition -->
2716							<xsl:with-param name="numberTextValue" select="substring($posed-number-format-unit,2,1)"/>
2717							<xsl:with-param name="finished" select="$finished"/>
2718						</xsl:call-template>
2719					</xsl:when>
2720					<xsl:otherwise>
2721						<xsl:call-template name="get-number-text-content">
2722							<xsl:with-param name="style-type-name" select="$style-type-name"/>
2723							<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2724							<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
2725							<xsl:with-param name="condition-pos" select="$condition-pos"/>
2726							<xsl:with-param name="posed-number-format-unit" select="substring($number-format-unit,$unit-pos +2)"/>
2727							<xsl:with-param name="finished" select="true()"/>
2728						</xsl:call-template>
2729					</xsl:otherwise>
2730				</xsl:choose>
2731			</xsl:when>
2732			<xsl:when test="starts-with( $posed-number-format-unit, '_')">
2733				<xsl:choose>
2734					<xsl:when test="not($finished)">
2735						<xsl:call-template name="add-number-text-value">
2736							<xsl:with-param name="style-type-name" select="$style-type-name"/>
2737							<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2738							<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
2739							<xsl:with-param name="condition-pos" select="$condition-pos"/>
2740							<xsl:with-param name="isNumberTextElementOpened" select="$isNumberTextElementOpened"/>
2741							<xsl:with-param name="posed-number-format-unit" select="substring($number-format-unit,$unit-pos + 2)"/>
2742							<!-- adding an empty string -->
2743							<xsl:with-param name="numberTextValue" select="' '"/>
2744							<xsl:with-param name="finished" select="$finished"/>
2745						</xsl:call-template>
2746					</xsl:when>
2747					<xsl:otherwise>
2748						<xsl:call-template name="get-number-text-content">
2749							<xsl:with-param name="style-type-name" select="$style-type-name"/>
2750							<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2751							<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
2752							<xsl:with-param name="condition-pos" select="$condition-pos"/>
2753							<xsl:with-param name="posed-number-format-unit" select="substring($number-format-unit,$unit-pos + 2)"/>
2754							<xsl:with-param name="finished" select="true()"/>
2755						</xsl:call-template>
2756					</xsl:otherwise>
2757				</xsl:choose>
2758			</xsl:when>
2759			<xsl:when test="starts-with( $posed-number-format-unit, '&quot;')">
2760				<xsl:choose>
2761					<xsl:when test="not($finished)">
2762						<!-- creating a pre-character string  -->
2763						<xsl:variable name="pre-character-string" select="substring-before(substring($posed-number-format-unit,2), '&quot;')"/>
2764						<xsl:call-template name="add-number-text-value">
2765							<xsl:with-param name="style-type-name" select="$style-type-name"/>
2766							<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2767							<xsl:with-param name="unit-pos" select="$unit-pos + string-length($pre-character-string) + 2"/>
2768							<xsl:with-param name="condition-pos" select="$condition-pos"/>
2769							<xsl:with-param name="posed-number-format-unit" select="substring($number-format-unit,$unit-pos + string-length($pre-character-string) + 2)"/>
2770							<xsl:with-param name="isNumberTextElementOpened" select="$isNumberTextElementOpened"/>
2771							<xsl:with-param name="numberTextValue" select="$pre-character-string"/>
2772							<xsl:with-param name="finished" select="$finished"/>
2773						</xsl:call-template>
2774					</xsl:when>
2775					<xsl:otherwise>
2776						<!-- creating a pre-character string  -->
2777						<xsl:variable name="pre-character-string" select="substring-before(substring($posed-number-format-unit,2), '&quot;')"/>
2778						<xsl:call-template name="get-number-text-content">
2779							<xsl:with-param name="style-type-name" select="$style-type-name"/>
2780							<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2781							<xsl:with-param name="unit-pos" select="$unit-pos + string-length($pre-character-string) + 2"/>
2782							<xsl:with-param name="condition-pos" select="$condition-pos"/>
2783							<xsl:with-param name="posed-number-format-unit" select="substring($number-format-unit,$unit-pos + string-length($pre-character-string) + 2)"/>
2784							<xsl:with-param name="finished" select="true()"/>
2785						</xsl:call-template>
2786					</xsl:otherwise>
2787				</xsl:choose>
2788			</xsl:when>
2789			<xsl:otherwise>
2790				<xsl:if test="$finished">
2791					<xsl:call-template name="create-number-format-content">
2792						<xsl:with-param name="style-type-name" select="$style-type-name"/>
2793						<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2794						<xsl:with-param name="unit-pos" select="$unit-pos"/>
2795						<xsl:with-param name="condition-pos" select="$condition-pos"/>
2796					</xsl:call-template>
2797				</xsl:if>
2798			</xsl:otherwise>
2799		</xsl:choose>
2800	</xsl:template>
2801	<xsl:template name="create-number-format-content">
2802		<xsl:param name="style-type-name"/>
2803		<xsl:param name="number-format-unit"/>
2804		<xsl:param name="unit-pos"/>
2805		<xsl:param name="condition-pos"/>
2806		<xsl:param name="isNumberTextElementOpened" select="false()"/>
2807		<xsl:variable name="posed-number-format-unit" select="substring($number-format-unit,$unit-pos)"/>
2808		<xsl:variable name="calendar-type-name">
2809			<xsl:if test="contains( $number-format-unit, '[$')">
2810				<xsl:variable name="format-code" select="substring-before( substring-after( substring-after( $number-format-unit, '[$'), '-'), ']')"/>
2811				<xsl:if test="string-length( $format-code) &gt; 4">
2812					<xsl:call-template name="get-calendar-type-name">
2813						<xsl:with-param name="calendar-type" select="substring( $format-code, string-length($format-code) -5, 2)"/>
2814					</xsl:call-template>
2815				</xsl:if>
2816			</xsl:if>
2817		</xsl:variable>
2818		<!-- process number-format-unit by character string parser -->
2819		<xsl:choose>
2820			<xsl:when test="starts-with( $posed-number-format-unit, '[$') and (not(starts-with($posed-number-format-unit, '[$-') ) )">
2821				<xsl:element name="number:currency-symbol">
2822					<xsl:call-template name="create-language-country-attribute">
2823						<xsl:with-param name="attribute-code" select="substring-before(substring-after(substring-after($posed-number-format-unit,'[$'),'-'),']')"/>
2824					</xsl:call-template>
2825					<xsl:value-of select="substring-before( substring-after( $posed-number-format-unit, '[$'), '-')"/>
2826				</xsl:element>
2827				<xsl:call-template name="create-number-format-content">
2828					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2829					<xsl:with-param name="unit-pos" select="$unit-pos + string-length( substring-before( $posed-number-format-unit, ']') ) + 1"/>
2830					<xsl:with-param name="condition-pos" select="$condition-pos"/>
2831				</xsl:call-template>
2832			</xsl:when>
2833			<xsl:when test="starts-with( $posed-number-format-unit, '\') or starts-with( $posed-number-format-unit, '*') or starts-with( $posed-number-format-unit, '_') or starts-with( $posed-number-format-unit, '&quot;')">
2834				<xsl:call-template name="get-number-text-content">
2835					<xsl:with-param name="style-type-name" select="$style-type-name"/>
2836					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
2837					<xsl:with-param name="unit-pos" select="$unit-pos"/>
2838					<xsl:with-param name="condition-pos" select="$condition-pos"/>
2839					<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
2840				</xsl:call-template>
2841			</xsl:when>
2842			<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') ) )">
2843				<xsl:variable name="valid-number-format-string">
2844					<xsl:call-template name="get-valid-number-format-string">
2845						<xsl:with-param name="number-format-unit" select="$posed-number-format-unit"/>
2846					</xsl:call-template>
2847				</xsl:variable>
2848				<xsl:choose>
2849					<xsl:when test="contains( $valid-number-format-string, '/')">
2850						<xsl:element name="number:fraction">
2851							<xsl:attribute name="number:min-integer-digits">
2852								<xsl:value-of select="string-length( substring-before($valid-number-format-string, '/') ) - string-length(translate( substring-before($valid-number-format-string, '/'), '0', '') )"/>
2853							</xsl:attribute>
2854							<xsl:if test="contains( $valid-number-format-string, ',')">
2855								<xsl:attribute name="number:grouping">true</xsl:attribute>
2856							</xsl:if>
2857							<xsl:attribute name="number:min-numerator-digits">
2858								<xsl:value-of select="string-length( substring-before($valid-number-format-string, '/') ) - string-length(translate( substring-before($valid-number-format-string,'/'), '?', '') )"/>
2859							</xsl:attribute>
2860							<xsl:attribute name="number:min-denominator-digits">
2861								<xsl:value-of select="string-length(substring-after($valid-number-format-string, '/') )"/>
2862							</xsl:attribute>
2863							<!-- deal with number:embedded-text (removed, as SCHEMA demands element to be empty)
2864							<xsl:call-template name="create-number-format-embedded-text">
2865								<xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
2866								<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
2867							</xsl:call-template>
2868							 -->
2869						</xsl:element>
2870					</xsl:when>
2871					<xsl:when test="contains( $valid-number-format-string, '%')">
2872						<xsl:element name="number:number">
2873							<xsl:choose>
2874								<xsl:when test="contains( $valid-number-format-string, '.')">
2875									<xsl:attribute name="number:decimal-places">
2876										<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', '') )"/>
2877									</xsl:attribute>
2878									<xsl:attribute name="number:min-integer-digits">
2879										<xsl:value-of select="string-length( substring-before($valid-number-format-string, '.') ) - string-length(translate( substring-before($valid-number-format-string, '.'), '0', '') )"/>
2880									</xsl:attribute>
2881								</xsl:when>
2882								<xsl:otherwise>
2883									<xsl:attribute name="number:decimal-places">0</xsl:attribute>
2884									<xsl:attribute name="number:min-integer-digits">
2885										<xsl:value-of select="string-length( substring-before($valid-number-format-string, '%') ) - string-length(translate( substring-before($valid-number-format-string, '%'), '0', '') )"/>
2886									</xsl:attribute>
2887								</xsl:otherwise>
2888							</xsl:choose>
2889							<xsl:choose>
2890								<xsl:when test="contains( $valid-number-format-string, ',') and (substring( $valid-number-format-string,string-length($valid-number-format-string)) = ',')">
2891									<xsl:variable name="display-factor">
2892										<xsl:call-template name="get-display-factor">
2893											<xsl:with-param name="start-number" select="1"/>
2894											<xsl:with-param name="thousand-count" select="string-length($valid-number-format-string) - string-length( translate($valid-number-format-string, ',', '') )"/>
2895										</xsl:call-template>
2896									</xsl:variable>
2897									<xsl:attribute name="number:display-factor">
2898										<xsl:value-of select="$display-factor"/>
2899									</xsl:attribute>
2900									<xsl:attribute name="number:grouping">true</xsl:attribute>
2901								</xsl:when>
2902								<xsl:when test="contains( $valid-number-format-string, ',')">
2903									<xsl:attribute name="number:grouping">true</xsl:attribute>
2904								</xsl:when>
2905							</xsl:choose>
2906							<!-- deal with number:embedded-text -->
2907							<xsl:call-template name="create-number-format-embedded-text">
2908								<xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
2909								<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
2910							</xsl:call-template>
2911						</xsl:element>
2912						<number:text>%</number:text>
2913					</xsl:when>
2914					<xsl:when test="contains( $valid-number-format-string, 'E') or contains ($valid-number-format-string, 'e')">
2915						<xsl:element name="number:scientific-number">
2916							<xsl:choose>
2917								<xsl:when test="contains( $valid-number-format-string, '.')">
2918									<xsl:attribute name="number:decimal-places">
2919										<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', '') )"/>
2920									</xsl:attribute>
2921									<xsl:attribute name="number:min-integer-digits">
2922										<xsl:value-of select="string-length( substring-before($valid-number-format-string, '.') ) - string-length(translate( substring-before($valid-number-format-string, '.'), '0', '') )"/>
2923									</xsl:attribute>
2924								</xsl:when>
2925								<xsl:otherwise>
2926									<xsl:attribute name="number:decimal-places">0</xsl:attribute>
2927									<xsl:attribute name="number:min-integer-digits">
2928										<xsl:value-of select="string-length( substring-before($valid-number-format-string, 'E') ) - string-length(translate( substring-before($valid-number-format-string, 'E'), '0', '') )"/>
2929									</xsl:attribute>
2930								</xsl:otherwise>
2931							</xsl:choose>
2932							<xsl:attribute name="number:min-exponent-digits">
2933								<xsl:value-of select="string-length( substring-after( $valid-number-format-string, 'E') ) - string-length( translate( substring-after( $valid-number-format-string, 'E'), '0', '') )"/>
2934							</xsl:attribute>
2935							<!-- deal with number:embedded-text -->
2936							<xsl:call-template name="create-number-format-embedded-text">
2937								<xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
2938								<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
2939							</xsl:call-template>
2940						</xsl:element>
2941					</xsl:when>
2942					<xsl:otherwise>
2943						<!-- -normal number format, currency, and accounting, e.g -->
2944						<xsl:element name="number:number">
2945							<xsl:choose>
2946								<xsl:when test="contains( $valid-number-format-string, '.')">
2947									<xsl:attribute name="number:decimal-places">
2948										<xsl:value-of select="string-length( substring-after( $valid-number-format-string, '.') ) - string-length( translate( substring-after( $valid-number-format-string, '.'), '0', '') )"/>
2949									</xsl:attribute>
2950									<xsl:attribute name="number:min-integer-digits">
2951										<xsl:value-of select="string-length( substring-before($valid-number-format-string, '.') ) - string-length(translate( substring-before($valid-number-format-string, '.'), '0', '') )"/>
2952									</xsl:attribute>
2953								</xsl:when>
2954								<xsl:otherwise>
2955									<xsl:attribute name="number:decimal-places">0</xsl:attribute>
2956									<xsl:attribute name="number:min-integer-digits">
2957										<xsl:value-of select="string-length( $valid-number-format-string ) - string-length(translate( $valid-number-format-string, '0', '') )"/>
2958									</xsl:attribute>
2959								</xsl:otherwise>
2960							</xsl:choose>
2961							<xsl:choose>
2962								<xsl:when test="contains( $valid-number-format-string, ',') and (substring( $valid-number-format-string,string-length($valid-number-format-string)) = ',')">
2963									<xsl:variable name="display-factor">
2964										<xsl:call-template name="get-display-factor">
2965											<xsl:with-param name="start-number" select="1"/>
2966											<xsl:with-param name="thousand-count">
2967												<xsl:call-template name="thousand-count-temp">
2968													<xsl:with-param name="format-unit" select="$valid-number-format-string"/>
2969												</xsl:call-template>
2970											</xsl:with-param>
2971										</xsl:call-template>
2972									</xsl:variable>
2973									<xsl:attribute name="number:display-factor">
2974										<xsl:value-of select="$display-factor"/>
2975									</xsl:attribute>
2976									<xsl:attribute name="number:grouping">true</xsl:attribute>
2977								</xsl:when>
2978								<xsl:when test="contains( $valid-number-format-string, ',')">
2979									<xsl:attribute name="number:grouping">true</xsl:attribute>
2980								</xsl:when>
2981							</xsl:choose>
2982							<!-- deal with number:embedded-text -->
2983							<xsl:call-template name="create-number-format-embedded-text">
2984								<xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
2985								<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
2986							</xsl:call-template>
2987						</xsl:element>
2988					</xsl:otherwise>
2989				</xsl:choose>
2990				<!-- deal with post number:text -->
2991				<xsl:variable name="post-number-format-text">
2992					<xsl:call-template name="get-post-number-format-text">
2993						<xsl:with-param name="adapted-number-format-unit" select="$posed-number-format-unit"/>
2994						<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
2995					</xsl:call-template>
2996				</xsl:variable>
2997				<xsl:call-template name="create-number-format-content">
2998					<xsl:with-param name="style-type-name" select="$style-type-name"/>
2999					<xsl:with-param name="number-format-unit" select="$post-number-format-text"/>
3000					<xsl:with-param name="unit-pos" select="1"/>
3001					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3002				</xsl:call-template>
3003			</xsl:when>
3004			<xsl:when test="starts-with( $posed-number-format-unit, 'ggg')">
3005				<xsl:element name="number:era">
3006					<xsl:attribute name="number:style">long</xsl:attribute>
3007					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3008						<xsl:attribute name="number:calendar">
3009							<xsl:value-of select="$calendar-type-name"/>
3010						</xsl:attribute>
3011					</xsl:if>
3012				</xsl:element>
3013				<xsl:call-template name="create-number-format-content">
3014					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3015					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3016					<xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
3017					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3018				</xsl:call-template>
3019			</xsl:when>
3020			<xsl:when test="starts-with( $posed-number-format-unit, 'gg')">
3021				<xsl:element name="number:era">
3022					<xsl:attribute name="number:style">long</xsl:attribute>
3023					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3024						<xsl:attribute name="number:calendar">
3025							<xsl:value-of select="$calendar-type-name"/>
3026						</xsl:attribute>
3027					</xsl:if>
3028				</xsl:element>
3029				<xsl:call-template name="create-number-format-content">
3030					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3031					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3032					<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
3033					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3034				</xsl:call-template>
3035			</xsl:when>
3036			<xsl:when test="starts-with( $posed-number-format-unit, 'g')">
3037				<xsl:element name="number:era">
3038					<xsl:attribute name="number:style">short</xsl:attribute>
3039					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3040						<xsl:attribute name="number:calendar">
3041							<xsl:value-of select="$calendar-type-name"/>
3042						</xsl:attribute>
3043					</xsl:if>
3044				</xsl:element>
3045				<xsl:call-template name="create-number-format-content">
3046					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3047					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3048					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3049					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3050				</xsl:call-template>
3051			</xsl:when>
3052			<xsl:when test="starts-with( $posed-number-format-unit, 'ee')">
3053				<xsl:element name="number:year">
3054					<xsl:attribute name="number:style">long</xsl:attribute>
3055					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3056						<xsl:attribute name="number:calendar">
3057							<xsl:value-of select="$calendar-type-name"/>
3058						</xsl:attribute>
3059					</xsl:if>
3060				</xsl:element>
3061				<xsl:call-template name="create-number-format-content">
3062					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3063					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3064					<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
3065					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3066				</xsl:call-template>
3067			</xsl:when>
3068			<xsl:when test="starts-with( $posed-number-format-unit, 'r')">
3069				<xsl:element name="number:year">
3070					<xsl:attribute name="number:style">long</xsl:attribute>
3071					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3072						<xsl:attribute name="number:calendar">
3073							<xsl:value-of select="$calendar-type-name"/>
3074						</xsl:attribute>
3075					</xsl:if>
3076				</xsl:element>
3077				<xsl:call-template name="create-number-format-content">
3078					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3079					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3080					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3081					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3082				</xsl:call-template>
3083			</xsl:when>
3084			<xsl:when test="starts-with( $posed-number-format-unit, 'yyyy')">
3085				<xsl:element name="number:year">
3086					<xsl:attribute name="number:style">long</xsl:attribute>
3087					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3088						<xsl:attribute name="number:calendar">
3089							<xsl:value-of select="$calendar-type-name"/>
3090						</xsl:attribute>
3091					</xsl:if>
3092				</xsl:element>
3093				<xsl:call-template name="create-number-format-content">
3094					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3095					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3096					<xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
3097					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3098				</xsl:call-template>
3099			</xsl:when>
3100			<xsl:when test="starts-with( $posed-number-format-unit, 'yy')">
3101				<xsl:element name="number:year">
3102					<xsl:attribute name="number:style">short</xsl:attribute>
3103					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3104						<xsl:attribute name="number:calendar">
3105							<xsl:value-of select="$calendar-type-name"/>
3106						</xsl:attribute>
3107					</xsl:if>
3108				</xsl:element>
3109				<xsl:call-template name="create-number-format-content">
3110					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3111					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3112					<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
3113					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3114				</xsl:call-template>
3115			</xsl:when>
3116			<xsl:when test="starts-with( $posed-number-format-unit, 'e') or starts-with( $posed-number-format-unit, 'y')">
3117				<xsl:element name="number:year">
3118					<xsl:attribute name="number:style">short</xsl:attribute>
3119					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3120						<xsl:attribute name="number:calendar">
3121							<xsl:value-of select="$calendar-type-name"/>
3122						</xsl:attribute>
3123					</xsl:if>
3124				</xsl:element>
3125				<xsl:call-template name="create-number-format-content">
3126					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3127					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3128					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3129					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3130				</xsl:call-template>
3131			</xsl:when>
3132			<xsl:when test="starts-with( $posed-number-format-unit, 'mmmmm')">
3133				<xsl:element name="number:month">
3134					<xsl:attribute name="number:style">short</xsl:attribute>
3135					<xsl:attribute name="number:textual">true</xsl:attribute>
3136					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3137						<xsl:attribute name="number:calendar">
3138							<xsl:value-of select="$calendar-type-name"/>
3139						</xsl:attribute>
3140					</xsl:if>
3141				</xsl:element>
3142				<xsl:call-template name="create-number-format-content">
3143					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3144					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3145					<xsl:with-param name="unit-pos" select="$unit-pos + 5"/>
3146					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3147				</xsl:call-template>
3148			</xsl:when>
3149			<xsl:when test="starts-with( $posed-number-format-unit, 'mmmm')">
3150				<xsl:element name="number:month">
3151					<xsl:attribute name="number:style">long</xsl:attribute>
3152					<xsl:attribute name="number:textual">true</xsl:attribute>
3153					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3154						<xsl:attribute name="number:calendar">
3155							<xsl:value-of select="$calendar-type-name"/>
3156						</xsl:attribute>
3157					</xsl:if>
3158				</xsl:element>
3159				<xsl:call-template name="create-number-format-content">
3160					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3161					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3162					<xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
3163					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3164				</xsl:call-template>
3165			</xsl:when>
3166			<xsl:when test="starts-with( $posed-number-format-unit, 'mmm')">
3167				<xsl:element name="number:month">
3168					<xsl:attribute name="number:style">short</xsl:attribute>
3169					<xsl:attribute name="number:textual">true</xsl:attribute>
3170					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3171						<xsl:attribute name="number:calendar">
3172							<xsl:value-of select="$calendar-type-name"/>
3173						</xsl:attribute>
3174					</xsl:if>
3175				</xsl:element>
3176				<xsl:call-template name="create-number-format-content">
3177					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3178					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3179					<xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
3180					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3181				</xsl:call-template>
3182			</xsl:when>
3183			<xsl:when test="starts-with( $posed-number-format-unit, '[mm]')">
3184				<xsl:element name="number:minutes">
3185					<xsl:attribute name="number:style">long</xsl:attribute>
3186				</xsl:element>
3187				<xsl:call-template name="create-number-format-content">
3188					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3189					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3190					<xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
3191					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3192				</xsl:call-template>
3193			</xsl:when>
3194			<xsl:when test="starts-with( $posed-number-format-unit, '[m]')">
3195				<xsl:element name="number:minutes">
3196					<xsl:attribute name="number:style">short</xsl:attribute>
3197				</xsl:element>
3198				<xsl:call-template name="create-number-format-content">
3199					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3200					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3201					<xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
3202					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3203				</xsl:call-template>
3204			</xsl:when>
3205			<xsl:when test="starts-with( $posed-number-format-unit, 'mm') and ( contains( $number-format-unit, 'h') or contains( $posed-number-format-unit, 's') )">
3206				<xsl:element name="number:minutes">
3207					<xsl:attribute name="number:style">long</xsl:attribute>
3208				</xsl:element>
3209				<xsl:call-template name="create-number-format-content">
3210					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3211					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3212					<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
3213					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3214				</xsl:call-template>
3215			</xsl:when>
3216			<xsl:when test="starts-with( $posed-number-format-unit, 'mm')">
3217				<xsl:element name="number:month">
3218					<xsl:attribute name="number:style">long</xsl:attribute>
3219					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3220						<xsl:attribute name="number:calendar">
3221							<xsl:value-of select="$calendar-type-name"/>
3222						</xsl:attribute>
3223					</xsl:if>
3224				</xsl:element>
3225				<xsl:call-template name="create-number-format-content">
3226					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3227					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3228					<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
3229					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3230				</xsl:call-template>
3231			</xsl:when>
3232			<xsl:when test="starts-with( $posed-number-format-unit, 'm') and ( contains( $number-format-unit, 'h') or contains( $posed-number-format-unit, 's') )">
3233				<xsl:element name="number:minutes">
3234					<xsl:attribute name="number:style">short</xsl:attribute>
3235				</xsl:element>
3236				<xsl:call-template name="create-number-format-content">
3237					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3238					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3239					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3240					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3241				</xsl:call-template>
3242			</xsl:when>
3243			<xsl:when test="starts-with( $posed-number-format-unit, 'm')">
3244				<xsl:element name="number:month">
3245					<xsl:attribute name="number:style">short</xsl:attribute>
3246					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3247						<xsl:attribute name="number:calendar">
3248							<xsl:value-of select="$calendar-type-name"/>
3249						</xsl:attribute>
3250					</xsl:if>
3251				</xsl:element>
3252				<xsl:call-template name="create-number-format-content">
3253					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3254					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3255					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3256					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3257				</xsl:call-template>
3258			</xsl:when>
3259			<xsl:when test="starts-with( $posed-number-format-unit, 'dddd') or starts-with( $posed-number-format-unit, 'aaaa')">
3260				<xsl:element name="number:day-of-week">
3261					<xsl:attribute name="number:style">long</xsl:attribute>
3262					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3263						<xsl:attribute name="number:calendar">
3264							<xsl:value-of select="$calendar-type-name"/>
3265						</xsl:attribute>
3266					</xsl:if>
3267				</xsl:element>
3268				<xsl:call-template name="create-number-format-content">
3269					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3270					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3271					<xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
3272					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3273				</xsl:call-template>
3274			</xsl:when>
3275			<xsl:when test="starts-with( $posed-number-format-unit, 'ddd') or starts-with( $posed-number-format-unit, 'aaa')">
3276				<xsl:element name="number:day-of-week">
3277					<xsl:attribute name="number:style">short</xsl:attribute>
3278					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3279						<xsl:attribute name="number:calendar">
3280							<xsl:value-of select="$calendar-type-name"/>
3281						</xsl:attribute>
3282					</xsl:if>
3283				</xsl:element>
3284				<xsl:call-template name="create-number-format-content">
3285					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3286					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3287					<xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
3288					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3289				</xsl:call-template>
3290			</xsl:when>
3291			<xsl:when test="starts-with( $posed-number-format-unit, 'dd')">
3292				<xsl:element name="number:day">
3293					<xsl:attribute name="number:style">long</xsl:attribute>
3294					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3295						<xsl:attribute name="number:calendar">
3296							<xsl:value-of select="$calendar-type-name"/>
3297						</xsl:attribute>
3298					</xsl:if>
3299				</xsl:element>
3300				<xsl:call-template name="create-number-format-content">
3301					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3302					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3303					<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
3304					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3305				</xsl:call-template>
3306			</xsl:when>
3307			<xsl:when test="starts-with( $posed-number-format-unit, 'd')">
3308				<xsl:element name="number:day">
3309					<xsl:attribute name="number:style">short</xsl:attribute>
3310					<xsl:if test="string-length($calendar-type-name) &gt; 0">
3311						<xsl:attribute name="number:calendar">
3312							<xsl:value-of select="$calendar-type-name"/>
3313						</xsl:attribute>
3314					</xsl:if>
3315				</xsl:element>
3316				<xsl:call-template name="create-number-format-content">
3317					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3318					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3319					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3320					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3321				</xsl:call-template>
3322			</xsl:when>
3323			<xsl:when test="starts-with( $posed-number-format-unit, 'hh')">
3324				<xsl:element name="number:hours">
3325					<xsl:attribute name="number:style">long</xsl:attribute>
3326				</xsl:element>
3327				<xsl:call-template name="create-number-format-content">
3328					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3329					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3330					<xsl:with-param name="unit-pos" select="$unit-pos + 2"/>
3331					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3332				</xsl:call-template>
3333			</xsl:when>
3334			<xsl:when test="starts-with( $posed-number-format-unit, '[hh]')">
3335				<xsl:element name="number:hours">
3336					<xsl:attribute name="number:style">long</xsl:attribute>
3337				</xsl:element>
3338				<xsl:call-template name="create-number-format-content">
3339					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3340					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3341					<xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
3342					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3343				</xsl:call-template>
3344			</xsl:when>
3345			<xsl:when test="starts-with( $posed-number-format-unit, 'h')">
3346				<xsl:element name="number:hours">
3347					<xsl:attribute name="number:style">short</xsl:attribute>
3348				</xsl:element>
3349				<xsl:call-template name="create-number-format-content">
3350					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3351					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3352					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3353					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3354				</xsl:call-template>
3355			</xsl:when>
3356			<xsl:when test="starts-with( $posed-number-format-unit, '[h]')">
3357				<xsl:element name="number:hours">
3358					<xsl:attribute name="number:style">short</xsl:attribute>
3359				</xsl:element>
3360				<xsl:call-template name="create-number-format-content">
3361					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3362					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3363					<xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
3364					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3365				</xsl:call-template>
3366			</xsl:when>
3367			<xsl:when test="starts-with( $posed-number-format-unit, 'AM/PM') or starts-with( $posed-number-format-unit, 'am/pm')">
3368				<number:am-pm/>
3369				<!-- long: am-pm doesn't support long style yet -->
3370				<xsl:call-template name="create-number-format-content">
3371					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3372					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3373					<xsl:with-param name="unit-pos" select="$unit-pos + 5"/>
3374					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3375				</xsl:call-template>
3376			</xsl:when>
3377			<xsl:when test="starts-with( $posed-number-format-unit, 'a/p'or starts-with( $posed-number-format-unit, 'A/P'))">
3378				<number:am-pm/>
3379				<!-- short: am-pm doesn't support short style yet -->
3380				<xsl:call-template name="create-number-format-content">
3381					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3382					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3383					<xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
3384					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3385				</xsl:call-template>
3386			</xsl:when>
3387			<xsl:when test="starts-with( $posed-number-format-unit, 'ss')">
3388				<xsl:variable name="decimal-places">
3389					<xsl:choose>
3390						<xsl:when test="starts-with( $posed-number-format-unit, 'ss.0')">
3391							<xsl:value-of select="string-length( $posed-number-format-unit) - string-length( translate( $posed-number-format-unit, '0', '') )"/>
3392						</xsl:when>
3393						<xsl:otherwise>0</xsl:otherwise>
3394					</xsl:choose>
3395				</xsl:variable>
3396				<xsl:element name="number:seconds">
3397					<xsl:attribute name="number:style">long</xsl:attribute>
3398					<xsl:if test="$decimal-places &gt; 0">
3399						<xsl:attribute name="number:decimal-places">
3400							<xsl:value-of select="$decimal-places"/>
3401						</xsl:attribute>
3402					</xsl:if>
3403				</xsl:element>
3404				<xsl:variable name="second-length">
3405					<xsl:choose>
3406						<xsl:when test="$decimal-places &gt; 0">
3407							<xsl:value-of select="$decimal-places + 3"/>
3408						</xsl:when>
3409						<xsl:otherwise>2</xsl:otherwise>
3410					</xsl:choose>
3411				</xsl:variable>
3412				<xsl:call-template name="create-number-format-content">
3413					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3414					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3415					<xsl:with-param name="unit-pos" select="$unit-pos + $second-length"/>
3416					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3417				</xsl:call-template>
3418			</xsl:when>
3419			<xsl:when test="starts-with( $posed-number-format-unit, '[ss]')">
3420				<xsl:element name="number:seconds">
3421					<xsl:attribute name="number:style">long</xsl:attribute>
3422				</xsl:element>
3423				<xsl:call-template name="create-number-format-content">
3424					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3425					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3426					<xsl:with-param name="unit-pos" select="$unit-pos + 4"/>
3427					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3428				</xsl:call-template>
3429			</xsl:when>
3430			<xsl:when test="starts-with( $posed-number-format-unit, 's')">
3431				<xsl:variable name="decimal-places">
3432					<xsl:choose>
3433						<xsl:when test="starts-with( $posed-number-format-unit, 's.0')">
3434							<xsl:value-of select="string-length( $posed-number-format-unit) - string-length( translate( $posed-number-format-unit, '0', '') )"/>
3435						</xsl:when>
3436						<xsl:otherwise>0</xsl:otherwise>
3437					</xsl:choose>
3438				</xsl:variable>
3439				<xsl:element name="number:seconds">
3440					<xsl:attribute name="number:style">short</xsl:attribute>
3441					<xsl:if test="$decimal-places &gt; 0">
3442						<xsl:attribute name="number:decimal-places">
3443							<xsl:value-of select="$decimal-places"/>
3444						</xsl:attribute>
3445					</xsl:if>
3446				</xsl:element>
3447				<xsl:variable name="second-length">
3448					<xsl:choose>
3449						<xsl:when test="$decimal-places &gt; 0">
3450							<xsl:value-of select="$decimal-places + 2"/>
3451						</xsl:when>
3452						<xsl:otherwise>1</xsl:otherwise>
3453					</xsl:choose>
3454				</xsl:variable>
3455				<xsl:call-template name="create-number-format-content">
3456					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3457					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3458					<xsl:with-param name="unit-pos" select="$unit-pos + $second-length"/>
3459					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3460				</xsl:call-template>
3461			</xsl:when>
3462			<xsl:when test="starts-with( $posed-number-format-unit, '[s]')">
3463				<xsl:element name="number:seconds">
3464					<xsl:attribute name="number:style">short</xsl:attribute>
3465				</xsl:element>
3466				<xsl:call-template name="create-number-format-content">
3467					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3468					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3469					<xsl:with-param name="unit-pos" select="$unit-pos + 3"/>
3470					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3471				</xsl:call-template>
3472			</xsl:when>
3473			<xsl:when test="starts-with( $posed-number-format-unit, '@')">
3474				<number:text-content/>
3475				<xsl:call-template name="create-number-format-content">
3476					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3477					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3478					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3479					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3480				</xsl:call-template>
3481			</xsl:when>
3482			<xsl:when test="$posed-number-format-unit = 'General Number'">
3483				<number:number number:decimal-places="0" number:min-integer-digits="1"/>
3484			</xsl:when>
3485			<xsl:when test="$posed-number-format-unit = 'General Date'">
3486				<number:year number:style="long"/>
3487				<number:text>-</number:text>
3488				<number:month number:style="short"/>
3489				<number:text>-</number:text>
3490				<number:day number:style="short"/>
3491				<number:text>
3492					<xsl:text> </xsl:text>
3493				</number:text>
3494				<number:hours number:style="short"/>
3495				<number:text>:</number:text>
3496				<number:minutes number:style="long"/>
3497			</xsl:when>
3498			<!-- special for General number:text-content output -->
3499			<xsl:when test="starts-with($posed-number-format-unit , 'General')">
3500				<xsl:choose>
3501					<xsl:when test="$posed-number-format-unit = 'General' and $condition-pos = 1">
3502						<number:number number:decimal-places="0" number:min-integer-digits="1"/>
3503					</xsl:when>
3504					<xsl:otherwise>
3505						<xsl:call-template name="create-number-format-content">
3506							<xsl:with-param name="style-type-name" select="$style-type-name"/>
3507							<xsl:with-param name="number-format-unit" select="$posed-number-format-unit"/>
3508							<xsl:with-param name="unit-pos" select="8"/>
3509							<xsl:with-param name="condition-pos" select="$condition-pos"/>
3510						</xsl:call-template>
3511					</xsl:otherwise>
3512				</xsl:choose>
3513			</xsl:when>
3514			<xsl:when test="$posed-number-format-unit = 'Fixed'">
3515				<number:number number:decimal-places="2" number:min-integer-digits="1"/>
3516				<number:text/>
3517			</xsl:when>
3518			<xsl:when test="$posed-number-format-unit = 'Standard'">
3519				<number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/>
3520			</xsl:when>
3521			<xsl:when test="$posed-number-format-unit = 'Long Date'">
3522				<number:year number:style="long"/>
3523				<number:text>-</number:text>
3524				<number:month number:style="long"/>
3525				<number:text>-</number:text>
3526				<number:day number:style="long"/>
3527			</xsl:when>
3528			<xsl:when test="$posed-number-format-unit = 'Medium Date'">
3529				<number:day number:style="short"/>
3530				<number:text>-</number:text>
3531				<number:month number:textual="true"/>
3532				<number:text>-</number:text>
3533				<number:year number:style="short"/>
3534			</xsl:when>
3535			<xsl:when test="$posed-number-format-unit = 'Short Date'">
3536				<number:day number:style="short"/>
3537				<number:text>-</number:text>
3538				<number:month number:style="short"/>
3539				<number:text>-</number:text>
3540				<number:year number:style="short"/>
3541			</xsl:when>
3542			<xsl:when test="$posed-number-format-unit = 'Long Time'">
3543				<number:hours number:style="long"/>
3544				<number:text>:</number:text>
3545				<number:minutes number:style="long"/>
3546				<number:text>:</number:text>
3547				<number:seconds number:style="long"/>
3548				<number:text>
3549					<xsl:text> </xsl:text>
3550				</number:text>
3551				<number:am-pm/>
3552			</xsl:when>
3553			<xsl:when test="$posed-number-format-unit = 'Medium Time'">
3554				<number:hours number:style="short"/>
3555				<number:text>:</number:text>
3556				<number:minutes number:style="long"/>
3557				<number:text>
3558					<xsl:text> </xsl:text>
3559				</number:text>
3560				<number:am-pm/>
3561			</xsl:when>
3562			<xsl:when test="$posed-number-format-unit = 'Short Time'">
3563				<number:hours number:style="short"/>
3564				<number:text>:</number:text>
3565				<number:minutes number:style="long"/>
3566				<number:text>
3567					<xsl:text> </xsl:text>
3568				</number:text>
3569			</xsl:when>
3570			<xsl:when test="$posed-number-format-unit = 'Percent'">
3571				<number:number number:decimal-places="2" number:min-integer-digits="1"/>
3572				<number:text>%</number:text>
3573			</xsl:when>
3574			<xsl:when test="$posed-number-format-unit = 'Scientific'">
3575				<number:scientific-number number:decimal-places="2" number:min-integer-digits="1" number:min-exponent-digits="2"/>
3576			</xsl:when>
3577			<xsl:when test="starts-with( $posed-number-format-unit, '[')">
3578				<xsl:call-template name="create-number-format-content">
3579					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3580					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3581					<xsl:with-param name="unit-pos" select="$unit-pos + string-length( substring-before( $posed-number-format-unit, ']') ) + 1"/>
3582					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3583					<xsl:with-param name="isNumberTextElementOpened" select="$isNumberTextElementOpened"/>
3584					<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
3585				</xsl:call-template>
3586			</xsl:when>
3587			<xsl:when test="starts-with( $posed-number-format-unit, '/')">
3588				<number:text>/</number:text>
3589				<xsl:call-template name="create-number-format-content">
3590					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3591					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3592					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3593					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3594				</xsl:call-template>
3595			</xsl:when>
3596			<xsl:when test="starts-with( $posed-number-format-unit, ':')">
3597				<number:text>:</number:text>
3598				<xsl:call-template name="create-number-format-content">
3599					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3600					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3601					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3602					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3603				</xsl:call-template>
3604			</xsl:when>
3605			<xsl:when test="string-length( $posed-number-format-unit ) &gt; 0">
3606				<xsl:call-template name="create-number-format-content">
3607					<xsl:with-param name="style-type-name" select="$style-type-name"/>
3608					<xsl:with-param name="number-format-unit" select="$number-format-unit"/>
3609					<xsl:with-param name="unit-pos" select="$unit-pos + 1"/>
3610					<xsl:with-param name="condition-pos" select="$condition-pos"/>
3611					<xsl:with-param name="isNumberTextElementOpened" select="$isNumberTextElementOpened"/>
3612					<xsl:with-param name="posed-number-format-unit" select="$posed-number-format-unit"/>
3613					<xsl:with-param name="numberTextValue" select="substring( $posed-number-format-unit, 1, 1)"/>
3614				</xsl:call-template>
3615			</xsl:when>
3616		</xsl:choose>
3617	</xsl:template>
3618	<xsl:template name="thousand-count-temp">
3619		<!-- thousand count for char ',' at the latter of format-unit by recursion -->
3620		<xsl:param name="format-unit"/>
3621		<xsl:choose>
3622			<xsl:when test="contains($format-unit, ',#')">
3623				<xsl:call-template name="thousand-count-temp">
3624					<xsl:with-param name="format-unit" select="substring-after($format-unit, ',#')"/>
3625				</xsl:call-template>
3626			</xsl:when>
3627			<xsl:when test="contains($format-unit, ',0')">
3628				<xsl:call-template name="thousand-count-temp">
3629					<xsl:with-param name="format-unit" select="substring-after($format-unit, ',0')"/>
3630				</xsl:call-template>
3631			</xsl:when>
3632			<xsl:otherwise>
3633				<xsl:value-of select="string-length($format-unit) - string-length( translate($format-unit, ',', ''))"/>
3634			</xsl:otherwise>
3635		</xsl:choose>
3636	</xsl:template>
3637	<xsl:template name="get-calendar-type-name">
3638		<xsl:param name="calendar-type"/>
3639		<xsl:variable name="temp-type">
3640			<xsl:call-template name="hex2decimal">
3641				<xsl:with-param name="hex-number" select="$calendar-type"/>
3642				<xsl:with-param name="index" select="1"/>
3643				<xsl:with-param name="str-length" select="string-length($calendar-type)"/>
3644				<xsl:with-param name="last-value" select="0"/>
3645			</xsl:call-template>
3646		</xsl:variable>
3647		<xsl:choose>
3648			<!-- Japanese (Emperor era), #03 -->
3649			<xsl:when test="$temp-type = 3">gengou</xsl:when>
3650			<!-- Taiwanese, #04 -->
3651			<xsl:when test="$temp-type = 4">ROC</xsl:when>
3652			<!-- Korean (Tangun era) hanja_yoil is ok too. #05 -->
3653			<xsl:when test="$temp-type = 5">hanja</xsl:when>
3654			<!-- Hijri (Arabic lunar), #06 -->
3655			<xsl:when test="$temp-type = 6">hijri</xsl:when>
3656			<!-- Thai, #07 -->
3657			<xsl:when test="$temp-type = 7">buddhist</xsl:when>
3658			<!-- 01: Gregorian (Localized), 02: Gregorian (United States), 09: Gregorian (Middle East French), 0A: Gregorian (Arabic), 0B: Gregorian (Transliterated English) -->
3659			<xsl:otherwise>gregorian</xsl:otherwise>
3660			<!-- not found jewish yet -->
3661		</xsl:choose>
3662	</xsl:template>
3663	<xsl:template name="get-valid-number-format-string">
3664		<xsl:param name="number-format-unit"/>
3665		<xsl:choose>
3666			<xsl:when test="contains( $number-format-unit, '\')">
3667				<xsl:call-template name="get-valid-number-format-string">
3668					<xsl:with-param name="number-format-unit" select="concat( substring-before( $number-format-unit, '\'), substring( substring-after( $number-format-unit, '\'), 2) )"/>
3669				</xsl:call-template>
3670			</xsl:when>
3671			<xsl:when test="contains( $number-format-unit, '*')">
3672				<xsl:call-template name="get-valid-number-format-string">
3673					<xsl:with-param name="number-format-unit" select="concat( substring-before( $number-format-unit, '*'), substring( substring-after( $number-format-unit, '*'), 2) )"/>
3674				</xsl:call-template>
3675			</xsl:when>
3676			<xsl:when test="contains( $number-format-unit, '_')">
3677				<xsl:call-template name="get-valid-number-format-string">
3678					<xsl:with-param name="number-format-unit" select="concat( substring-before( $number-format-unit, '_'), substring( substring-after( $number-format-unit, '_'), 2) )"/>
3679				</xsl:call-template>
3680			</xsl:when>
3681			<xsl:when test="contains( $number-format-unit, '&quot;')">
3682				<xsl:call-template name="get-valid-number-format-string">
3683					<xsl:with-param name="number-format-unit" select="concat( substring-before( $number-format-unit, '&quot;'), substring-after( substring-after( $number-format-unit, '&quot;'), '&quot;') )"/>
3684				</xsl:call-template>
3685			</xsl:when>
3686			<xsl:otherwise>
3687				<xsl:value-of select="$number-format-unit"/>
3688			</xsl:otherwise>
3689		</xsl:choose>
3690	</xsl:template>
3691	<xsl:template name="get-display-factor">
3692		<xsl:param name="start-number"/>
3693		<xsl:param name="thousand-count"/>
3694		<xsl:choose>
3695			<xsl:when test="$thousand-count = 0">
3696				<xsl:value-of select="$start-number"/>
3697			</xsl:when>
3698			<xsl:otherwise>
3699				<xsl:call-template name="get-display-factor">
3700					<xsl:with-param name="start-number" select="$start-number * 1000"/>
3701					<xsl:with-param name="thousand-count" select="$thousand-count -1"/>
3702				</xsl:call-template>
3703			</xsl:otherwise>
3704		</xsl:choose>
3705	</xsl:template>
3706	<xsl:template name="get-post-number-format-text">
3707		<xsl:param name="adapted-number-format-unit"/>
3708		<xsl:param name="valid-number-format-string"/>
3709		<xsl:variable name="first-embedded-character-pos">
3710			<xsl:choose>
3711				<xsl:when test="contains( $adapted-number-format-unit, '\')">
3712					<xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '\') ) + 1"/>
3713				</xsl:when>
3714				<xsl:when test="contains( $adapted-number-format-unit, '_')">
3715					<xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '_') ) + 1"/>
3716				</xsl:when>
3717				<xsl:when test="contains( $adapted-number-format-unit, '*')">
3718					<xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '*') ) + 1"/>
3719				</xsl:when>
3720				<xsl:otherwise>0</xsl:otherwise>
3721			</xsl:choose>
3722		</xsl:variable>
3723		<xsl:variable name="first-embedded-string-pos">
3724			<xsl:choose>
3725				<xsl:when test="contains( $adapted-number-format-unit, '&quot;')">
3726					<xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '&quot;') ) + 1"/>
3727				</xsl:when>
3728				<xsl:otherwise>0</xsl:otherwise>
3729			</xsl:choose>
3730		</xsl:variable>
3731		<xsl:variable name="first-embedded-text-pos">
3732			<xsl:choose>
3733				<xsl:when test="$first-embedded-character-pos &lt; $first-embedded-string-pos and $first-embedded-character-pos &gt; 0">
3734					<xsl:value-of select="$first-embedded-character-pos"/>
3735				</xsl:when>
3736				<xsl:when test="$first-embedded-character-pos &lt; $first-embedded-string-pos and $first-embedded-character-pos = 0">
3737					<xsl:value-of select="$first-embedded-string-pos"/>
3738				</xsl:when>
3739				<xsl:when test="$first-embedded-character-pos &gt; $first-embedded-string-pos and $first-embedded-string-pos &gt; 0">
3740					<xsl:value-of select="$first-embedded-string-pos"/>
3741				</xsl:when>
3742				<xsl:when test="$first-embedded-character-pos &gt; $first-embedded-string-pos and $first-embedded-string-pos = 0">
3743					<xsl:value-of select="$first-embedded-character-pos"/>
3744				</xsl:when>
3745			</xsl:choose>
3746		</xsl:variable>
3747		<xsl:choose>
3748			<xsl:when test="$first-embedded-text-pos &gt; string-length( $valid-number-format-string )">
3749				<xsl:value-of select="substring( $adapted-number-format-unit, $first-embedded-text-pos)"/>
3750			</xsl:when>
3751			<xsl:when test="$first-embedded-text-pos &gt; 0 and $first-embedded-text-pos &lt; string-length( $valid-number-format-string )">
3752				<xsl:choose>
3753					<xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '\')">
3754						<xsl:call-template name="get-post-number-format-text">
3755							<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) )"/>
3756							<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
3757						</xsl:call-template>
3758					</xsl:when>
3759					<xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '_')">
3760						<xsl:call-template name="get-post-number-format-text">
3761							<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) )"/>
3762							<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
3763						</xsl:call-template>
3764					</xsl:when>
3765					<xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '*')">
3766						<xsl:call-template name="get-post-number-format-text">
3767							<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) )"/>
3768							<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
3769						</xsl:call-template>
3770					</xsl:when>
3771					<xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '&quot;')">
3772						<xsl:call-template name="get-post-number-format-text">
3773							<xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '&quot;'), substring-after( substring-after( $adapted-number-format-unit, '&quot;'), '&quot;') )"/>
3774							<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
3775						</xsl:call-template>
3776					</xsl:when>
3777				</xsl:choose>
3778			</xsl:when>
3779			<xsl:otherwise/>
3780		</xsl:choose>
3781	</xsl:template>
3782	<xsl:template name="create-number-format-embedded-text">
3783		<xsl:param name="adapted-number-format-unit"/>
3784		<xsl:param name="valid-number-format-string"/>
3785		<xsl:variable name="first-embedded-character-pos">
3786			<xsl:choose>
3787				<xsl:when test="contains( $adapted-number-format-unit, '\')">
3788					<xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '\') ) + 1"/>
3789				</xsl:when>
3790				<xsl:when test="contains( $adapted-number-format-unit, '_')">
3791					<xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '_') ) + 1"/>
3792				</xsl:when>
3793				<xsl:when test="contains( $adapted-number-format-unit, '*')">
3794					<xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '*') ) + 1"/>
3795				</xsl:when>
3796				<xsl:otherwise>0</xsl:otherwise>
3797			</xsl:choose>
3798		</xsl:variable>
3799		<xsl:variable name="first-embedded-string-pos">
3800			<xsl:choose>
3801				<xsl:when test="contains( $adapted-number-format-unit, '&quot;')">
3802					<xsl:value-of select="string-length( substring-before($adapted-number-format-unit, '&quot;') ) + 1"/>
3803				</xsl:when>
3804				<xsl:otherwise>0</xsl:otherwise>
3805			</xsl:choose>
3806		</xsl:variable>
3807		<xsl:variable name="first-embedded-text-pos">
3808			<xsl:choose>
3809				<xsl:when test="$first-embedded-character-pos &lt; $first-embedded-string-pos and $first-embedded-character-pos &gt; 0">
3810					<xsl:value-of select="$first-embedded-character-pos"/>
3811				</xsl:when>
3812				<xsl:when test="$first-embedded-character-pos &lt; $first-embedded-string-pos and $first-embedded-character-pos = 0">
3813					<xsl:value-of select="$first-embedded-string-pos"/>
3814				</xsl:when>
3815				<xsl:when test="$first-embedded-character-pos &gt; $first-embedded-string-pos and $first-embedded-string-pos &gt; 0">
3816					<xsl:value-of select="$first-embedded-string-pos"/>
3817				</xsl:when>
3818				<xsl:when test="$first-embedded-character-pos &gt; $first-embedded-string-pos and $first-embedded-string-pos = 0">
3819					<xsl:value-of select="$first-embedded-character-pos"/>
3820				</xsl:when>
3821			</xsl:choose>
3822		</xsl:variable>
3823		<xsl:if test="$first-embedded-text-pos &gt; 0 and $first-embedded-text-pos &lt; string-length( $valid-number-format-string )">
3824			<xsl:variable name="text-pos">
3825				<xsl:choose>
3826					<xsl:when test="contains( $valid-number-format-string, '.')">
3827						<xsl:variable name="right-text-pos" select="substring( substring-before( $valid-number-format-string, '.'), $first-embedded-text-pos)"/>
3828						<xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
3829					</xsl:when>
3830					<xsl:when test="contains( $valid-number-format-string, '/')">
3831						<xsl:variable name="right-text-pos" select="substring( substring-before( $valid-number-format-string, '/'), $first-embedded-text-pos)"/>
3832						<xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
3833					</xsl:when>
3834					<xsl:when test="contains( $valid-number-format-string, '%')">
3835						<xsl:variable name="right-text-pos" select="substring( substring-before( $valid-number-format-string, '%'), $first-embedded-text-pos)"/>
3836						<xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
3837					</xsl:when>
3838					<xsl:when test="contains( $valid-number-format-string, 'E')">
3839						<xsl:variable name="right-text-pos" select="substring( substring-before( $valid-number-format-string, 'E'), $first-embedded-text-pos)"/>
3840						<xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
3841					</xsl:when>
3842					<xsl:otherwise>
3843						<xsl:variable name="right-text-pos" select="substring( $valid-number-format-string, $first-embedded-text-pos)"/>
3844						<xsl:value-of select="string-length($right-text-pos) - string-length( translate( $right-text-pos, '0#?', '') )"/>
3845					</xsl:otherwise>
3846				</xsl:choose>
3847			</xsl:variable>
3848			<xsl:choose>
3849				<xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '\')">
3850					<number:embedded-text number:position="{$text-pos}">
3851						<xsl:value-of select="substring( $adapted-number-format-unit, $first-embedded-text-pos + 1, 1)"/>
3852					</number:embedded-text>
3853					<xsl:call-template name="create-number-format-embedded-text">
3854						<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) )"/>
3855						<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
3856					</xsl:call-template>
3857				</xsl:when>
3858				<xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '_')">
3859					<number:embedded-text number:position="{$text-pos}">
3860						<xsl:value-of select="substring( $adapted-number-format-unit, $first-embedded-text-pos + 1, 1)"/>
3861					</number:embedded-text>
3862					<xsl:call-template name="create-number-format-embedded-text">
3863						<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) )"/>
3864						<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
3865					</xsl:call-template>
3866				</xsl:when>
3867				<xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '*')">
3868					<number:embedded-text number:position="{$text-pos}">
3869						<xsl:value-of select="substring( $adapted-number-format-unit, $first-embedded-text-pos + 1, 1)"/>
3870					</number:embedded-text>
3871					<xsl:call-template name="create-number-format-embedded-text">
3872						<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) )"/>
3873						<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
3874					</xsl:call-template>
3875				</xsl:when>
3876				<xsl:when test="starts-with( substring( $adapted-number-format-unit, $first-embedded-text-pos, 1), '&quot;')">
3877					<number:embedded-text number:position="{$text-pos}">
3878						<xsl:value-of select="substring-before( substring( $adapted-number-format-unit, $first-embedded-text-pos + 1), '&quot;')"/>
3879					</number:embedded-text>
3880					<xsl:call-template name="create-number-format-embedded-text">
3881						<xsl:with-param name="adapted-number-format-unit" select="concat( substring-before( $adapted-number-format-unit, '&quot;'), substring-after( substring-after( $adapted-number-format-unit, '&quot;'), '&quot;') )"/>
3882						<xsl:with-param name="valid-number-format-string" select="$valid-number-format-string"/>
3883					</xsl:call-template>
3884				</xsl:when>
3885			</xsl:choose>
3886		</xsl:if>
3887	</xsl:template>
3888	<xsl:template name="create-master-styles">
3889		<xsl:param name="worksheetoptions"/>
3890		<xsl:for-each select="$worksheetoptions">
3891			<xsl:element name="style:master-page">
3892				<xsl:attribute name="style:name">
3893					<xsl:call-template name="encode-as-nc-name">
3894						<xsl:with-param name="string" select="concat( 'TAB_', ../@ss:Name)"/>
3895					</xsl:call-template>
3896				</xsl:attribute>
3897				<xsl:attribute name="style:display-name">
3898					<xsl:value-of select="concat( 'PageStyle_', ../@ss:Name)"/>
3899				</xsl:attribute>
3900				<xsl:attribute name="style:page-layout-name">
3901					<xsl:call-template name="encode-as-nc-name">
3902						<xsl:with-param name="string" select="concat( 'pm_', ../@ss:Name)"/>
3903					</xsl:call-template>
3904				</xsl:attribute>
3905				<xsl:choose>
3906					<xsl:when test="x:PageSetup/x:Header/@x:Data">
3907						<style:header>
3908							<xsl:call-template name="translate-header-footer">
3909								<xsl:with-param name="content" select="x:PageSetup/x:Header/@x:Data"/>
3910								<xsl:with-param name="style-name-header" select="concat(../@ss:Name, substring(name(x:PageSetup/x:Header),1,1))"/>
3911							</xsl:call-template>
3912						</style:header>
3913					</xsl:when>
3914					<xsl:otherwise>
3915						<style:header style:display="false"/>
3916					</xsl:otherwise>
3917				</xsl:choose>
3918				<xsl:choose>
3919					<xsl:when test="x:PageSetup/x:Footer/@x:Data">
3920						<style:footer>
3921							<xsl:call-template name="translate-header-footer">
3922								<xsl:with-param name="content" select="x:PageSetup/x:Footer/@x:Data"/>
3923								<xsl:with-param name="style-name-header" select="concat(../@ss:Name, substring(name(x:PageSetup/x:Footer),1,1))"/>
3924							</xsl:call-template>
3925						</style:footer>
3926					</xsl:when>
3927					<xsl:otherwise>
3928						<style:footer style:display="false"/>
3929					</xsl:otherwise>
3930				</xsl:choose>
3931			</xsl:element>
3932		</xsl:for-each>
3933	</xsl:template>
3934	<xsl:template name="translate-header-footer">
3935		<xsl:param name="content"/>
3936		<xsl:param name="style-name-header"/>
3937		<style:region-left>
3938			<text:p>
3939				<xsl:variable name="left-content">
3940					<xsl:call-template name="get-pos-content">
3941						<xsl:with-param name="content" select="$content"/>
3942						<xsl:with-param name="pos" select="'left'"/>
3943					</xsl:call-template>
3944				</xsl:variable>
3945				<xsl:call-template name="locate-header-footer-data">
3946					<xsl:with-param name="header-footer-data" select="$left-content"/>
3947					<xsl:with-param name="style-name-header" select="concat($style-name-header,'L')"/>
3948					<xsl:with-param name="index" select="0"/>
3949					<xsl:with-param name="current-pos" select="1"/>
3950				</xsl:call-template>
3951			</text:p>
3952		</style:region-left>
3953		<style:region-center>
3954			<text:p>
3955				<xsl:variable name="center-content">
3956					<xsl:call-template name="get-pos-content">
3957						<xsl:with-param name="content" select="$content"/>
3958						<xsl:with-param name="pos" select="'center'"/>
3959					</xsl:call-template>
3960				</xsl:variable>
3961				<xsl:call-template name="locate-header-footer-data">
3962					<xsl:with-param name="header-footer-data" select="$center-content"/>
3963					<xsl:with-param name="style-name-header" select="concat($style-name-header,'C')"/>
3964					<xsl:with-param name="index" select="0"/>
3965					<xsl:with-param name="current-pos" select="1"/>
3966				</xsl:call-template>
3967			</text:p>
3968		</style:region-center>
3969		<style:region-right>
3970			<text:p>
3971				<xsl:variable name="right-content">
3972					<xsl:call-template name="get-pos-content">
3973						<xsl:with-param name="content" select="$content"/>
3974						<xsl:with-param name="pos" select="'right'"/>
3975					</xsl:call-template>
3976				</xsl:variable>
3977				<xsl:call-template name="locate-header-footer-data">
3978					<xsl:with-param name="header-footer-data" select="$right-content"/>
3979					<xsl:with-param name="style-name-header" select="concat($style-name-header,'R')"/>
3980					<xsl:with-param name="index" select="0"/>
3981					<xsl:with-param name="current-pos" select="1"/>
3982				</xsl:call-template>
3983			</text:p>
3984		</style:region-right>
3985	</xsl:template>
3986	<xsl:template name="locate-header-footer-data">
3987		<xsl:param name="header-footer-data"/>
3988		<xsl:param name="style-name-header"/>
3989		<xsl:param name="index"/>
3990		<xsl:param name="current-pos"/>
3991		<xsl:variable name="current-style-data">
3992			<xsl:value-of select="substring($header-footer-data,$current-pos)"/>
3993		</xsl:variable>
3994		<xsl:choose>
3995			<xsl:when test="starts-with($current-style-data,'&amp;X') or starts-with($current-style-data,'&amp;Y') or starts-with($current-style-data,'&amp;S') or starts-with($current-style-data,'&amp;U') or starts-with($current-style-data,'&amp;E') or starts-with($current-style-data,'&amp;B')">
3996				<xsl:call-template name="locate-header-footer-data">
3997					<xsl:with-param name="header-footer-data" select="$header-footer-data"/>
3998					<xsl:with-param name="style-name-header" select="$style-name-header"/>
3999					<xsl:with-param name="index" select="$index"/>
4000					<xsl:with-param name="current-pos" select="$current-pos+2"/>
4001				</xsl:call-template>
4002			</xsl:when>
4003			<xsl:when test="starts-with($current-style-data,'&amp;0') or starts-with($current-style-data,'&amp;1') or starts-with($current-style-data,'&amp;2') or starts-with($current-style-data,'&amp;3') or starts-with($current-style-data,'&amp;4') or starts-with($current-style-data,'&amp;5') or starts-with($current-style-data,'&amp;6') or starts-with($current-style-data,'&amp;7') or starts-with($current-style-data,'&amp;8') or starts-with($current-style-data,'&amp;9')">
4004				<xsl:variable name="font-size-length">
4005					<xsl:call-template name="get-digit-length">
4006						<xsl:with-param name="complexive-string" select="substring-after($current-style-data,'&amp;')"/>
4007					</xsl:call-template>
4008				</xsl:variable>
4009				<xsl:call-template name="locate-header-footer-data">
4010					<xsl:with-param name="header-footer-data" select="$header-footer-data"/>
4011					<xsl:with-param name="style-name-header" select="$style-name-header"/>
4012					<xsl:with-param name="index" select="$index"/>
4013					<xsl:with-param name="current-pos" select="$current-pos+1+$font-size-length"/>
4014				</xsl:call-template>
4015			</xsl:when>
4016			<xsl:when test="starts-with($current-style-data,'&amp;&quot;')">
4017				<xsl:call-template name="locate-header-footer-data">
4018					<xsl:with-param name="header-footer-data" select="$header-footer-data"/>
4019					<xsl:with-param name="style-name-header" select="$style-name-header"/>
4020					<xsl:with-param name="index" select="$index"/>
4021					<xsl:with-param name="current-pos" select="string-length(substring-before(substring($header-footer-data,$current-pos+2),'&quot;'))+$current-pos+3"/>
4022				</xsl:call-template>
4023			</xsl:when>
4024			<xsl:otherwise>
4025				<xsl:variable name="current-content-last-pos">
4026					<xsl:call-template name="get-current-content-last-pos">
4027						<xsl:with-param name="style-data" select="$header-footer-data"/>
4028						<xsl:with-param name="current-pos" select="$current-pos"/>
4029					</xsl:call-template>
4030				</xsl:variable>
4031				<xsl:choose>
4032					<xsl:when test="$current-pos &gt; 1">
4033						<text:span text:style-name="{concat($style-name-header,$index)}">
4034							<xsl:call-template name="translate-header-footer-data">
4035								<xsl:with-param name="header-footer-data" select="substring($header-footer-data,$current-pos,$current-content-last-pos+1-$current-pos)"/>
4036							</xsl:call-template>
4037						</text:span>
4038						<xsl:if test="$current-content-last-pos &lt; string-length($header-footer-data)">
4039							<xsl:call-template name="locate-header-footer-data">
4040								<xsl:with-param name="header-footer-data" select="$header-footer-data"/>
4041								<xsl:with-param name="style-name-header" select="$style-name-header"/>
4042								<xsl:with-param name="index" select="$index+1"/>
4043								<xsl:with-param name="current-pos" select="$current-content-last-pos+1"/>
4044							</xsl:call-template>
4045						</xsl:if>
4046					</xsl:when>
4047					<xsl:otherwise>
4048						<xsl:call-template name="translate-header-footer-data">
4049							<xsl:with-param name="header-footer-data" select="substring($header-footer-data,$current-pos,$current-content-last-pos+1-$current-pos)"/>
4050						</xsl:call-template>
4051						<xsl:if test="$current-content-last-pos &lt; string-length($header-footer-data)">
4052							<xsl:call-template name="locate-header-footer-data">
4053								<xsl:with-param name="header-footer-data" select="$header-footer-data"/>
4054								<xsl:with-param name="style-name-header" select="$style-name-header"/>
4055								<xsl:with-param name="index" select="$index"/>
4056								<xsl:with-param name="current-pos" select="$current-content-last-pos+1"/>
4057							</xsl:call-template>
4058						</xsl:if>
4059					</xsl:otherwise>
4060				</xsl:choose>
4061			</xsl:otherwise>
4062		</xsl:choose>
4063	</xsl:template>
4064	<xsl:template name="get-current-content-last-pos">
4065		<xsl:param name="style-data"/>
4066		<xsl:param name="current-pos"/>
4067		<xsl:variable name="current-style-data">
4068			<xsl:value-of select="substring($style-data,$current-pos)"/>
4069		</xsl:variable>
4070		<xsl:choose>
4071			<xsl:when test="starts-with($current-style-data,'&amp;&quot;') or starts-with($current-style-data,'&amp;X') or starts-with($current-style-data,'&amp;Y') or starts-with($current-style-data,'&amp;S') or starts-with($current-style-data,'&amp;U') or starts-with($current-style-data,'&amp;E') or starts-with($current-style-data,'&amp;B')or starts-with($current-style-data,'&amp;0') or starts-with($current-style-data,'&amp;1') or starts-with($current-style-data,'&amp;2') or starts-with($current-style-data,'&amp;3') or starts-with($current-style-data,'&amp;4') or starts-with($current-style-data,'&amp;5') or starts-with($current-style-data,'&amp;6') or starts-with($current-style-data,'&amp;7') or starts-with($current-style-data,'&amp;8') or starts-with($current-style-data,'&amp;9')">
4072				<xsl:value-of select="$current-pos - 1"/>
4073			</xsl:when>
4074			<xsl:when test="contains($current-style-data,'&amp;&quot;') or contains($current-style-data,'&amp;X') or contains($current-style-data,'&amp;Y') or contains($current-style-data,'&amp;S') or contains($current-style-data,'&amp;U') or contains($current-style-data,'&amp;E') or contains($current-style-data,'&amp;B')or contains($current-style-data,'&amp;0') or contains($current-style-data,'&amp;1') or contains($current-style-data,'&amp;2') or contains($current-style-data,'&amp;3') or contains($current-style-data,'&amp;4') or contains($current-style-data,'&amp;5') or contains($current-style-data,'&amp;6') or contains($current-style-data,'&amp;7') or contains($current-style-data,'&amp;8') or contains($current-style-data,'&amp;9')">
4075				<xsl:variable name="temp" select="substring-before(substring($current-style-data,2),'&amp;')"/>
4076				<xsl:variable name="next-amp-pos">
4077					<xsl:value-of select="$current-pos+string-length($temp)+1"/>
4078				</xsl:variable>
4079				<xsl:call-template name="get-current-content-last-pos">
4080					<xsl:with-param name="style-data" select="$style-data"/>
4081					<xsl:with-param name="current-pos" select="$next-amp-pos"/>
4082				</xsl:call-template>
4083			</xsl:when>
4084			<xsl:otherwise>
4085				<xsl:value-of select="string-length($style-data)"/>
4086			</xsl:otherwise>
4087		</xsl:choose>
4088	</xsl:template>
4089	<xsl:template name="translate-header-footer-data">
4090		<xsl:param name="header-footer-data"/>
4091		<xsl:choose>
4092			<xsl:when test="contains( $header-footer-data, '&amp;D')">
4093				<xsl:call-template name="translate-header-footer-data">
4094					<xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&amp;D')"/>
4095				</xsl:call-template>
4096				<text:date/>
4097				<xsl:call-template name="translate-header-footer-data">
4098					<xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&amp;D')"/>
4099				</xsl:call-template>
4100			</xsl:when>
4101			<xsl:when test="contains( $header-footer-data, '&amp;T')">
4102				<xsl:call-template name="translate-header-footer-data">
4103					<xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&amp;T')"/>
4104				</xsl:call-template>
4105				<text:time/>
4106				<xsl:call-template name="translate-header-footer-data">
4107					<xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&amp;T')"/>
4108				</xsl:call-template>
4109			</xsl:when>
4110			<xsl:when test="contains( $header-footer-data, '&amp;P')">
4111				<xsl:call-template name="translate-header-footer-data">
4112					<xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&amp;P')"/>
4113				</xsl:call-template>
4114				<text:page-number/>
4115				<xsl:call-template name="translate-header-footer-data">
4116					<xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&amp;P')"/>
4117				</xsl:call-template>
4118			</xsl:when>
4119			<xsl:when test="contains( $header-footer-data, '&amp;N')">
4120				<xsl:call-template name="translate-header-footer-data">
4121					<xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&amp;N')"/>
4122				</xsl:call-template>
4123				<text:page-count/>
4124				<xsl:call-template name="translate-header-footer-data">
4125					<xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&amp;N')"/>
4126				</xsl:call-template>
4127			</xsl:when>
4128			<xsl:when test="contains( $header-footer-data, '&amp;A')">
4129				<xsl:call-template name="translate-header-footer-data">
4130					<xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&amp;A')"/>
4131				</xsl:call-template>
4132				<text:sheet-name/>
4133				<xsl:call-template name="translate-header-footer-data">
4134					<xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&amp;A')"/>
4135				</xsl:call-template>
4136			</xsl:when>
4137			<xsl:when test="contains( $header-footer-data, '&amp;Z&amp;F')">
4138				<xsl:call-template name="translate-header-footer-data">
4139					<xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&amp;Z&amp;F')"/>
4140				</xsl:call-template>
4141				<text:file-name text:display="full"/>
4142				<xsl:call-template name="translate-header-footer-data">
4143					<xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&amp;Z&amp;F')"/>
4144				</xsl:call-template>
4145			</xsl:when>
4146			<xsl:when test="contains( $header-footer-data, '&amp;Z')">
4147				<xsl:call-template name="translate-header-footer-data">
4148					<xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&amp;Z')"/>
4149				</xsl:call-template>
4150				<text:file-name text:display="path"/>
4151				<xsl:call-template name="translate-header-footer-data">
4152					<xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&amp;Z')"/>
4153				</xsl:call-template>
4154			</xsl:when>
4155			<xsl:when test="contains( $header-footer-data, '&amp;F')">
4156				<xsl:call-template name="translate-header-footer-data">
4157					<xsl:with-param name="header-footer-data" select="substring-before( $header-footer-data, '&amp;F')"/>
4158				</xsl:call-template>
4159				<text:file-name text:display="name"/>
4160				<xsl:call-template name="translate-header-footer-data">
4161					<xsl:with-param name="header-footer-data" select="substring-after( $header-footer-data, '&amp;F')"/>
4162				</xsl:call-template>
4163			</xsl:when>
4164			<xsl:otherwise>
4165				<xsl:value-of select="$header-footer-data"/>
4166			</xsl:otherwise>
4167		</xsl:choose>
4168	</xsl:template>
4169	<xsl:template name="create-page-master">
4170		<xsl:param name="worksheetoptions"/>
4171		<xsl:for-each select="$worksheetoptions">
4172			<xsl:element name="style:page-layout">
4173				<xsl:attribute name="style:name">
4174					<xsl:call-template name="encode-as-nc-name">
4175						<xsl:with-param name="string" select="concat( 'pm_', ../@ss:Name)"/>
4176					</xsl:call-template>
4177				</xsl:attribute>
4178				<xsl:element name="style:page-layout-properties">
4179					<xsl:choose>
4180						<xsl:when test="x:PageSetup/x:Layout/@x:Orientation = 'Landscape'">
4181							<xsl:attribute name="style:print-orientation">landscape</xsl:attribute>
4182						</xsl:when>
4183						<xsl:otherwise>
4184							<xsl:attribute name="style:print-orientation">portrait</xsl:attribute>
4185						</xsl:otherwise>
4186					</xsl:choose>
4187					<xsl:choose>
4188						<xsl:when test="x:PageSetup/x:Layout/@x:StartPageNumber">
4189							<xsl:attribute name="style:first-page-number">
4190								<xsl:value-of select="x:PageSetup/x:Layout/@x:StartPageNumber"/>
4191							</xsl:attribute>
4192						</xsl:when>
4193						<xsl:otherwise>
4194							<xsl:attribute name="style:first-page-number">continue</xsl:attribute>
4195						</xsl:otherwise>
4196					</xsl:choose>
4197					<xsl:if test="x:PageSetup/x:PageMargins">
4198						<xsl:attribute name="fo:margin-top">
4199							<xsl:call-template name="convert2cm">
4200								<xsl:with-param name="value" select="concat(x:PageSetup/x:PageMargins/@x:Top,'pt')"/>
4201							</xsl:call-template>
4202							<xsl:text>cm</xsl:text>
4203						</xsl:attribute>
4204						<xsl:attribute name="fo:margin-bottom">
4205							<xsl:call-template name="convert2cm">
4206								<xsl:with-param name="value" select="concat(x:PageSetup/x:PageMargins/@x:Bottom,'pt')"/>
4207							</xsl:call-template>
4208							<xsl:text>cm</xsl:text>
4209						</xsl:attribute>
4210						<xsl:attribute name="fo:margin-left">
4211							<xsl:call-template name="convert2cm">
4212								<xsl:with-param name="value" select="concat(x:PageSetup/x:PageMargins/@x:Left,'pt')"/>
4213							</xsl:call-template>
4214							<xsl:text>cm</xsl:text>
4215						</xsl:attribute>
4216						<xsl:attribute name="fo:margin-right">
4217							<xsl:call-template name="convert2cm">
4218								<xsl:with-param name="value" select="concat(x:PageSetup/x:PageMargins/@x:Right,'pt')"/>
4219							</xsl:call-template>
4220							<xsl:text>cm</xsl:text>
4221						</xsl:attribute>
4222					</xsl:if>
4223				</xsl:element>
4224				<xsl:if test="x:PageSetup/x:Header">
4225					<style:header-style>
4226						<xsl:element name="style:header-footer-properties">
4227							<xsl:attribute name="fo:min-height">0.75cm</xsl:attribute>
4228							<xsl:choose>
4229								<xsl:when test="x:PageSetup/x:Header/@x:Margin">
4230									<xsl:attribute name="fo:margin-bottom">
4231										<xsl:call-template name="convert2cm">
4232											<xsl:with-param name="value" select="concat(x:PageSetup/x:Header/@x:Margin,'pt')"/>
4233										</xsl:call-template>
4234										<xsl:text>cm</xsl:text>
4235									</xsl:attribute>
4236								</xsl:when>
4237								<xsl:otherwise>
4238									<xsl:attribute name="fo:margin-bottom">0.25cm</xsl:attribute>
4239								</xsl:otherwise>
4240							</xsl:choose>
4241						</xsl:element>
4242					</style:header-style>
4243				</xsl:if>
4244				<xsl:if test="x:PageSetup/x:Footer">
4245					<style:footer-style>
4246						<xsl:element name="style:header-footer-properties">
4247							<xsl:attribute name="fo:min-height">0.75cm</xsl:attribute>
4248							<xsl:choose>
4249								<xsl:when test="x:PageSetup/x:Footer/@x:Margin">
4250									<xsl:attribute name="fo:margin-top">
4251										<xsl:call-template name="convert2cm">
4252											<xsl:with-param name="value" select="concat(x:PageSetup/x:Footer/@x:Margin,'pt')"/>
4253										</xsl:call-template>
4254										<xsl:text>cm</xsl:text>
4255									</xsl:attribute>
4256								</xsl:when>
4257								<xsl:otherwise>
4258									<xsl:attribute name="fo:margin-top">0.25cm</xsl:attribute>
4259								</xsl:otherwise>
4260							</xsl:choose>
4261						</xsl:element>
4262					</style:footer-style>
4263				</xsl:if>
4264			</xsl:element>
4265		</xsl:for-each>
4266	</xsl:template>
4267	<xsl:template match="ss:Style" name="style-style-content" mode="style-style-content">
4268		<xsl:element name="style:table-cell-properties">
4269			<xsl:if test="ss:Alignment">
4270				<xsl:if test="ss:Alignment/@ss:Vertical">
4271					<xsl:variable name="vertical-align">
4272						<xsl:choose>
4273							<xsl:when test="ss:Alignment/@ss:Vertical = 'Top'">top</xsl:when>
4274							<xsl:when test="ss:Alignment/@ss:Vertical = 'Center'">middle</xsl:when>
4275							<xsl:when test="ss:Alignment/@ss:Vertical = 'Bottom'">bottom</xsl:when>
4276							<xsl:when test="ss:Alignment/@ss:Vertical = 'Automatic'">middle</xsl:when>
4277							<!-- actually for vertical writen characters, not supported by StarOffice/OpenOffice now yet -->
4278							<xsl:otherwise>middle</xsl:otherwise>
4279						</xsl:choose>
4280					</xsl:variable>
4281					<xsl:attribute name="style:vertical-align">
4282						<xsl:value-of select="$vertical-align"/>
4283					</xsl:attribute>
4284				</xsl:if>
4285				<xsl:if test="ss:Alignment/@ss:WrapText = '1'">
4286					<xsl:attribute name="fo:wrap-option">wrap</xsl:attribute>
4287				</xsl:if>
4288				<xsl:if test="ss:Alignment/@ss:Indent">
4289					<xsl:attribute name="fo:padding-left"><!-- Indent is ten times of a point -->
4290						<xsl:variable name="indent" select="ss:Alignment/@ss:Indent * 10"/>
4291						<xsl:call-template name="convert2cm">
4292							<xsl:with-param name="value" select="concat($indent,'pt')"/>
4293						</xsl:call-template>
4294						<xsl:text>cm</xsl:text>
4295					</xsl:attribute>
4296				</xsl:if>
4297				<xsl:if test="ss:Alignment/@ss:Rotate">
4298					<xsl:attribute name="style:rotation-angle">
4299						<xsl:choose>
4300							<xsl:when test="ss:Alignment/@ss:Rotate &lt; 0">
4301								<xsl:value-of select="360 + ss:Alignment/@ss:Rotate"/>
4302							</xsl:when>
4303							<xsl:otherwise>
4304								<xsl:value-of select="ss:Alignment/@ss:Rotate"/>
4305							</xsl:otherwise>
4306						</xsl:choose>
4307					</xsl:attribute>
4308					<xsl:attribute name="style:rotation-align">none</xsl:attribute>
4309				</xsl:if>
4310				<xsl:if test="ss:Alignment/@ss:VerticalText = '1'">
4311					<xsl:attribute name="style:direction">ttb</xsl:attribute>
4312					<!-- The horizontal align default for vertical text in Excel is 'center' -->
4313					<xsl:if test="not(ss:Alignment/@ss:Horizontal)">
4314						<!-- OASIS XML removal
4315						<xsl:attribute name="fo:text-align">center</xsl:attribute>-->
4316						<xsl:attribute name="style:text-align-source">fix</xsl:attribute>
4317					</xsl:if>
4318				</xsl:if>
4319			</xsl:if>
4320			<xsl:if test="ss:Borders">
4321				<xsl:if test="ss:Borders/ss:Border">
4322					<xsl:apply-templates select="ss:Borders/ss:Border"/>
4323				</xsl:if>
4324			</xsl:if>
4325			<xsl:apply-templates select="ss:Interior" mode="style-style-content"/>
4326			<xsl:if test="ss:Protection">
4327				<xsl:choose>
4328					<xsl:when test="ss:Protection/@ss:Protected = '0'">
4329						<xsl:choose>
4330							<xsl:when test="ss:Protection/@ss:HideFormula = '1'">
4331								<xsl:attribute name="style:cell-protect">hidden-and-protected</xsl:attribute>
4332							</xsl:when>
4333							<xsl:otherwise>
4334								<xsl:attribute name="style:cell-protect">none</xsl:attribute>
4335							</xsl:otherwise>
4336						</xsl:choose>
4337					</xsl:when>
4338					<xsl:otherwise>
4339						<xsl:choose>
4340							<xsl:when test="ss:Protection/@x:HideFormula = '1'">
4341								<xsl:attribute name="style:cell-protect">protected formula-hidden</xsl:attribute>
4342							</xsl:when>
4343							<xsl:otherwise>
4344								<xsl:attribute name="style:cell-protect">none</xsl:attribute>
4345							</xsl:otherwise>
4346						</xsl:choose>
4347					</xsl:otherwise>
4348				</xsl:choose>
4349			</xsl:if>
4350			<!-- fix means the horizontal alignment is dependent on ss:Horizontal,
4351				 but set on paragaraph properties not cell paragraphs -->
4352			<xsl:if test="ss:Alignment/@ss:Horizontal">
4353				<xsl:attribute name="style:text-align-source">fix</xsl:attribute>
4354			</xsl:if>
4355		</xsl:element>
4356		<xsl:choose>
4357			<xsl:when test="ss:Alignment/@ss:Horizontal">
4358				<xsl:element name="style:paragraph-properties">
4359					<xsl:variable name="text-align">
4360						<xsl:choose>
4361							<xsl:when test="ss:Alignment/@ss:Horizontal = 'Left'">start</xsl:when>
4362							<xsl:when test="ss:Alignment/@ss:Horizontal = 'Center'">center</xsl:when>
4363							<xsl:when test="ss:Alignment/@ss:Horizontal = 'Right'">end</xsl:when>
4364							<xsl:when test="ss:Alignment/@ss:Horizontal = 'Justify'">justify</xsl:when>
4365							<!-- many other text-align not supported yet -->
4366							<xsl:otherwise>start</xsl:otherwise>
4367						</xsl:choose>
4368					</xsl:variable>
4369					<xsl:attribute name="fo:text-align">
4370						<xsl:value-of select="$text-align"/>
4371					</xsl:attribute>
4372				</xsl:element>
4373			</xsl:when>
4374			<xsl:otherwise>
4375				<!-- The horizontal align default for vertical text in Excel is 'center' -->
4376				<xsl:element name="style:paragraph-properties">
4377					<xsl:if test="ss:Alignment/@ss:VerticalText = '1'">
4378						<xsl:attribute name="fo:text-align">center</xsl:attribute>
4379					</xsl:if>
4380				</xsl:element>
4381			</xsl:otherwise>
4382		</xsl:choose>
4383		<xsl:if test="ss:Font">
4384			<xsl:element name="style:text-properties">
4385				<xsl:choose>
4386					<xsl:when test="ss:Font/@ss:FontName">
4387						<xsl:attribute name="style:font-name">
4388							<xsl:value-of select="ss:Font/@ss:FontName"/>
4389						</xsl:attribute>
4390						<xsl:attribute name="style:font-name-asian">
4391							<xsl:value-of select="ss:Font/@ss:FontName"/>
4392						</xsl:attribute>
4393						<xsl:attribute name="style:font-name-complex">
4394							<xsl:value-of select="ss:Font/@ss:FontName"/>
4395						</xsl:attribute>
4396					</xsl:when>
4397					<xsl:otherwise>
4398						<xsl:attribute name="style:font-name">Arial</xsl:attribute>
4399					</xsl:otherwise>
4400				</xsl:choose>
4401				<!-- "ss:Font/@x:Family" is useless here, so can't map to "svg:font-family" attribute -->
4402				<xsl:if test="ss:Font/@ss:Bold = '1'">
4403					<xsl:attribute name="fo:font-weight">bold</xsl:attribute>
4404					<xsl:attribute name="style:font-weight-asian">bold</xsl:attribute>
4405					<xsl:attribute name="style:font-weight-complex">bold</xsl:attribute>
4406				</xsl:if>
4407				<xsl:choose>
4408					<xsl:when test="ss:Font/@ss:Color">
4409						<xsl:attribute name="fo:color">
4410							<xsl:value-of select="ss:Font/@ss:Color"/>
4411						</xsl:attribute>
4412					</xsl:when>
4413					<xsl:otherwise>
4414						<xsl:attribute name="style:use-window-font-color">true</xsl:attribute>
4415					</xsl:otherwise>
4416				</xsl:choose>
4417				<xsl:if test="ss:Font/@ss:Italic = '1'">
4418					<!-- omit font-style oblique -->
4419					<xsl:attribute name="fo:font-style">italic</xsl:attribute>
4420					<xsl:attribute name="style:font-style-asian">italic</xsl:attribute>
4421					<xsl:attribute name="style:font-style-complex">italic</xsl:attribute>
4422				</xsl:if>
4423				<xsl:choose>
4424					<xsl:when test="ss:Font/@ss:Size">
4425						<xsl:attribute name="fo:font-size">
4426							<xsl:value-of select="concat( ss:Font/@ss:Size, 'pt')"/>
4427						</xsl:attribute>
4428						<xsl:attribute name="style:font-size-asian">
4429							<xsl:value-of select="concat( ss:Font/@ss:Size, 'pt')"/>
4430						</xsl:attribute>
4431						<xsl:attribute name="style:font-size-complex">
4432							<xsl:value-of select="concat( ss:Font/@ss:Size, 'pt')"/>
4433						</xsl:attribute>
4434					</xsl:when>
4435					<xsl:otherwise>
4436						<xsl:attribute name="fo:font-size">10pt</xsl:attribute>
4437						<xsl:attribute name="style:font-size-asian">10pt</xsl:attribute>
4438						<xsl:attribute name="style:font-size-complex">10pt</xsl:attribute>
4439					</xsl:otherwise>
4440				</xsl:choose>
4441				<xsl:if test="ss:Font/@ss:Outline = '1'">
4442					<xsl:attribute name="style:text-outline">true</xsl:attribute>
4443				</xsl:if>
4444				<xsl:if test="ss:Font/@ss:Shadow = '1'">
4445					<!-- Not in DTD nor in docu <xsl:attribute name="style:text-shadow">shadow</xsl:attribute> -->
4446					<xsl:attribute name="fo:text-shadow">1pt 1pt</xsl:attribute>
4447				</xsl:if>
4448				<xsl:if test="ss:Font/@ss:StrikeThrough = '1'">
4449					<xsl:attribute name="style:text-line-through-style">solid</xsl:attribute>
4450				</xsl:if>
4451				<xsl:if test="ss:Font/@ss:Underline">
4452					<xsl:choose>
4453						<xsl:when test="ss:Font/@ss:Underline = 'None'">
4454							<xsl:attribute name="style:text-underline-type">none</xsl:attribute>
4455						</xsl:when>
4456						<xsl:when test="ss:Font/@ss:Underline = 'Single'">
4457							<xsl:attribute name="style:text-underline-type">single</xsl:attribute>
4458						</xsl:when>
4459						<xsl:when test="ss:Font/@ss:Underline = 'Double'">
4460							<xsl:attribute name="style:text-underline-type">double</xsl:attribute>
4461						</xsl:when>
4462						<xsl:when test="ss:Font/@ss:Underline = 'SingleAccounting'">
4463							<xsl:attribute name="style:text-underline-type">single</xsl:attribute>"</xsl:when>
4464						<xsl:when test="ss:Font/@ss:Underline = 'DoubleAccounting'">
4465							<xsl:attribute name="style:text-underline-type">double</xsl:attribute>
4466						</xsl:when>
4467						<xsl:otherwise>
4468							<xsl:attribute name="style:text-underline-type">none</xsl:attribute>
4469						</xsl:otherwise>
4470					</xsl:choose>
4471				</xsl:if>
4472				<xsl:if test="ss:Font/@x:Charset">
4473					<!-- quite unclear till now, -->
4474					<xsl:attribute name="style:font-charset">x-symbol</xsl:attribute>
4475				</xsl:if>
4476			</xsl:element>
4477		</xsl:if>
4478	</xsl:template>
4479
4480	<xsl:template match="ss:Interior" mode="style-style-content">
4481		<xsl:choose>
4482			<xsl:when test="@ss:Pattern = 'Solid'">
4483				<xsl:if test="@ss:Color">
4484					<xsl:attribute name="fo:background-color">
4485						<xsl:value-of select="@ss:Color"/>
4486					</xsl:attribute>
4487				</xsl:if>
4488			</xsl:when>
4489			<xsl:otherwise>
4490				<xsl:if test="@ss:PatternColor">
4491					<xsl:variable name="pattern-value">
4492						<xsl:call-template name="cell-pattern-color">
4493							<xsl:with-param name="pattern" select="concat('0.',substring-after(@ss:Pattern,'y'))"/>
4494							<xsl:with-param name="color-value" select="@ss:Color"/>
4495							<xsl:with-param name="pattern-color-value" select="@ss:PatternColor"/>
4496						</xsl:call-template>
4497					</xsl:variable>
4498					<xsl:attribute name="fo:background-color">
4499						<xsl:value-of select="$pattern-value"/>
4500					</xsl:attribute>
4501				</xsl:if>
4502			</xsl:otherwise>
4503		</xsl:choose>
4504	</xsl:template>
4505
4506
4507	<xsl:template match="ss:Style">
4508		<!-- style:default-style is meant for application defaults
4509		<xsl:when test="@ss:ID = 'Default'">
4510			<xsl:element name="style:default-style">
4511				<xsl:call-template name="style-style-content" />
4512			</xsl:element>
4513		</xsl:when> -->
4514		<xsl:element name="style:style">
4515			<xsl:attribute name="style:name">
4516				<xsl:value-of select="@ss:ID"/>
4517			</xsl:attribute>
4518			<xsl:apply-templates select="@ss:Name" />
4519			<xsl:choose>
4520				<xsl:when test="@ss:Parent">
4521					<xsl:attribute name="style:parent-style-name">
4522						<xsl:value-of select="@ss:Parent"/>
4523					</xsl:attribute>
4524				</xsl:when>
4525				<!-- no parent, but automatic style are automatically inheriting from a style called 'Default'
4526					not necessary named style -->
4527				<xsl:when test="not(key('Style', @ss:ID)/@ss:Name)">
4528					<xsl:attribute name="style:parent-style-name">
4529						<xsl:text>Default</xsl:text>
4530					</xsl:attribute>
4531				</xsl:when>
4532			</xsl:choose>
4533			<xsl:if test="ss:NumberFormat/@ss:Format">
4534				<xsl:attribute name="style:data-style-name">
4535					<xsl:value-of select="concat( @ss:ID, 'F')"/>
4536				</xsl:attribute>
4537			</xsl:if>
4538			<xsl:attribute name="style:family">table-cell</xsl:attribute>
4539			<xsl:call-template name="style-style-content"/>
4540		</xsl:element>
4541	</xsl:template>
4542	<xsl:template name="cell-pattern-color">
4543		<!-- generates a new color from cell-pattern-color -->
4544		<xsl:param name="pattern"/>
4545		<xsl:param name="color-value"/>
4546		<xsl:param name="pattern-color-value"/>
4547		<xsl:variable name="rev-pattern" select="1 - $pattern"/>
4548		<xsl:variable name="color-R-value">
4549			<xsl:call-template name="hex2decimal">
4550				<xsl:with-param name="hex-number" select="substring($color-value,2,2)"/>
4551				<xsl:with-param name="index" select="1"/>
4552				<xsl:with-param name="str-length" select="2"/>
4553				<xsl:with-param name="last-value" select="0"/>
4554			</xsl:call-template>
4555		</xsl:variable>
4556		<xsl:variable name="color-G-value">
4557			<xsl:call-template name="hex2decimal">
4558				<xsl:with-param name="hex-number" select="substring($color-value,4,2)"/>
4559				<xsl:with-param name="index" select="1"/>
4560				<xsl:with-param name="str-length" select="2"/>
4561				<xsl:with-param name="last-value" select="0"/>
4562			</xsl:call-template>
4563		</xsl:variable>
4564		<xsl:variable name="color-B-value">
4565			<xsl:call-template name="hex2decimal">
4566				<xsl:with-param name="hex-number" select="substring($color-value,6,2)"/>
4567				<xsl:with-param name="index" select="1"/>
4568				<xsl:with-param name="str-length" select="2"/>
4569				<xsl:with-param name="last-value" select="0"/>
4570			</xsl:call-template>
4571		</xsl:variable>
4572		<xsl:variable name="pattern-R-value">
4573			<xsl:call-template name="hex2decimal">
4574				<xsl:with-param name="hex-number" select="substring($pattern-color-value,2,2)"/>
4575				<xsl:with-param name="index" select="1"/>
4576				<xsl:with-param name="str-length" select="2"/>
4577				<xsl:with-param name="last-value" select="0"/>
4578			</xsl:call-template>
4579		</xsl:variable>
4580		<xsl:variable name="pattern-G-value">
4581			<xsl:call-template name="hex2decimal">
4582				<xsl:with-param name="hex-number" select="substring($pattern-color-value,4,2)"/>
4583				<xsl:with-param name="index" select="1"/>
4584				<xsl:with-param name="str-length" select="2"/>
4585				<xsl:with-param name="last-value" select="0"/>
4586			</xsl:call-template>
4587		</xsl:variable>
4588		<xsl:variable name="pattern-B-value">
4589			<xsl:call-template name="hex2decimal">
4590				<xsl:with-param name="hex-number" select="substring($pattern-color-value,6,2)"/>
4591				<xsl:with-param name="index" select="1"/>
4592				<xsl:with-param name="str-length" select="2"/>
4593				<xsl:with-param name="last-value" select="0"/>
4594			</xsl:call-template>
4595		</xsl:variable>
4596		<xsl:variable name="R-value">
4597			<xsl:variable name="combined-R-value">
4598				<xsl:call-template name="decimal2hex">
4599					<xsl:with-param name="dec-number" select="floor($color-R-value * $rev-pattern + $pattern-R-value * $pattern)"/>
4600					<xsl:with-param name="last-value" select="'H'"/>
4601				</xsl:call-template>
4602			</xsl:variable>
4603			<xsl:choose>
4604				<xsl:when test="string-length($combined-R-value) = 1">
4605					<xsl:value-of select="concat('0',$combined-R-value)"/>
4606				</xsl:when>
4607				<xsl:otherwise>
4608					<xsl:value-of select="$combined-R-value"/>
4609				</xsl:otherwise>
4610			</xsl:choose>
4611		</xsl:variable>
4612		<xsl:variable name="G-value">
4613			<xsl:variable name="combined-G-value">
4614				<xsl:call-template name="decimal2hex">
4615					<xsl:with-param name="dec-number" select="floor($color-G-value * $rev-pattern + $pattern-G-value * $pattern)"/>
4616					<xsl:with-param name="last-value" select="'H'"/>
4617				</xsl:call-template>
4618			</xsl:variable>
4619			<xsl:choose>
4620				<xsl:when test="string-length($combined-G-value) = 1">
4621					<xsl:value-of select="concat('0',$combined-G-value)"/>
4622				</xsl:when>
4623				<xsl:otherwise>
4624					<xsl:value-of select="$combined-G-value"/>
4625				</xsl:otherwise>
4626			</xsl:choose>
4627		</xsl:variable>
4628		<xsl:variable name="B-value">
4629			<xsl:variable name="combined-B-value">
4630				<xsl:call-template name="decimal2hex">
4631					<xsl:with-param name="dec-number" select="floor($color-B-value * $rev-pattern + $pattern-B-value * $pattern)"/>
4632					<xsl:with-param name="last-value" select="'H'"/>
4633				</xsl:call-template>
4634			</xsl:variable>
4635			<xsl:choose>
4636				<xsl:when test="string-length($combined-B-value) = 1">
4637					<xsl:value-of select="concat('0',$combined-B-value)"/>
4638				</xsl:when>
4639				<xsl:otherwise>
4640					<xsl:value-of select="$combined-B-value"/>
4641				</xsl:otherwise>
4642			</xsl:choose>
4643		</xsl:variable>
4644		<xsl:value-of select="concat('#',$R-value,$G-value,$B-value)"/>
4645	</xsl:template>
4646    <xsl:template name="colorindex2decimal">
4647        <xsl:param name="colorindex"/>
4648        <xsl:variable name="colorIndexLookup">
4649            <xsl:value-of select="$colorindex - 8"/>
4650        </xsl:variable>
4651        <xsl:variable name="tempColorValue">
4652            <xsl:choose>
4653                <!-- Grab the color from the custom color index if it exists... -->
4654                <xsl:when test="/ss:Workbook/o:OfficeDocumentSettings/o:Colors/o:Color/o:Index=$colorIndexLookup">
4655                    <xsl:value-of select="substring-after(normalize-space(/ss:Workbook/o:OfficeDocumentSettings/o:Colors/o:Color/o:RGB[/ss:Workbook/o:OfficeDocumentSettings/o:Colors/o:Color/o:Index=$colorIndexLookup]), '#')"/>
4656                </xsl:when >
4657                <xsl:otherwise>
4658                    <xsl:choose>
4659                        <xsl:when test="$colorindex=8">
4660                            <xsl:value-of select="'000000'"/>
4661                        </xsl:when>
4662                        <xsl:when test="$colorindex=9">
4663                            <xsl:value-of select="'FFFFFF'"/>
4664                        </xsl:when>
4665                        <xsl:when test="$colorindex=10">
4666                            <xsl:value-of select="'FF0000'"/>
4667                        </xsl:when>
4668                        <xsl:when test="$colorindex=11">
4669                            <xsl:value-of select="'00FF00'"/>
4670                        </xsl:when>
4671                        <xsl:when test="$colorindex=12">
4672                            <xsl:value-of select="'0000FF'"/>
4673                        </xsl:when>
4674                        <xsl:when test="$colorindex=13">
4675                            <xsl:value-of select="'FFFF00'"/>
4676                        </xsl:when>
4677                        <xsl:when test="$colorindex=14">
4678                            <xsl:value-of select="'FF00FF'"/>
4679                        </xsl:when>
4680                        <xsl:when test="$colorindex=15">
4681                            <xsl:value-of select="'00FFFF'"/>
4682                        </xsl:when>
4683                        <xsl:when test="$colorindex=16">
4684                            <xsl:value-of select="'800000'"/>
4685                        </xsl:when>
4686                        <xsl:when test="$colorindex=17">
4687                            <xsl:value-of select="'008000'"/>
4688                        </xsl:when>
4689                        <xsl:when test="$colorindex=18">
4690                            <xsl:value-of select="'000080'"/>
4691                        </xsl:when>
4692                        <xsl:when test="$colorindex=19">
4693                            <xsl:value-of select="'808000'"/>
4694                        </xsl:when>
4695                        <xsl:when test="$colorindex=20">
4696                            <xsl:value-of select="'800080'"/>
4697                        </xsl:when>
4698                        <xsl:when test="$colorindex=21">
4699                            <xsl:value-of select="'008080'"/>
4700                        </xsl:when>
4701                        <xsl:when test="$colorindex=22">
4702                            <xsl:value-of select="'C0C0C0'"/>
4703                        </xsl:when>
4704                        <xsl:when test="$colorindex=23">
4705                            <xsl:value-of select="'808080'"/>
4706                        </xsl:when>
4707                        <xsl:when test="$colorindex=24">
4708                            <xsl:value-of select="'9999FF'"/>
4709                        </xsl:when>
4710                        <xsl:when test="$colorindex=25">
4711                            <xsl:value-of select="'993366'"/>
4712                        </xsl:when>
4713                        <xsl:when test="$colorindex=26">
4714                            <xsl:value-of select="'FFFFCC'"/>
4715                        </xsl:when>
4716                        <xsl:when test="$colorindex=27">
4717                            <xsl:value-of select="'CCFFFF'"/>
4718                        </xsl:when>
4719                        <xsl:when test="$colorindex=28">
4720                            <xsl:value-of select="'660066'"/>
4721                        </xsl:when>
4722                        <xsl:when test="$colorindex=29">
4723                            <xsl:value-of select="'FF8080'"/>
4724                        </xsl:when>
4725                        <xsl:when test="$colorindex=30">
4726                            <xsl:value-of select="'0066CC'"/>
4727                        </xsl:when>
4728                        <xsl:when test="$colorindex=31">
4729                            <xsl:value-of select="'CCCCFF'"/>
4730                        </xsl:when>
4731                        <xsl:when test="$colorindex=32">
4732                            <xsl:value-of select="'000080'"/>
4733                        </xsl:when>
4734                        <xsl:when test="$colorindex=33">
4735                            <xsl:value-of select="'FF00FF'"/>
4736                        </xsl:when>
4737                        <xsl:when test="$colorindex=34">
4738                            <xsl:value-of select="'FFFF00'"/>
4739                        </xsl:when>
4740                        <xsl:when test="$colorindex=35">
4741                            <xsl:value-of select="'00FFFF'"/>
4742                        </xsl:when>
4743                        <xsl:when test="$colorindex=36">
4744                            <xsl:value-of select="'800080'"/>
4745                        </xsl:when>
4746                        <xsl:when test="$colorindex=37">
4747                            <xsl:value-of select="'800000'"/>
4748                        </xsl:when>
4749                        <xsl:when test="$colorindex=38">
4750                            <xsl:value-of select="'008080'"/>
4751                        </xsl:when>
4752                        <xsl:when test="$colorindex=39">
4753                            <xsl:value-of select="'0000FF'"/>
4754                        </xsl:when>
4755                        <xsl:when test="$colorindex=40">
4756                            <xsl:value-of select="'00CCFF'"/>
4757                        </xsl:when>
4758                        <xsl:when test="$colorindex=41">
4759                            <xsl:value-of select="'CCFFFF'"/>
4760                        </xsl:when>
4761                        <xsl:when test="$colorindex=42">
4762                            <xsl:value-of select="'CCFFCC'"/>
4763                        </xsl:when>
4764                        <xsl:when test="$colorindex=43">
4765                            <xsl:value-of select="'FFFF99'"/>
4766                        </xsl:when>
4767                        <xsl:when test="$colorindex=44">
4768                            <xsl:value-of select="'99CCFF'"/>
4769                        </xsl:when>
4770                        <xsl:when test="$colorindex=45">
4771                            <xsl:value-of select="'FF99CC'"/>
4772                        </xsl:when>
4773                        <xsl:when test="$colorindex=46">
4774                            <xsl:value-of select="'CC99FF'"/>
4775                        </xsl:when>
4776                        <xsl:when test="$colorindex=47">
4777                            <xsl:value-of select="'FFCC99'"/>
4778                        </xsl:when>
4779                        <xsl:when test="$colorindex=48">
4780                            <xsl:value-of select="'3366FF'"/>
4781                        </xsl:when>
4782                        <xsl:when test="$colorindex=49">
4783                            <xsl:value-of select="'33CCCC'"/>
4784                        </xsl:when>
4785                        <xsl:when test="$colorindex=50">
4786                            <xsl:value-of select="'99CC00'"/>
4787                        </xsl:when>
4788                        <xsl:when test="$colorindex=51">
4789                            <xsl:value-of select="'FFCC00'"/>
4790                        </xsl:when>
4791                        <xsl:when test="$colorindex=52">
4792                            <xsl:value-of select="'FF9900'"/>
4793                        </xsl:when>
4794                        <xsl:when test="$colorindex=53">
4795                            <xsl:value-of select="'FF6600'"/>
4796                        </xsl:when>
4797                        <xsl:when test="$colorindex=54">
4798                            <xsl:value-of select="'666699'"/>
4799                        </xsl:when>
4800                        <xsl:when test="$colorindex=55">
4801                            <xsl:value-of select="'969696'"/>
4802                        </xsl:when>
4803                        <xsl:when test="$colorindex=56">
4804                            <xsl:value-of select="'003366'"/>
4805                        </xsl:when>
4806                        <xsl:when test="$colorindex=57">
4807                            <xsl:value-of select="'339966'"/>
4808                        </xsl:when>
4809                        <xsl:when test="$colorindex=58">
4810                            <xsl:value-of select="'003300'"/>
4811                        </xsl:when>
4812                        <xsl:when test="$colorindex=59">
4813                            <xsl:value-of select="'333300'"/>
4814                        </xsl:when>
4815                        <xsl:when test="$colorindex=60">
4816                            <xsl:value-of select="'993300'"/>
4817                        </xsl:when>
4818                        <xsl:when test="$colorindex=61">
4819                            <xsl:value-of select="'993366'"/>
4820                        </xsl:when>
4821                        <xsl:when test="$colorindex=62">
4822                            <xsl:value-of select="'333399'"/>
4823                        </xsl:when>
4824                        <xsl:when test="$colorindex=63">
4825                            <xsl:value-of select="'333333'"/>
4826                        </xsl:when>
4827                        <xsl:otherwise>
4828                            <xsl:value-of select="'NOTFOUND'"/>
4829                        </xsl:otherwise>
4830                    </xsl:choose>
4831                </xsl:otherwise>
4832            </xsl:choose>
4833        </xsl:variable>
4834        <xsl:variable name="tempColorDecimal">
4835            <xsl:choose>
4836                    <xsl:when test="not($tempColorValue = 'NOTFOUND')">
4837                        <xsl:call-template name="hex2decimal">
4838                            <xsl:with-param name="hex-number" select="$tempColorValue"/>
4839                            <xsl:with-param name="index" select="1"/>
4840                            <xsl:with-param name="str-length" select="6"/>
4841                            <xsl:with-param name="last-value" select="0"/>
4842                        </xsl:call-template>
4843                    </xsl:when>
4844                    <xsl:otherwise>
4845                        <xsl:value-of select="4294967295"/>
4846                    </xsl:otherwise>
4847            </xsl:choose>
4848        </xsl:variable>
4849        <xsl:value-of select="$tempColorDecimal"/>
4850    </xsl:template>
4851	<xsl:template name="hex2decimal">
4852		<!-- transforms a hex number to a decimal number.parses the string from left to right -->
4853		<xsl:param name="hex-number"/>
4854		<xsl:param name="index"/>
4855		<xsl:param name="str-length"/>
4856		<xsl:param name="last-value"/>
4857		<xsl:variable name="dec-char">
4858			<xsl:call-template name="hexNumber2dec">
4859				<xsl:with-param name="hex-value" select="substring($hex-number, $index ,1)"/>
4860			</xsl:call-template>
4861		</xsl:variable>
4862		<xsl:variable name="current-value" select="$last-value * 16 + $dec-char"/>
4863		<xsl:if test="$index &lt; $str-length">
4864			<xsl:call-template name="hex2decimal">
4865				<xsl:with-param name="hex-number" select="$hex-number"/>
4866				<xsl:with-param name="index" select="$index + 1"/>
4867				<xsl:with-param name="str-length" select="$str-length"/>
4868				<xsl:with-param name="last-value" select="$current-value"/>
4869			</xsl:call-template>
4870		</xsl:if>
4871		<xsl:if test="$index = $str-length">
4872			<xsl:value-of select="$current-value"/>
4873		</xsl:if>
4874	</xsl:template>
4875	<xsl:template name="hexNumber2dec">
4876		<!-- return a decimal number for a hex character -->
4877		<xsl:param name="hex-value"/>
4878		<xsl:choose>
4879			<xsl:when test="$hex-value = 'A' or ($hex-value = 'a')">
4880				<xsl:value-of select="10"/>
4881			</xsl:when>
4882			<xsl:when test="$hex-value = 'B' or ($hex-value = 'b')">
4883				<xsl:value-of select="11"/>
4884			</xsl:when>
4885			<xsl:when test="$hex-value = 'C' or ($hex-value = 'c')">
4886				<xsl:value-of select="12"/>
4887			</xsl:when>
4888			<xsl:when test="$hex-value = 'D' or ($hex-value = 'd')">
4889				<xsl:value-of select="13"/>
4890			</xsl:when>
4891			<xsl:when test="$hex-value = 'E' or ($hex-value = 'e')">
4892				<xsl:value-of select="14"/>
4893			</xsl:when>
4894			<xsl:when test="$hex-value = 'F' or ($hex-value = 'f')">
4895				<xsl:value-of select="15"/>
4896			</xsl:when>
4897			<xsl:otherwise>
4898				<xsl:value-of select="$hex-value"/>
4899			</xsl:otherwise>
4900		</xsl:choose>
4901	</xsl:template>
4902	<xsl:template name="decimal2hex">
4903		<!-- transforms a decimal number to a hex number,only for two-bit hex(less than 256 in decimal) currently -->
4904		<xsl:param name="dec-number"/>
4905		<xsl:param name="last-value"/>
4906		<xsl:variable name="current-value">
4907			<xsl:call-template name="decNumber2hex">
4908				<xsl:with-param name="dec-value">
4909					<xsl:if test="$dec-number &gt; 15">
4910						<xsl:value-of select="floor($dec-number div 16)"/>
4911					</xsl:if>
4912					<xsl:if test="$dec-number &lt; 16">
4913						<xsl:value-of select="$dec-number"/>
4914					</xsl:if>
4915				</xsl:with-param>
4916			</xsl:call-template>
4917		</xsl:variable>
4918		<xsl:if test="$dec-number &gt; 15">
4919			<xsl:call-template name="decimal2hex">
4920				<xsl:with-param name="dec-number" select="$dec-number mod 16"/>
4921				<xsl:with-param name="last-value" select="concat($last-value,$current-value)"/>
4922			</xsl:call-template>
4923		</xsl:if>
4924		<xsl:if test="$dec-number &lt; 16">
4925			<xsl:value-of select="substring-after(concat($last-value,$current-value),'H')"/>
4926		</xsl:if>
4927	</xsl:template>
4928	<xsl:template name="decNumber2hex">
4929		<!-- return a hex number for a decimal character -->
4930		<xsl:param name="dec-value"/>
4931		<xsl:choose>
4932			<xsl:when test="$dec-value = 10">
4933				<xsl:value-of select="'A'"/>
4934			</xsl:when>
4935			<xsl:when test="$dec-value = 11">
4936				<xsl:value-of select="'B'"/>
4937			</xsl:when>
4938			<xsl:when test="$dec-value = 12">
4939				<xsl:value-of select="'C'"/>
4940			</xsl:when>
4941			<xsl:when test="$dec-value = 13">
4942				<xsl:value-of select="'D'"/>
4943			</xsl:when>
4944			<xsl:when test="$dec-value = 14">
4945				<xsl:value-of select="'E'"/>
4946			</xsl:when>
4947			<xsl:when test="$dec-value = 15">
4948				<xsl:value-of select="'F'"/>
4949			</xsl:when>
4950			<xsl:otherwise>
4951				<xsl:value-of select="$dec-value"/>
4952			</xsl:otherwise>
4953		</xsl:choose>
4954	</xsl:template>
4955	<xsl:template match="ss:Border">
4956		<xsl:variable name="position">
4957			<xsl:choose>
4958				<xsl:when test="@ss:Position = 'Top'">fo:border-top</xsl:when>
4959				<xsl:when test="@ss:Position = 'Bottom'">fo:border-bottom</xsl:when>
4960				<xsl:when test="@ss:Position = 'Left'">fo:border-left</xsl:when>
4961				<xsl:when test="@ss:Position = 'Right'">fo:border-right</xsl:when>
4962				<!-- DiagonalLeft & DiagonalRight are not supported yet, -->
4963				<xsl:otherwise>fo:border-left</xsl:otherwise>
4964			</xsl:choose>
4965		</xsl:variable>
4966		<xsl:variable name="width">
4967			<xsl:choose>
4968				<!-- 0: Hairline -->
4969				<xsl:when test="@ss:Weight = '0'">0.002cm</xsl:when>
4970				<!-- 1: Thin -->
4971				<xsl:when test="@ss:Weight = '1'">0.035cm</xsl:when>
4972				<!-- 2: Medium -->
4973				<xsl:when test="@ss:Weight = '2'">0.088cm</xsl:when>
4974				<!-- 3: Thick -->
4975				<xsl:when test="@ss:Weight = '3'">
4976					<xsl:choose>
4977						<xsl:when test="@ss:LineStyle = 'Double'">0.105cm</xsl:when>
4978						<xsl:otherwise>0.141cm</xsl:otherwise>
4979					</xsl:choose>
4980				</xsl:when>
4981				<!-- invalid value, or parameter not exist at all -->
4982				<xsl:otherwise>0.002cm</xsl:otherwise>
4983			</xsl:choose>
4984		</xsl:variable>
4985		<xsl:variable name="linestyle">
4986			<xsl:choose>
4987				<xsl:when test="@ss:LineStyle = 'None'">none</xsl:when>
4988				<xsl:when test="@ss:LineStyle = 'Continuous'">solid</xsl:when>
4989				<xsl:when test="@ss:LineStyle = 'Double'">double</xsl:when>
4990				<!-- Dash, Dot, DashDot, DashDotDot, SlantDashDot are not supported yet -->
4991				<xsl:otherwise>solid</xsl:otherwise>
4992			</xsl:choose>
4993		</xsl:variable>
4994		<xsl:variable name="color">
4995			<xsl:choose>
4996				<xsl:when test="@ss:Color">
4997					<xsl:value-of select="@ss:Color"/>
4998				</xsl:when>
4999				<!-- default border color is black -->
5000				<xsl:otherwise>#000000</xsl:otherwise>
5001			</xsl:choose>
5002		</xsl:variable>
5003		<xsl:attribute name="{$position}">
5004			<xsl:value-of select="concat( $width, ' ', $linestyle, ' ', $color)"/>
5005		</xsl:attribute>
5006		<xsl:if test="@ss:LineStyle = 'Double'">
5007			<xsl:variable name="widthposition">
5008				<xsl:choose>
5009					<xsl:when test="@ss:Position = 'Top'">style:border-line-width-top</xsl:when>
5010					<xsl:when test="@ss:Position = 'Bottom'">style:border-line-width-bottom</xsl:when>
5011					<xsl:when test="@ss:Position = 'Left'">style:border-line-width-left</xsl:when>
5012					<xsl:when test="@ss:Position = 'Right'">style:border-line-width-right</xsl:when>
5013				</xsl:choose>
5014			</xsl:variable>
5015			<xsl:attribute name="{$widthposition}">0.035cm 0.035cm 0.035cm</xsl:attribute>
5016		</xsl:if>
5017	</xsl:template>
5018	<xsl:template match="ss:Font">
5019		<xsl:choose>
5020			<xsl:when test="@ss:VerticalAlign = 'Superscript'">
5021				<style:style style:name="{concat(../@ss:ID,'T0')}" style:family="text">
5022					<style:text-properties style:text-position="33% 58%"/>
5023				</style:style>
5024			</xsl:when>
5025			<xsl:when test="@ss:VerticalAlign = 'Subscript'">
5026				<style:style style:name="{concat(../@ss:ID,'T0')}" style:family="text">
5027					<style:text-properties style:text-position="-33% 58%"/>
5028				</style:style>
5029			</xsl:when>
5030			<xsl:otherwise/>
5031		</xsl:choose>
5032	</xsl:template>
5033	<xsl:template match="ss:Table">
5034		<xsl:variable name="default-column-width">
5035			<xsl:choose>
5036				<xsl:when test="@ss:DefaultColumnWidth">
5037					<xsl:call-template name="convert2cm">
5038						<xsl:with-param name="value" select="concat(@ss:DefaultColumnWidth,'pt')"/>
5039					</xsl:call-template>
5040					<xsl:text>cm</xsl:text>
5041				</xsl:when>
5042				<!-- Note: Specify where this value come from.. -->
5043				<xsl:otherwise>2.096cm</xsl:otherwise>
5044			</xsl:choose>
5045		</xsl:variable>
5046		<xsl:variable name="table-pos">
5047			<xsl:value-of select="count(../preceding-sibling::ss:Worksheet)+1"/>
5048		</xsl:variable>
5049		<!-- naming convention the default column style is name co<NumberOfSheet> e.g. co1 for the first sheet -->
5050		<style:style style:family="table-column" style:name="{concat('co', $table-pos)}">
5051			<style:table-column-properties fo:break-before="auto" style:column-width="{$default-column-width}"/>
5052		</style:style>
5053		<xsl:choose>
5054			<xsl:when test="ss:Column">
5055				<xsl:call-template name="get-column-style-name">
5056					<xsl:with-param name="finishedColumns" select="0"/>
5057					<xsl:with-param name="columnCount" select="count(./ss:Column)"/>
5058					<xsl:with-param name="currentCount" select="1"/>
5059					<xsl:with-param name="table-pos" select="$table-pos"/>
5060					<xsl:with-param name="default-column-width" select="$default-column-width"/>
5061				</xsl:call-template>
5062			</xsl:when>
5063		</xsl:choose>
5064		<xsl:if test="../x:PageBreaks/x:ColBreaks">
5065			<style:style style:name="{concat('cob',$table-pos)}" style:family="table-column">
5066				<xsl:element name="style:table-column-properties">
5067					<xsl:attribute name="style:column-width">
5068						<xsl:value-of select="$default-column-width"/>
5069					</xsl:attribute>
5070					<xsl:attribute name="fo:break-before">page</xsl:attribute>
5071				</xsl:element>
5072			</style:style>
5073		</xsl:if>
5074		<xsl:variable name="default-row-height">
5075			<xsl:choose>
5076				<xsl:when test="@ss:DefaultRowHeight">
5077					<xsl:call-template name="convert2cm">
5078						<xsl:with-param name="value" select="concat(@ss:DefaultRowHeight,'pt')"/>
5079					</xsl:call-template>
5080					<xsl:text>cm</xsl:text>
5081				</xsl:when>
5082				<!-- Note: This is the default row hight value in spec it is written 255 point, this seems wrong -->
5083				<!-- <xsl:otherwise>0.503cm</xsl:otherwise> -->
5084				<xsl:otherwise>0.45cm</xsl:otherwise>
5085			</xsl:choose>
5086		</xsl:variable>
5087		<style:style style:family="table-row" style:name="{concat('ro', $table-pos)}">
5088			<style:table-row-properties style:row-height="{$default-row-height}" style:use-optimal-row-height="false"/>
5089		</style:style>
5090		<xsl:if test="ss:Row">
5091			<xsl:call-template name="get-row-style-name">
5092				<xsl:with-param name="earlierRowNo" select="0"/>
5093				<xsl:with-param name="rowNodeCount" select="count(./ss:Row)"/>
5094				<xsl:with-param name="rowNodeIndex" select="1"/>
5095				<xsl:with-param name="table-pos" select="$table-pos"/>
5096				<xsl:with-param name="default-row-height" select="$default-row-height"/>
5097			</xsl:call-template>
5098		</xsl:if>
5099		<xsl:if test="../x:PageBreaks/x:RowBreaks">
5100			<style:style style:name="{concat('rob',$table-pos)}" style:family="table-row">
5101				<xsl:element name="style:table-row-properties">
5102					<xsl:attribute name="style:row-height">
5103						<xsl:value-of select="$default-row-height"/>
5104					</xsl:attribute>
5105					<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
5106					<xsl:attribute name="fo:break-before">page</xsl:attribute>
5107				</xsl:element>
5108			</style:style>
5109		</xsl:if>
5110		<!-- create table-style -->
5111		<xsl:element name="style:style">
5112			<xsl:attribute name="style:name">
5113				<xsl:value-of select="concat( 'ta', $table-pos)"/>
5114			</xsl:attribute>
5115			<xsl:attribute name="style:family">table</xsl:attribute>
5116			<!-- ss:Name have to be from type 'NCNameChar'      ::=     Letter | Digit | '.' | '-' | '_' | CombiningChar | Extender -->
5117			<xsl:attribute name="style:master-page-name">
5118				<xsl:call-template name="encode-as-nc-name">
5119					<xsl:with-param name="string" select="../@ss:Name"/>
5120				</xsl:call-template>
5121			</xsl:attribute>
5122			<xsl:element name="style:table-properties">
5123				<xsl:choose>
5124					<xsl:when test="../x:WorksheetOptions/x:Visible = 'SheetHidden'">
5125						<xsl:attribute name="table:display">false</xsl:attribute>
5126					</xsl:when>
5127					<xsl:otherwise>
5128						<xsl:attribute name="table:display">true</xsl:attribute>
5129					</xsl:otherwise>
5130				</xsl:choose>
5131			</xsl:element>
5132		</xsl:element>
5133	</xsl:template>
5134	<xsl:template name="get-column-style-name">
5135		<!-- generate stylename of colbreak after matching the column number and the colbreak number -->
5136		<xsl:param name="finishedColumns"/>
5137		<xsl:param name="columnCount"/>
5138		<xsl:param name="currentCount"/>
5139		<xsl:param name="table-pos"/>
5140		<xsl:param name="default-column-width"/>
5141		<xsl:if test="$currentCount &lt; ($columnCount + 1)">
5142			<xsl:variable name="span-value">
5143				<xsl:choose>
5144					<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Span">
5145						<xsl:value-of select="./ss:Column[position() = $currentCount]/@ss:Span + 1"/>
5146					</xsl:when>
5147					<xsl:otherwise>
5148						<xsl:value-of select="0"/>
5149					</xsl:otherwise>
5150				</xsl:choose>
5151			</xsl:variable>
5152			<xsl:variable name="current-index">
5153				<xsl:choose>
5154					<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Index">
5155						<xsl:value-of select="./ss:Column[position() = $currentCount]/@ss:Index - 1"/>
5156					</xsl:when>
5157					<xsl:otherwise>
5158						<xsl:value-of select="$finishedColumns"/>
5159					</xsl:otherwise>
5160				</xsl:choose>
5161			</xsl:variable>
5162			<xsl:variable name="column-break">
5163				<xsl:choose>
5164					<xsl:when test="$span-value = 0">
5165						<xsl:if test="../x:PageBreaks/x:ColBreaks/x:ColBreak/x:Column = $current-index">
5166							<xsl:value-of select="1"/>
5167						</xsl:if>
5168					</xsl:when>
5169					<xsl:otherwise>
5170						<xsl:if test="../x:PageBreaks/x:ColBreaks[(x:ColBreak/x:Column &gt; $finishedColumns) and (x:ColBreak/x:Column &lt; ($finishedColumns + $span-value))]">
5171							<xsl:value-of select="1"/>
5172						</xsl:if>
5173					</xsl:otherwise>
5174				</xsl:choose>
5175			</xsl:variable>
5176			<xsl:if test="$column-break = 1">
5177				<xsl:element name="style:style">
5178					<xsl:attribute name="style:name">
5179						<xsl:call-template name="encode-as-nc-name">
5180							<xsl:with-param name="string" select="concat('cob', $table-pos, '-',$currentCount)"/>
5181						</xsl:call-template>
5182					</xsl:attribute>
5183					<xsl:attribute name="style:family">table-column</xsl:attribute>
5184					<xsl:element name="style:table-column-properties">
5185						<xsl:choose>
5186							<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Width">
5187								<xsl:attribute name="style:column-width">
5188									<xsl:call-template name="convert2cm">
5189										<xsl:with-param name="value" select="concat(./ss:Column[position() = $currentCount]/@ss:Width,'pt')"/>
5190									</xsl:call-template>
5191									<xsl:text>cm</xsl:text>
5192								</xsl:attribute>
5193							</xsl:when>
5194							<xsl:otherwise>
5195								<xsl:attribute name="style:column-width">
5196									<xsl:value-of select="$default-column-width"/>
5197								</xsl:attribute>
5198							</xsl:otherwise>
5199						</xsl:choose>
5200						<xsl:choose>
5201							<xsl:when test="./ss:Column[position() = $currentCount]/@ss:AutoFitWidth = '0'">
5202								<xsl:attribute name="style:use-optimal-column-width">false</xsl:attribute>
5203							</xsl:when>
5204							<xsl:otherwise>
5205								<xsl:choose>
5206									<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Width &gt; 0">
5207										<xsl:attribute name="style:use-optimal-column-width">false</xsl:attribute>
5208									</xsl:when>
5209									<xsl:otherwise>
5210										<xsl:attribute name="style:use-optimal-column-width">true</xsl:attribute>
5211									</xsl:otherwise>
5212								</xsl:choose>
5213							</xsl:otherwise>
5214						</xsl:choose>
5215						<xsl:attribute name="fo:break-before">page</xsl:attribute>
5216					</xsl:element>
5217				</xsl:element>
5218			</xsl:if>
5219			<style:style style:name="{concat('co', $table-pos, '-',$currentCount)}" style:family="table-column">
5220				<xsl:element name="style:table-column-properties">
5221					<xsl:choose>
5222						<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Width">
5223							<xsl:attribute name="style:column-width">
5224								<xsl:call-template name="convert2cm">
5225									<xsl:with-param name="value" select="concat(./ss:Column[position() = $currentCount]/@ss:Width,'pt')"/>
5226								</xsl:call-template>
5227								<xsl:text>cm</xsl:text>
5228							</xsl:attribute>
5229						</xsl:when>
5230						<xsl:otherwise>
5231							<xsl:attribute name="style:column-width">
5232								<xsl:value-of select="$default-column-width"/>
5233							</xsl:attribute>
5234						</xsl:otherwise>
5235					</xsl:choose>
5236					<xsl:attribute name="fo:break-before">auto</xsl:attribute>
5237				</xsl:element>
5238			</style:style>
5239			<xsl:if test="$currentCount &lt; $columnCount">
5240				<xsl:call-template name="get-column-style-name">
5241					<xsl:with-param name="finishedColumns">
5242						<xsl:choose>
5243							<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Index">
5244								<xsl:choose>
5245									<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Span">
5246										<xsl:value-of select="./ss:Column[position() = $currentCount]/@ss:Index + ./ss:Column[position() = $currentCount]/@ss:Span"/>
5247									</xsl:when>
5248									<xsl:otherwise>
5249										<xsl:value-of select="./ss:Column[position() = $currentCount]/@ss:Index"/>
5250									</xsl:otherwise>
5251								</xsl:choose>
5252							</xsl:when>
5253							<xsl:otherwise>
5254								<xsl:choose>
5255									<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Span">
5256										<xsl:value-of select="$finishedColumns + ./ss:Column[position() = $currentCount]/@ss:Span + 1"/>
5257									</xsl:when>
5258									<xsl:otherwise>
5259										<xsl:value-of select="$finishedColumns + 1"/>
5260									</xsl:otherwise>
5261								</xsl:choose>
5262							</xsl:otherwise>
5263						</xsl:choose>
5264					</xsl:with-param>
5265					<xsl:with-param name="columnCount" select="$columnCount"/>
5266					<xsl:with-param name="currentCount" select="$currentCount + 1"/>
5267					<xsl:with-param name="table-pos" select="$table-pos"/>
5268					<xsl:with-param name="default-column-width" select="$default-column-width"/>
5269				</xsl:call-template>
5270			</xsl:if>
5271		</xsl:if>
5272	</xsl:template>
5273	<xsl:template name="get-row-style-name">
5274		<!-- generate stylename of rowbreak after matching the row number and the rowbreak number -->
5275		<xsl:param name="earlierRowNo"/>
5276		<xsl:param name="rowNodeCount"/>
5277		<xsl:param name="rowNodeIndex"/>
5278		<xsl:param name="table-pos"/>
5279		<xsl:param name="default-row-height"/>
5280		<xsl:if test="$rowNodeIndex &lt; ($rowNodeCount + 1)">
5281			<xsl:variable name="span-value">
5282				<xsl:choose>
5283					<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Index">
5284						<xsl:choose>
5285							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Span">
5286								<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Index - $earlierRowNo+ ./ss:Row[position() = $rowNodeIndex]/@ss:Span"/>
5287							</xsl:when>
5288							<xsl:otherwise>
5289								<xsl:value-of select="0"/>
5290							</xsl:otherwise>
5291						</xsl:choose>
5292					</xsl:when>
5293					<xsl:otherwise>
5294						<xsl:choose>
5295							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Span">
5296								<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Span + 1"/>
5297							</xsl:when>
5298							<xsl:otherwise>
5299								<xsl:value-of select="0"/>
5300							</xsl:otherwise>
5301						</xsl:choose>
5302					</xsl:otherwise>
5303				</xsl:choose>
5304			</xsl:variable>
5305			<xsl:variable name="current-index">
5306				<xsl:choose>
5307					<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Index">
5308						<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Index - 1"/>
5309					</xsl:when>
5310					<xsl:otherwise>
5311						<xsl:value-of select="$earlierRowNo"/>
5312					</xsl:otherwise>
5313				</xsl:choose>
5314			</xsl:variable>
5315			<xsl:variable name="row-break">
5316				<xsl:choose>
5317					<xsl:when test="$span-value = 0">
5318						<xsl:if test="../x:PageBreaks/x:RowBreaks/x:RowBreak/x:Row = $current-index">
5319							<xsl:value-of select="1"/>
5320						</xsl:if>
5321					</xsl:when>
5322					<xsl:otherwise>
5323						<xsl:if test="../x:PageBreaks/x:RowBreaks[(x:RowBreak/x:Row &gt; $earlierRowNo) and (x:RowBreak/x:Row &lt; ($earlierRowNo + $span-value))]">
5324							<xsl:value-of select="1"/>
5325						</xsl:if>
5326					</xsl:otherwise>
5327				</xsl:choose>
5328			</xsl:variable>
5329			<xsl:if test="$row-break = 1">
5330				<xsl:element name="style:style">
5331					<xsl:choose>
5332						<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:StyleID">
5333							<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex,'-',ss:Row[position() = $rowNodeIndex]/@ss:StyleID)"/></xsl:attribute>
5334						</xsl:when>
5335						<xsl:otherwise>
5336							<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex)"/></xsl:attribute>
5337						</xsl:otherwise>
5338					</xsl:choose>
5339					<xsl:attribute name="style:family">table-row</xsl:attribute>
5340
5341
5342					<xsl:element name="style:table-row-properties">
5343						<xsl:choose>
5344							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Height">
5345								<xsl:attribute name="style:row-height">
5346									<xsl:call-template name="convert2cm">
5347										<xsl:with-param name="value" select="concat(./ss:Row[position() = $rowNodeIndex]/@ss:Height,'pt')"/>
5348									</xsl:call-template>
5349									<xsl:text>cm</xsl:text>
5350								</xsl:attribute>
5351							</xsl:when>
5352							<xsl:otherwise>
5353								<xsl:attribute name="style:row-height">
5354									<xsl:value-of select="$default-row-height"/>
5355								</xsl:attribute>
5356							</xsl:otherwise>
5357						</xsl:choose>
5358						<xsl:choose>
5359							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:AutoFitHeight = '0'">
5360								<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
5361							</xsl:when>
5362							<xsl:otherwise>
5363								<xsl:choose>
5364									<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Height &gt; 0">
5365										<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
5366									</xsl:when>
5367									<xsl:otherwise>
5368										<xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
5369									</xsl:otherwise>
5370								</xsl:choose>
5371							</xsl:otherwise>
5372						</xsl:choose>
5373						<xsl:attribute name="fo:break-before">page</xsl:attribute>
5374						<xsl:apply-templates select="key('Style', ss:Row[position() = $rowNodeIndex]/@ss:StyleID)/ss:Interior" mode="style-style-content"/>
5375					</xsl:element>
5376					<!--
5377						<xsl:apply-templates select="key('Style', ss:Row[position() = $rowNodeIndex]/@ss:StyleID)" mode="style-style-content" />
5378					-->
5379				</xsl:element>
5380			</xsl:if>
5381			<!--
5382			<style:style style:name="{concat('ro', $table-pos, '-',$rowNodeIndex)}" style:family="table-row">
5383			-->
5384			<xsl:element name="style:style">
5385				<xsl:choose>
5386					<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:StyleID">
5387						<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex,'-',ss:Row[position() = $rowNodeIndex]/@ss:StyleID)"/></xsl:attribute>
5388					</xsl:when>
5389					<xsl:otherwise>
5390						<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex)"/></xsl:attribute>
5391					</xsl:otherwise>
5392				</xsl:choose>
5393				<xsl:attribute name="style:family">table-row</xsl:attribute>
5394
5395
5396				<xsl:element name="style:table-row-properties">
5397					<xsl:choose>
5398						<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Height">
5399							<xsl:attribute name="style:row-height">
5400								<xsl:call-template name="convert2cm">
5401									<xsl:with-param name="value" select="concat(./ss:Row[position() = $rowNodeIndex]/@ss:Height,'pt')"/>
5402								</xsl:call-template>
5403								<xsl:text>cm</xsl:text>
5404							</xsl:attribute>
5405						</xsl:when>
5406						<xsl:otherwise>
5407							<xsl:attribute name="style:row-height">
5408								<xsl:value-of select="$default-row-height"/>
5409							</xsl:attribute>
5410						</xsl:otherwise>
5411					</xsl:choose>
5412					<xsl:choose>
5413						<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:AutoFitHeight">
5414							<xsl:choose>
5415								<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:AutoFitHeight = '0'">
5416									<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
5417								</xsl:when>
5418								<xsl:otherwise>
5419									<xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
5420								</xsl:otherwise>
5421							</xsl:choose>
5422						</xsl:when>
5423						<xsl:otherwise>
5424							<xsl:choose>
5425								<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Height &gt; 0">
5426									<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
5427								</xsl:when>
5428								<xsl:otherwise>
5429									<xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
5430								</xsl:otherwise>
5431							</xsl:choose>
5432						</xsl:otherwise>
5433					</xsl:choose>
5434					<xsl:attribute name="fo:break-before">auto</xsl:attribute>
5435					<!-- apply to background  -->
5436					<xsl:apply-templates select="key('Style', ss:Row[position() = $rowNodeIndex]/@ss:StyleID)/ss:Interior" mode="style-style-content"/>
5437				</xsl:element>
5438				<!--
5439				<xsl:apply-templates select="key('Style', ss:Row[position() = $rowNodeIndex]/@ss:StyleID)" mode="style-style-content" />
5440				-->
5441			</xsl:element>
5442			<xsl:if test="$rowNodeIndex &lt; $rowNodeCount">
5443				<xsl:call-template name="get-row-style-name">
5444					<xsl:with-param name="earlierRowNo">
5445						<xsl:choose>
5446							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Index">
5447								<xsl:choose>
5448									<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Span">
5449										<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Index + ./ss:Row[position() = $rowNodeIndex]/@ss:Span"/>
5450									</xsl:when>
5451									<xsl:otherwise>
5452										<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Index"/>
5453									</xsl:otherwise>
5454								</xsl:choose>
5455							</xsl:when>
5456							<xsl:otherwise>
5457								<xsl:choose>
5458									<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Span">
5459										<xsl:value-of select="$earlierRowNo + ./ss:Row[position() = $rowNodeIndex]/@ss:Span + 1"/>
5460									</xsl:when>
5461									<xsl:otherwise>
5462										<xsl:value-of select="$earlierRowNo + 1"/>
5463									</xsl:otherwise>
5464								</xsl:choose>
5465							</xsl:otherwise>
5466						</xsl:choose>
5467					</xsl:with-param>
5468					<xsl:with-param name="rowNodeCount" select="$rowNodeCount"/>
5469					<xsl:with-param name="rowNodeIndex" select="$rowNodeIndex + 1"/>
5470					<xsl:with-param name="table-pos" select="$table-pos"/>
5471					<xsl:with-param name="default-row-height" select="$default-row-height"/>
5472				</xsl:call-template>
5473			</xsl:if>
5474		</xsl:if>
5475	</xsl:template>
5476	<xsl:template name="count-spanned-columns">
5477		<xsl:param name="expandedColumnCount" select="0"/>
5478		<xsl:param name="columns"/>
5479		<xsl:param name="columnsCount" select="count($columns)"/>
5480		<xsl:param name="columnIndex" select="1"/>
5481		<xsl:choose>
5482			<xsl:when test="$columnIndex &lt;= $columnsCount">
5483				<xsl:call-template name="count-spanned-columns">
5484					<xsl:with-param name="columns" select="$columns"/>
5485					<xsl:with-param name="columnsCount" select="$columnsCount"/>
5486					<xsl:with-param name="columnIndex" select="$columnIndex + 1"/>
5487					<xsl:with-param name="expandedColumnCount" select="$expandedColumnCount + $columns[$columnIndex]/@ss:Span"/>
5488				</xsl:call-template>
5489			</xsl:when>
5490			<xsl:otherwise>
5491				<xsl:value-of select="$expandedColumnCount"/>
5492			</xsl:otherwise>
5493		</xsl:choose>
5494	</xsl:template>
5495	<xsl:template match="ss:Worksheet">
5496		<xsl:element name="table:table">
5497			<xsl:attribute name="table:name">
5498				<xsl:value-of select="@ss:Name"/>
5499			</xsl:attribute>
5500			<!-- other attributes aren't suitable to apply yet -->
5501			<xsl:if test="ss:Table">
5502				<xsl:attribute name="table:style-name">
5503					<xsl:value-of select="concat( 'ta', count(preceding-sibling::ss:Worksheet)+1)"/>
5504				</xsl:attribute>
5505				<xsl:if test="@ss:Protected = '1'">
5506					<xsl:attribute name="table:protected">true</xsl:attribute>
5507				</xsl:if>
5508				<xsl:if test="descendant::ss:NamedRange[@ss:Name = 'Print_Area' and contains( @ss:RefersTo, '!R')]">
5509					<xsl:variable name="referto">
5510						<xsl:call-template name="translate-expression">
5511							<xsl:with-param name="cell-row-pos" select="0"/>
5512							<xsl:with-param name="cell-column-pos" select="0"/>
5513							<xsl:with-param name="expression" select="descendant::ss:NamedRange/@ss:RefersTo"/>
5514							<xsl:with-param name="return-value" select="''"/>
5515						</xsl:call-template>
5516					</xsl:variable>
5517					<xsl:attribute name="table:print-ranges">
5518						<xsl:value-of select="translate( $referto, '=', '$')"/>
5519					</xsl:attribute>
5520				</xsl:if>
5521				<xsl:variable name="table-pos">
5522					<xsl:value-of select="count(../preceding-sibling::ss:Worksheet)+1"/>
5523				</xsl:variable>
5524				<xsl:choose>
5525					<xsl:when test="ss:Table/@ss:ExpandedColumnCount">
5526						<xsl:choose>
5527							<xsl:when test="not(ss:Table/ss:Column)">
5528								<!-- no columns exist -->
5529								<xsl:call-template name="create-columns-without-input">
5530									<xsl:with-param name="table-pos" select="$table-pos"/>
5531								</xsl:call-template>
5532							</xsl:when>
5533							<xsl:otherwise>
5534								<xsl:call-template name="create-columns">
5535									<xsl:with-param name="columnCount" select="ss:Table/@ss:ExpandedColumnCount"/>
5536									<xsl:with-param name="currentColumnNode" select="ss:Table/ss:Column[1]"/>
5537								</xsl:call-template>
5538							</xsl:otherwise>
5539						</xsl:choose>
5540					</xsl:when>
5541					<xsl:otherwise>
5542						<xsl:choose>
5543							<xsl:when test="ss:Table/ss:Column/@ss:Span">
5544								<!-- No absolute column number (ss:ExpandedColumnCount) is add the nodes and spanned columns -->
5545								<xsl:variable name="spannedColumns">
5546									<xsl:call-template name="count-spanned-columns">
5547										<xsl:with-param name="columns" select="ss:Table/ss:Column[@ss:Span]"/>
5548									</xsl:call-template>
5549								</xsl:variable>
5550								<xsl:call-template name="create-columns">
5551									<xsl:with-param name="columnCount" select="count(ss:Table/ss:Column) + number($spannedColumns)"/>
5552									<xsl:with-param name="currentColumnNode" select="ss:Table/ss:Column[1]"/>
5553								</xsl:call-template>
5554							</xsl:when>
5555							<xsl:otherwise>
5556								<!-- No absolute column number (ss:ExpandedColumnCount) is add the nodes -->
5557								<xsl:call-template name="create-columns">
5558									<xsl:with-param name="columnCount" select="count(ss:Table/ss:Column)"/>
5559									<xsl:with-param name="currentColumnNode" select="ss:Table/ss:Column[1]"/>
5560								</xsl:call-template>
5561							</xsl:otherwise>
5562						</xsl:choose>
5563					</xsl:otherwise>
5564				</xsl:choose>
5565				<!-- generates the string of row\column position if ConditionalFormatting exists -->
5566				<xsl:variable name="condition-pos-str1">
5567					<xsl:if test="./x:ConditionalFormatting">
5568						<xsl:call-template name="condition-row-column-string">
5569							<xsl:with-param name="last" select="''"/>
5570							<xsl:with-param name="total" select="count(./x:ConditionalFormatting)"/>
5571							<xsl:with-param name="index" select="1"/>
5572						</xsl:call-template>
5573					</xsl:if>
5574				</xsl:variable>
5575				<xsl:variable name="condition-pos-str2">
5576					<xsl:if test="./x:DataValidation">
5577						<xsl:call-template name="validation-row-column-string">
5578							<xsl:with-param name="last" select="''"/>
5579							<xsl:with-param name="total" select="count(./x:DataValidation)"/>
5580							<xsl:with-param name="index" select="1"/>
5581						</xsl:call-template>
5582					</xsl:if>
5583				</xsl:variable>
5584				<xsl:variable name="condition-pos-str" select="concat($condition-pos-str1, $condition-pos-str2)"/>
5585				<xsl:choose>
5586					<xsl:when test="./ss:Table/ss:Row">
5587						<xsl:call-template name="create-rows">
5588							<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
5589						</xsl:call-template>
5590					</xsl:when>
5591					<xsl:otherwise>
5592						<xsl:choose>
5593							<xsl:when test="./x:PageBreaks/x:RowBreaks">
5594								<xsl:for-each select="./x:PageBreaks/x:RowBreaks/x:RowBreak">
5595									<xsl:variable name="number-repeated">
5596										<xsl:choose>
5597											<xsl:when test="position() = 1">
5598												<xsl:value-of select="./x:Row"/>
5599											</xsl:when>
5600											<xsl:otherwise>
5601												<xsl:value-of select=". - preceding::x:RowBreak[position()=count(.)]/x:Row - 1"/>
5602											</xsl:otherwise>
5603										</xsl:choose>
5604									</xsl:variable>
5605									<xsl:if test="$number-repeated &gt; 0">
5606										<xsl:element name="table:table-row">
5607											<xsl:if test="@ss:Hidden = '1'">
5608												<xsl:attribute name="table:visibility">collapse</xsl:attribute>
5609											</xsl:if>
5610											<xsl:attribute name="table:style-name">
5611												<xsl:value-of select="concat('ro',$table-pos)"/>
5612											</xsl:attribute>
5613											<xsl:attribute name="table:number-rows-repeated">
5614												<xsl:value-of select="$number-repeated"/>
5615											</xsl:attribute>
5616											<xsl:choose>
5617												<xsl:when test="ss:Table/@ss:ExpandedColumnCount">
5618													<table:table-cell table:number-columns-repeated="{ss:Table/@ss:ExpandedColumnCount}"/>
5619												</xsl:when>
5620												<xsl:otherwise>
5621													<!-- OASIS XML row can not be empty -->
5622													<table:table-cell table:number-columns-repeated="256"/>
5623												</xsl:otherwise>
5624											</xsl:choose>
5625										</xsl:element>
5626									</xsl:if>
5627									<xsl:element name="table:table-row">
5628										<xsl:if test="@ss:Hidden = '1'">
5629											<xsl:attribute name="table:visibility">collapse</xsl:attribute>
5630										</xsl:if>
5631										<xsl:attribute name="table:style-name">
5632											<xsl:value-of select="concat('rob',$table-pos)"/>
5633										</xsl:attribute>
5634										<xsl:choose>
5635											<xsl:when test="ss:Table/@ss:ExpandedColumnCount">
5636												<table:table-cell table:number-columns-repeated="{ss:Table/@ss:ExpandedColumnCount}"/>
5637											</xsl:when>
5638											<xsl:otherwise>
5639												<!-- OASIS XML row can not be empty -->
5640												<table:table-cell table:number-columns-repeated="256"/>
5641											</xsl:otherwise>
5642										</xsl:choose>
5643									</xsl:element>
5644								</xsl:for-each>
5645							</xsl:when>
5646							<xsl:otherwise>
5647								<!-- in case no table row exists (empty spreadsheet) -->
5648								<xsl:element name="table:table-row">
5649									<xsl:choose>
5650										<xsl:when test="ss:Table/@ss:StyleID">
5651											<xsl:attribute name="table:style-name">
5652												<xsl:value-of select="ss:Table/@ss:StyleID"/>
5653											</xsl:attribute>
5654											<xsl:element name="table:table-cell">
5655												<xsl:attribute name="table:style-name">
5656													<xsl:value-of select="ss:Table/@ss:StyleID"/>
5657												</xsl:attribute>
5658											</xsl:element>
5659										</xsl:when>
5660										<xsl:otherwise>
5661											<xsl:attribute name="table:style-name">
5662												<xsl:value-of select="concat('ro',$table-pos)"/>
5663											</xsl:attribute>
5664											<xsl:element name="table:table-cell"/>
5665										</xsl:otherwise>
5666									</xsl:choose>
5667								</xsl:element>
5668							</xsl:otherwise>
5669						</xsl:choose>
5670						<xsl:if test="./x:ConditionalFormatting">
5671							<xsl:variable name="condition-row-max">
5672								<xsl:call-template name="condition-row-col-pos-max">
5673									<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
5674									<xsl:with-param name="last-value" select="0"/>
5675									<xsl:with-param name="div-value" select="'R'"/>
5676								</xsl:call-template>
5677							</xsl:variable>
5678							<xsl:variable name="condition-col-max">
5679								<xsl:call-template name="condition-row-col-pos-max">
5680									<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
5681									<xsl:with-param name="last-value" select="0"/>
5682									<xsl:with-param name="div-value" select="'C'"/>
5683								</xsl:call-template>
5684							</xsl:variable>
5685							<xsl:variable name="break-row-max">
5686								<xsl:call-template name="break-row-beyond-max">
5687									<xsl:with-param name="pos" select="1"/>
5688									<xsl:with-param name="last-value" select="0"/>
5689									<xsl:with-param name="count-value" select="count(./x:PageBreaks/x:RowBreaks/x:RowBreak)"/>
5690								</xsl:call-template>
5691							</xsl:variable>
5692							<xsl:variable name="end-value">
5693								<xsl:choose>
5694									<xsl:when test="$condition-row-max &lt; $break-row-max">
5695										<xsl:value-of select="$break-row-max"/>
5696									</xsl:when>
5697									<xsl:otherwise>
5698										<xsl:value-of select="$condition-row-max"/>
5699									</xsl:otherwise>
5700								</xsl:choose>
5701							</xsl:variable>
5702							<xsl:call-template name="get-row-beyond-last">
5703								<xsl:with-param name="index-value" select="1"/>
5704								<xsl:with-param name="worksheetNo" select="count(preceding-sibling::ss:Worksheet)+1"/>
5705								<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
5706								<xsl:with-param name="end-pos" select="$end-value"/>
5707								<xsl:with-param name="total-col" select="$condition-col-max"/>
5708							</xsl:call-template>
5709						</xsl:if>
5710						<!-- if exists attribute of StyleID in tag of ss:Table but no Row/Column -->
5711						<xsl:if test="./ss:Table/@ss:StyleID">
5712							<table:table-row table:style-name="{concat('ro',$table-pos)}" table:number-rows-repeated="65564">
5713								<table:table-cell table:number-columns-repeated="256"/>
5714							</table:table-row>
5715						</xsl:if>
5716					</xsl:otherwise>
5717				</xsl:choose>
5718			</xsl:if>
5719		</xsl:element>
5720	</xsl:template>
5721	<!-- Note: Need to be refactored -->
5722	<xsl:template name="create-columns-without-input">
5723		<xsl:param name="table-pos"/>
5724		<xsl:choose>
5725			<xsl:when test="./x:PageBreaks/x:ColBreaks">
5726				<xsl:for-each select="./x:PageBreaks/x:ColBreaks/x:ColBreak">
5727					<xsl:variable name="number-repeated">
5728						<xsl:choose>
5729							<xsl:when test="position() = 1">
5730								<xsl:value-of select="./x:Column"/>
5731							</xsl:when>
5732							<xsl:otherwise>
5733								<xsl:value-of select=". - preceding::x:ColBreak[position()=count(.)]/x:Column - 1"/>
5734							</xsl:otherwise>
5735						</xsl:choose>
5736					</xsl:variable>
5737					<xsl:if test="$number-repeated &gt; 0">
5738						<xsl:element name="table:table-column">
5739							<xsl:if test="ancestor::ss:Worksheet/ss:Table/@ss:StyleID">
5740								<xsl:attribute name="table:default-cell-style-name">
5741									<xsl:value-of select="ancestor::ss:Worksheet/ss:Table/@ss:StyleID"/>
5742								</xsl:attribute>
5743							</xsl:if>
5744							<xsl:if test="@ss:Hidden = '1'">
5745								<xsl:attribute name="table:visibility">collapse</xsl:attribute>
5746							</xsl:if>
5747							<xsl:attribute name="table:style-name">
5748								<xsl:value-of select="concat('co',$table-pos)"/>
5749							</xsl:attribute>
5750							<xsl:attribute name="table:number-columns-repeated">
5751								<xsl:value-of select="$number-repeated"/>
5752							</xsl:attribute>
5753						</xsl:element>
5754					</xsl:if>
5755					<xsl:element name="table:table-column">
5756						<!-- column style be made out beforehead -->
5757						<xsl:if test="ancestor::ss:Worksheet/ss:Table/@ss:StyleID">
5758							<xsl:attribute name="table:default-cell-style-name">
5759								<xsl:value-of select="ancestor::ss:Worksheet/ss:Table/@ss:StyleID"/>
5760							</xsl:attribute>
5761						</xsl:if>
5762						<xsl:if test="@ss:Hidden = '1'">
5763							<xsl:attribute name="table:visibility">collapse</xsl:attribute>
5764						</xsl:if>
5765						<xsl:attribute name="table:style-name">
5766							<xsl:value-of select="concat('cob',$table-pos)"/>
5767						</xsl:attribute>
5768					</xsl:element>
5769				</xsl:for-each>
5770			</xsl:when>
5771			<xsl:otherwise>
5772				<xsl:element name="table:table-column">
5773					<xsl:choose>
5774						<xsl:when test="ss:Table/@ss:StyleID">
5775							<xsl:attribute name="table:style-name">
5776								<xsl:value-of select="ss:Table/@ss:StyleID"/>
5777							</xsl:attribute>
5778						</xsl:when>
5779						<xsl:otherwise>
5780							<xsl:attribute name="table:style-name">
5781								<xsl:text>co1</xsl:text>
5782							</xsl:attribute>
5783						</xsl:otherwise>
5784					</xsl:choose>
5785					<xsl:if test="ss:Table/@ss:ExpandedColumnCount and ss:Table/@ss:ExpandedColumnCount > 0">
5786						<xsl:attribute name="table:number-columns-repeated">
5787							<xsl:value-of select="ss:Table/@ss:ExpandedColumnCount"/>
5788						</xsl:attribute>
5789					</xsl:if>
5790					<xsl:attribute name="table:default-cell-style-name">
5791						<xsl:text>Default</xsl:text>
5792					</xsl:attribute>
5793				</xsl:element>
5794			</xsl:otherwise>
5795		</xsl:choose>
5796	</xsl:template>
5797	<!--
5798	 Example:
5799		<ss:Table>
5800			<ss:Column ss:Index="4" ss:Width="500" ss:Span="3" />
5801			<ss:Column ss:Width="200" />
5802		</ss:Table>
5803
5804	Prior column (ss:Index - 1) is written
5805	The given fourth cell (ss:Index="4") is handled as repeated three times (ss:Span="3").
5806	The eight column got a width of "200"
5807
5808	ContextNode: ss:Worksheet
5809	-->
5810	<xsl:key match="/ss:Workbook/ss:Worksheet/x:PageBreaks/x:ColBreaks/x:ColBreak" name="ColBreak" use="Column"/>
5811	<xsl:template name="create-columns">
5812		<xsl:param name="columnCount"/>
5813		<xsl:param name="currentColumn" select="1"/>
5814		<xsl:param name="finishedColumns" select="0"/>
5815		<xsl:param name="worksheetNo" select="count(preceding-sibling::ss:Worksheet)+1"/>
5816		<xsl:param name="currentColumnNode"/>
5817		<xsl:choose>
5818			<xsl:when test="$finishedColumns &lt; $columnCount">
5819				<xsl:choose>
5820					<xsl:when test="$currentColumnNode">
5821						<xsl:choose>
5822							<xsl:when test="$currentColumnNode/@ss:Index - $finishedColumns &gt; 1">
5823								<!-- found column with index.
5824								 filling up table with empty columns until Index is reached -->
5825								<xsl:call-template name="create-default-column">
5826									<xsl:with-param name="currentColumn" select="$currentColumn"/>
5827									<xsl:with-param name="currentColumnNode" select="$currentColumnNode"/>
5828									<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
5829								</xsl:call-template>
5830								<xsl:call-template name="create-columns">
5831									<xsl:with-param name="columnCount" select="$columnCount"/>
5832									<xsl:with-param name="currentColumn" select="$currentColumn"/>
5833									<xsl:with-param name="currentColumnNode" select="$currentColumnNode"/>
5834									<xsl:with-param name="finishedColumns" select="$finishedColumns + 1"/>
5835									<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
5836								</xsl:call-template>
5837							</xsl:when>
5838							<xsl:otherwise>
5839								<xsl:element name="table:table-column">
5840									<xsl:if test="$currentColumnNode/@ss:Hidden = '1'">
5841										<xsl:attribute name="table:visibility">collapse</xsl:attribute>
5842									</xsl:if>
5843									<xsl:if test="$currentColumnNode/@ss:Span">
5844										<xsl:attribute name="table:number-columns-repeated">
5845											<xsl:value-of select="$currentColumnNode/@ss:Span + 1"/>
5846										</xsl:attribute>
5847									</xsl:if>
5848									<xsl:choose>
5849										<xsl:when test="key('ColBreak', $currentColumn)">
5850											<xsl:attribute name="table:style-name">
5851												<xsl:value-of select="concat('cob', $worksheetNo, '-', $currentColumn)"/>
5852											</xsl:attribute>
5853										</xsl:when>
5854										<xsl:otherwise>
5855											<xsl:attribute name="table:style-name">
5856												<xsl:value-of select="concat('co', $worksheetNo, '-', $currentColumn)"/>
5857											</xsl:attribute>
5858										</xsl:otherwise>
5859									</xsl:choose>
5860									<xsl:choose>
5861										<xsl:when test="$currentColumnNode/@ss:StyleID">
5862											<xsl:attribute name="table:default-cell-style-name">
5863												<xsl:value-of select="$currentColumnNode/@ss:StyleID"/>
5864											</xsl:attribute>
5865										</xsl:when>
5866										<xsl:otherwise>
5867											<xsl:attribute name="table:default-cell-style-name">
5868												<xsl:text>Default</xsl:text>
5869											</xsl:attribute>
5870										</xsl:otherwise>
5871									</xsl:choose>
5872								</xsl:element>
5873								<xsl:call-template name="create-columns">
5874									<xsl:with-param name="columnCount" select="$columnCount"/>
5875									<xsl:with-param name="currentColumn" select="$currentColumn + 1"/>
5876									<xsl:with-param name="finishedColumns">
5877										<xsl:choose>
5878											<xsl:when test="$currentColumnNode/@ss:Span">
5879												<xsl:value-of select="$finishedColumns + $currentColumnNode/@ss:Span + 1"/>
5880											</xsl:when>
5881											<xsl:otherwise>
5882												<xsl:value-of select="$finishedColumns + 1"/>
5883											</xsl:otherwise>
5884										</xsl:choose>
5885									</xsl:with-param>
5886									<xsl:with-param name="currentColumnNode" select="ss:Table/ss:Column[$currentColumn + 1]"/>
5887									<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
5888								</xsl:call-template>
5889							</xsl:otherwise>
5890						</xsl:choose>
5891					</xsl:when>
5892					<xsl:otherwise>
5893					<!--                                 <xsl:if test="not($finishedColumns + 1 = $columnCount)"> -->
5894						<xsl:call-template name="create-default-column">
5895							<xsl:with-param name="currentColumn" select="$currentColumn"/>
5896							<xsl:with-param name="currentColumnNode" select="$currentColumnNode"/>
5897							<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
5898						</xsl:call-template>
5899						<xsl:call-template name="create-columns">
5900							<xsl:with-param name="columnCount" select="$columnCount"/>
5901							<xsl:with-param name="currentColumn" select="$currentColumn"/>
5902							<xsl:with-param name="finishedColumns" select="$finishedColumns + 1"/>
5903							<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
5904						</xsl:call-template>
5905					</xsl:otherwise>
5906				</xsl:choose>
5907			</xsl:when>
5908			<xsl:otherwise>
5909				<xsl:if test="$currentColumn = $columnCount">
5910					<!-- Note: name test document for this case and refactor the template -->
5911					<xsl:if test="x:PageBreaks/x:ColBreaks/x:ColBreak/x:Column &gt; $finishedColumns">
5912						<xsl:call-template name="get-column-beyond-last">
5913							<xsl:with-param name="index-value" select="$finishedColumns"/>
5914							<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
5915						</xsl:call-template>
5916					</xsl:if>
5917					<!--Note: Test Scenario for this case: generates some special tags for whole row style
5918				<xsl:if test="(./ss:Table[@ss:StyleID] or ./ss:Table/ss:Row[@ss:StyleID]) and (256 - $finishedColumns &gt; 0)">
5919					<xsl:element name="table:table-column">
5920						<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>
5921						<xsl:attribute name="table:style-name"><xsl:value-of select="'co1'" /></xsl:attribute>
5922						<xsl:attribute name="table:number-columns-repeated"><xsl:value-of select="256 - $finishedColumns" /></xsl:attribute>
5923					</xsl:element>
5924				</xsl:if>
5925				-->
5926				</xsl:if>
5927			</xsl:otherwise>
5928		</xsl:choose>
5929	</xsl:template>
5930	<xsl:template name="create-default-column">
5931		<xsl:param name="currentColumn"/>
5932		<xsl:param name="currentColumnNode"/>
5933		<xsl:param name="worksheetNo"/>
5934		<xsl:param name="nextColumnNo"/>
5935		<xsl:element name="table:table-column">
5936			<xsl:attribute name="table:default-cell-style-name">
5937				<xsl:call-template name="get-default-cell-style">
5938					<xsl:with-param name="currentColumnNode" select="$currentColumnNode"/>
5939				</xsl:call-template>
5940			</xsl:attribute>
5941			<!-- <xsl:attribute name="table:default-cell-style-name"><xsl:value-of select="$nextColumnNo - $currentColumn"/></xsl:attribute>  -->
5942			<xsl:choose>
5943				<xsl:when test="key('ColBreak', $currentColumn)">
5944					<xsl:attribute name="table:style-name">
5945						<xsl:value-of select="concat('cob',$worksheetNo)"/>
5946					</xsl:attribute>
5947				</xsl:when>
5948				<xsl:otherwise>
5949					<xsl:attribute name="table:style-name">
5950						<xsl:value-of select="concat('co',$worksheetNo)"/>
5951					</xsl:attribute>
5952				</xsl:otherwise>
5953			</xsl:choose>
5954		</xsl:element>
5955	</xsl:template>
5956	<xsl:template name="create-rows">
5957		<xsl:param name="condition-pos-str"/>
5958		<xsl:apply-templates select="ss:Table/ss:Row[1]" mode="create-rows">
5959			<xsl:with-param name="worksheetNo" select="count(preceding-sibling::ss:Worksheet)+1"/>
5960			<xsl:with-param name="rowNodeCount" select="count(ss:Table/ss:Row)"/>
5961			<xsl:with-param name="rowNodeIndex" select="1"/>
5962			<xsl:with-param name="expandedRowCount">
5963				<xsl:call-template name="get-expanded-row-count"/>
5964			</xsl:with-param>
5965			<xsl:with-param name="expandedRowCountIndex" select="1"/>
5966			<xsl:with-param name="expandedColumnCount">
5967				<xsl:call-template name="get-expanded-column-count"/>
5968			</xsl:with-param>
5969			<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
5970		</xsl:apply-templates>
5971	</xsl:template>
5972	<xsl:template match="ss:Row" mode="create-rows">
5973		<xsl:param name="worksheetNo"/>
5974		<xsl:param name="rowNodeCount"/>
5975		<xsl:param name="rowNodeIndex" select="1"/>
5976		<xsl:param name="expandedRowCount"/>
5977		<xsl:param name="expandedRowCountIndex" select="1"/>
5978		<xsl:param name="expandedColumnCount"/>
5979		<xsl:param name="condition-pos-str"/>
5980		<xsl:variable name="currentRowNo">
5981			<xsl:choose>
5982				<xsl:when test="@ss:Index">
5983					<xsl:value-of select="@ss:Index"/>
5984				</xsl:when>
5985				<xsl:otherwise>
5986					<xsl:value-of select="$expandedRowCountIndex"/>
5987				</xsl:otherwise>
5988			</xsl:choose>
5989		</xsl:variable>
5990		<xsl:if test="@ss:Index - $expandedRowCountIndex &gt; 0">
5991			<!-- create the precding missing rows -->
5992			<xsl:element name="table:table-row">
5993				<!-- fill the preceding gap with rows without a cell -->
5994				<xsl:attribute name="table:number-rows-repeated">
5995					<xsl:value-of select="@ss:Index - $expandedRowCountIndex"/>
5996				</xsl:attribute>
5997				<xsl:choose>
5998					<xsl:when test="$expandedColumnCount != 0">
5999						<table:table-cell table:number-columns-repeated="{$expandedColumnCount}"/>
6000					</xsl:when>
6001					<xsl:otherwise>
6002						<!-- OASIS XML row can not be empty -->
6003						<table:table-cell table:number-columns-repeated="256"/>
6004					</xsl:otherwise>
6005				</xsl:choose>
6006			</xsl:element>
6007		</xsl:if>
6008		<xsl:element name="table:table-row">
6009			<xsl:attribute name="table:style-name">
6010				<xsl:choose>
6011					<xsl:when test="@ss:StyleID">
6012						<xsl:value-of select="concat('ro',$worksheetNo, '-',$rowNodeIndex,'-', @ss:StyleID)"/>
6013					</xsl:when>
6014					<xsl:otherwise>
6015						<xsl:value-of select="concat('ro',$worksheetNo,'-',$rowNodeIndex)"/>
6016					</xsl:otherwise>
6017				</xsl:choose>
6018			</xsl:attribute>
6019			<xsl:if test="@ss:Hidden = '1'">
6020				<xsl:attribute name="table:visibility">collapse</xsl:attribute>
6021			</xsl:if>
6022			<xsl:if test="@ss:Span">
6023				<xsl:attribute name="table:number-rows-repeated">
6024					<xsl:value-of select="@ss:Span + 1"/>
6025				</xsl:attribute>
6026			</xsl:if>
6027			<xsl:choose>
6028				<!-- Excel row without content -->
6029				<xsl:when test="not(*)">
6030					<!-- OASIS OpenDocument Format does not allow rows without a cell -->
6031				<xsl:choose>
6032					<xsl:when test="$expandedColumnCount != 0">
6033						<table:table-cell table:number-columns-repeated="{$expandedColumnCount}"/>
6034					</xsl:when>
6035					<xsl:otherwise>
6036						<!-- OASIS XML row can not be empty -->
6037						<table:table-cell table:number-columns-repeated="256"/>
6038					</xsl:otherwise>
6039				</xsl:choose>
6040
6041				</xsl:when>
6042				<xsl:otherwise>
6043					<xsl:call-template name="create-cells">
6044						<xsl:with-param name="row-pos" select="$currentRowNo"/>
6045						<xsl:with-param name="expandedColumnCount" select="$expandedColumnCount"/>
6046						<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6047					</xsl:call-template>
6048				</xsl:otherwise>
6049			</xsl:choose>
6050		</xsl:element>
6051		<!-- columns are painting over the expanded RowCount -->
6052		<xsl:choose>
6053			<xsl:when test="count(following-sibling::ss:Row) != 0">
6054				<xsl:apply-templates select="following-sibling::ss:Row[1]" mode="create-rows">
6055					<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
6056					<xsl:with-param name="rowNodeCount" select="$rowNodeCount"/>
6057					<xsl:with-param name="rowNodeIndex" select="$rowNodeIndex + 1"/>
6058					<xsl:with-param name="expandedRowCount" select="$expandedRowCount"/>
6059					<xsl:with-param name="expandedRowCountIndex">
6060						<xsl:choose>
6061							<xsl:when test="@ss:Index and @ss:Span">
6062								<xsl:value-of select="@ss:Index + @ss:Span + 1"/>
6063							</xsl:when>
6064							<xsl:when test="@ss:Index">
6065								<xsl:value-of select="@ss:Index + 1"/>
6066							</xsl:when>
6067							<xsl:when test="@ss:Span">
6068								<xsl:value-of select="$expandedRowCountIndex + @ss:Span + 1"/>
6069							</xsl:when>
6070							<xsl:otherwise>
6071								<xsl:value-of select="$expandedRowCountIndex + 1"/>
6072							</xsl:otherwise>
6073						</xsl:choose>
6074					</xsl:with-param>
6075					<xsl:with-param name="expandedColumnCount" select="$expandedColumnCount"/>
6076					<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6077				</xsl:apply-templates>
6078			</xsl:when>
6079			<xsl:when test="$currentRowNo &lt; 65536">
6080				<xsl:element name="table:table-row">
6081					<!-- fill the preceding gap with rows without a cell -->
6082					<xsl:attribute name="table:number-rows-repeated">
6083						<xsl:value-of select="65536 - $currentRowNo"/>
6084					</xsl:attribute>
6085					<xsl:choose>
6086						<xsl:when test="$expandedColumnCount != 0">
6087							<table:table-cell table:number-columns-repeated="{$expandedColumnCount}"/>
6088						</xsl:when>
6089						<xsl:otherwise>
6090							<!-- OASIS XML row can not be empty -->
6091							<table:table-cell table:number-columns-repeated="256"/>
6092						</xsl:otherwise>
6093					</xsl:choose>
6094				</xsl:element>
6095			</xsl:when>
6096		</xsl:choose>
6097	</xsl:template>
6098	<xsl:template name="get-expanded-column-count">
6099		<xsl:choose>
6100			<xsl:when test="ss:Table/@ss:ExpandedColumnCount">
6101				<xsl:value-of select="ss:Table/@ss:ExpandedColumnCount"/>
6102			</xsl:when>
6103			<xsl:otherwise>
6104				<xsl:choose>
6105					<xsl:when test="ss:Table/ss:Column/@ss:Span">
6106						<!-- No absolute column number (ss:ExpandedColumnCount) is add the nodes and spanned columns -->
6107						<xsl:variable name="spannedColumns">
6108							<xsl:call-template name="count-spanned-columns">
6109								<xsl:with-param name="columns" select="ss:Table/ss:Column[@ss:Span]"/>
6110							</xsl:call-template>
6111						</xsl:variable>
6112						<xsl:value-of select="count(ss:Table/ss:Column) + number($spannedColumns)"/>
6113					</xsl:when>
6114					<xsl:otherwise>
6115						<!-- No absolute column number (ss:ExpandedColumnCount) is add the nodes -->
6116						<xsl:value-of select="count(ss:Table/ss:Column)"/>
6117					</xsl:otherwise>
6118				</xsl:choose>
6119			</xsl:otherwise>
6120		</xsl:choose>
6121	</xsl:template>
6122	<xsl:template name="get-expanded-row-count">
6123		<xsl:choose>
6124			<xsl:when test="ss:Table/@ss:ExpandedRowCount">
6125				<xsl:value-of select="ss:Table/@ss:ExpandedRowCount"/>
6126			</xsl:when>
6127			<xsl:otherwise>
6128				<xsl:choose>
6129					<xsl:when test="ss:Table/ss:Row/@ss:Index and not(ss:Table/ss:Row/@ss:Span)">
6130						<xsl:variable name="lastIndexedRow" select="ss:Table/ss:Row[@ss:Index][last()]"/>
6131						<xsl:value-of select="number($lastIndexedRow/@ss:Index) + count($lastIndexedRow/following-sibling::ss:Row)"/>
6132					</xsl:when>
6133					<xsl:when test="ss:Table/ss:Row/@ss:Index and ss:Table/ss:Row/@ss:Span">
6134						<xsl:variable name="lastIndexedRow" select="ss:Table/ss:Row[@ss:Index][last()]"/>
6135						<xsl:variable name="spannedRows">
6136							<xsl:call-template name="count-spanned-rows">
6137								<xsl:with-param name="rows" select="$lastIndexedRow/following-sibling::ss:Row[@ss:Span]"/>
6138							</xsl:call-template>
6139						</xsl:variable>
6140						<xsl:value-of select="number($lastIndexedRow/@ss:Index) + count($lastIndexedRow/following-sibling::ss:Row) + number($spannedRows)"/>
6141					</xsl:when>
6142					<xsl:when test="not(ss:Table/ss:Row/@ss:Index) and ss:Table/ss:Row/@ss:Span">
6143						<xsl:variable name="spannedRows">
6144							<xsl:call-template name="count-spanned-rows">
6145								<xsl:with-param name="rows" select="ss:Table/ss:Rows[@ss:Span]"/>
6146							</xsl:call-template>
6147						</xsl:variable>
6148						<xsl:value-of select="count(ss:Table/ss:Row + number($spannedRows))"/>
6149					</xsl:when>
6150					<xsl:otherwise>
6151						<xsl:value-of select="count(ss:Table/ss:Row)"/>
6152					</xsl:otherwise>
6153				</xsl:choose>
6154			</xsl:otherwise>
6155		</xsl:choose>
6156	</xsl:template>
6157	<xsl:template name="count-spanned-rows">
6158		<xsl:param name="expandedRowCount" select="0"/>
6159		<xsl:param name="rows"/>
6160		<xsl:param name="rowsCount" select="count($rows)"/>
6161		<xsl:param name="rowIndex" select="1"/>
6162		<xsl:choose>
6163			<xsl:when test="$rowIndex &lt;= $rowsCount">
6164				<xsl:call-template name="count-spanned-rows">
6165					<xsl:with-param name="rows" select="$rows"/>
6166					<xsl:with-param name="rowsCount" select="$rowsCount"/>
6167					<xsl:with-param name="rowIndex" select="$rowIndex + 1"/>
6168					<xsl:with-param name="expandedRowCount" select="$expandedRowCount + $rows[$rowIndex]/@ss:Span"/>
6169				</xsl:call-template>
6170			</xsl:when>
6171			<xsl:otherwise>
6172				<xsl:value-of select="$expandedRowCount"/>
6173			</xsl:otherwise>
6174		</xsl:choose>
6175	</xsl:template>
6176	<xsl:template name="get-default-cell-style">
6177		<xsl:param name="currentColumnNode"/>
6178		<xsl:choose>
6179			<xsl:when test="$currentColumnNode">
6180				<xsl:choose>
6181					<xsl:when test="$currentColumnNode/@ss:StyleID">
6182						<xsl:value-of select="$currentColumnNode/@ss:StyleID"/>
6183					</xsl:when>
6184					<xsl:otherwise>Default</xsl:otherwise>
6185				</xsl:choose>
6186			</xsl:when>
6187			<xsl:otherwise>
6188				<xsl:choose>
6189					<xsl:when test="./ss:Table[@ss:StyleID]">
6190						<xsl:value-of select="./ss:Table/@ss:StyleID"/>
6191					</xsl:when>
6192					<xsl:otherwise>Default</xsl:otherwise>
6193				</xsl:choose>
6194			</xsl:otherwise>
6195		</xsl:choose>
6196	</xsl:template>
6197	<xsl:template name="get-row-beyond-last">
6198		<!-- dealing the RowBreak after last row by recursion -->
6199		<xsl:param name="index-value"/>
6200		<xsl:param name="worksheetNo"/>
6201		<xsl:param name="condition-pos-str"/>
6202		<xsl:param name="end-pos"/>
6203		<xsl:param name="total-col"/>
6204		<xsl:variable name="current" select="concat('R',$index-value)"/>
6205		<xsl:element name="table:table-row">
6206			<xsl:choose>
6207				<xsl:when test="./x:PageBreaks/x:RowBreaks/x:RowBreak/x:Row = ($index-value - 1)">
6208					<xsl:attribute name="table:style-name">
6209						<xsl:value-of select="concat('rob',$worksheetNo)"/>
6210					</xsl:attribute>
6211				</xsl:when>
6212				<xsl:otherwise>
6213					<xsl:attribute name="table:style-name">
6214						<xsl:value-of select="concat('ro',$worksheetNo)"/>
6215					</xsl:attribute>
6216				</xsl:otherwise>
6217			</xsl:choose>
6218			<xsl:choose>
6219				<!-- Note: 2 be refactored
6220				<xsl:when test="./ss:Table/ss:Column[@ss:StyleID] or ./ss:Table[@ss:StyleID]">
6221					<xsl:if test="256 - count(ss:Table/ss:Column) &gt; 0">
6222						<table:table-cell table:number-columns-repeated="{256 - count(ss:Table/ss:Column)}" />
6223					</xsl:if>
6224				</xsl:when>-->
6225				<xsl:when test="contains($condition-pos-str,$current)">
6226					<xsl:call-template name="create-spanning-cells">
6227						<xsl:with-param name="row-pos" select="$index-value"/>
6228						<xsl:with-param name="c-start" select="1"/>
6229						<xsl:with-param name="c-end" select="$total-col"/>
6230						<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6231					</xsl:call-template>
6232				</xsl:when>
6233				<xsl:otherwise>
6234					<!-- OASIS XML does not allow rows without a cell -->
6235					<table:table-cell/>
6236				</xsl:otherwise>
6237			</xsl:choose>
6238		</xsl:element>
6239		<xsl:if test="$index-value &lt; ($end-pos + 1)">
6240			<xsl:call-template name="get-row-beyond-last">
6241				<xsl:with-param name="index-value" select="$index-value + 1"/>
6242				<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
6243				<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6244				<xsl:with-param name="end-pos" select="$end-pos"/>
6245				<xsl:with-param name="total-col" select="$total-col"/>
6246			</xsl:call-template>
6247		</xsl:if>
6248	</xsl:template>
6249	<xsl:template name="break-row-beyond-max">
6250		<!-- returns the max position of the row from condition-pos-str -->
6251		<xsl:param name="pos"/>
6252		<xsl:param name="last-value"/>
6253		<xsl:param name="count-value"/>
6254		<xsl:variable name="pre-value" select="./x:PageBreaks/x:RowBreaks/x:RowBreak[position() = $pos]/x:Row"/>
6255		<xsl:variable name="end-value">
6256			<xsl:choose>
6257				<xsl:when test="$last-value &lt; $pre-value">
6258					<xsl:value-of select="$pre-value"/>
6259				</xsl:when>
6260				<xsl:otherwise>
6261					<xsl:value-of select="$last-value"/>
6262				</xsl:otherwise>
6263			</xsl:choose>
6264		</xsl:variable>
6265		<xsl:choose>
6266			<xsl:when test="$pos &lt; $count-value">
6267				<xsl:call-template name="break-row-beyond-max">
6268					<xsl:with-param name="pos" select="$pos + 1"/>
6269					<xsl:with-param name="last-value" select="$end-value"/>
6270					<xsl:with-param name="count-value" select="$count-value"/>
6271				</xsl:call-template>
6272			</xsl:when>
6273			<xsl:otherwise>
6274				<xsl:value-of select="$end-value"/>
6275			</xsl:otherwise>
6276		</xsl:choose>
6277	</xsl:template>
6278	<xsl:template name="get-column-beyond-last">
6279		<!-- dealing the ColBreak after last column by recursion -->
6280		<xsl:param name="index-value"/>
6281		<xsl:param name="worksheetNo"/>
6282		<xsl:for-each select="./x:PageBreaks/x:ColBreaks/x:ColBreak">
6283			<xsl:variable name="each-column-value" select="./x:Column"/>
6284			<xsl:choose>
6285				<xsl:when test="$each-column-value + 1 &gt; $index-value">
6286					<xsl:variable name="number-repeated">
6287						<xsl:choose>
6288							<xsl:when test="preceding-sibling::x:ColBreak[position()=count(.)]/x:Column + 1 = $index-value">
6289								<xsl:value-of select="$each-column-value - preceding-sibling::x:ColBreak[position()=count(.)]/x:Column - 1"/>
6290							</xsl:when>
6291							<xsl:when test="preceding-sibling::x:ColBreak[position()=count(.)]/x:Column + 1 &gt; $index-value">
6292								<xsl:value-of select="$each-column-value - preceding-sibling::x:ColBreak[position()=count(.)]/x:Column - 1"/>
6293							</xsl:when>
6294							<xsl:otherwise>
6295								<xsl:value-of select="$each-column-value - $index-value + 1"/>
6296							</xsl:otherwise>
6297						</xsl:choose>
6298					</xsl:variable>
6299					<xsl:if test="$number-repeated &gt; 0">
6300						<xsl:element name="table:table-column">
6301							<xsl:attribute name="table:style-name">
6302								<xsl:value-of select="'co1'"/>
6303							</xsl:attribute>
6304							<xsl:attribute name="table:number-columns-repeated">
6305								<xsl:value-of select="$number-repeated"/>
6306							</xsl:attribute>
6307						</xsl:element>
6308					</xsl:if>
6309					<xsl:element name="table:table-column">
6310						<xsl:if test="./../../../ss:Table[@ss:StyleID]">
6311							<xsl:attribute name="table:default-cell-style-name">
6312								<xsl:value-of select="./ss:Table/@ss:StyleID"/>
6313							</xsl:attribute>
6314						</xsl:if>
6315						<xsl:attribute name="table:style-name">
6316							<xsl:value-of select="concat('cob',$worksheetNo)"/>
6317						</xsl:attribute>
6318					</xsl:element>
6319				</xsl:when>
6320				<xsl:when test="$each-column-value + 1 = $index-value">
6321					<xsl:element name="table:table-column">
6322						<xsl:if test="./../../../ss:Table[@ss:StyleID]">
6323							<xsl:attribute name="table:default-cell-style-name">
6324								<xsl:value-of select="./../../../ss:Table/@ss:StyleID"/>
6325							</xsl:attribute>
6326						</xsl:if>
6327						<xsl:attribute name="table:style-name">
6328							<xsl:value-of select="concat('cob',$worksheetNo)"/>
6329						</xsl:attribute>
6330					</xsl:element>
6331				</xsl:when>
6332			</xsl:choose>
6333		</xsl:for-each>
6334	</xsl:template>
6335	<xsl:template name="create-spanning-cells">
6336		<!-- judge the position of the Cell in the condition-pos-str -->
6337		<xsl:param name="row-pos"/>
6338		<xsl:param name="c-start"/>
6339		<xsl:param name="c-end"/>
6340		<xsl:param name="condition-pos-str"/>
6341
6342		<xsl:variable name="current" select="concat('R',$row-pos,'C',$c-start,',')"/>
6343		<xsl:variable name="style-name">
6344			<xsl:choose>
6345				<xsl:when test="contains($condition-pos-str,$current)">
6346					<xsl:variable name="temp-str">
6347						<xsl:call-template name="condition-str">
6348							<xsl:with-param name="param-str" select="substring-before($condition-pos-str,$current)"/>
6349						</xsl:call-template>
6350					</xsl:variable>
6351					<xsl:choose>
6352						<xsl:when test="starts-with($temp-str, 'c')">
6353							<xsl:value-of select="concat('ce', substring-after($temp-str, 'c'))"/>
6354						</xsl:when>
6355						<xsl:when test="starts-with($temp-str, 'v')">
6356							<xsl:value-of select="concat('val', substring-after($temp-str, 'v'))"/>
6357						</xsl:when>
6358					</xsl:choose>
6359				</xsl:when>
6360				<xsl:otherwise>
6361					<!-- as for the spanned cells no style is taken.. -->
6362					<xsl:choose>
6363						<!-- inherit style from parent row style-->
6364						<xsl:when test="../@ss:StyleID">
6365							<xsl:value-of select="../@ss:StyleID"/>
6366						</xsl:when>
6367						<!-- if no correspondent column style exisit.. -->
6368						<!-- inherit style from parent table style -->
6369						<xsl:when test="../../@ss:StyleID">
6370							<!-- function to give in col-pos and get back column style  -->
6371							<xsl:variable name="relatedColumnStyle">
6372								<xsl:call-template name="get-related-column-style">
6373									<!-- the given position of the cell in the table, a column style is searched -->
6374									<xsl:with-param name="calculatedCellPosition" select="$c-start" />
6375									<!-- all columns in XML -->
6376									<xsl:with-param name="columnXMLNodes" select="../../ss:Column"/>
6377								</xsl:call-template>
6378							</xsl:variable>
6379							<xsl:if test="$relatedColumnStyle = ''">
6380								<xsl:value-of select="../../@ss:StyleID"/>
6381							</xsl:if>
6382						</xsl:when>
6383					</xsl:choose>
6384				</xsl:otherwise>
6385			</xsl:choose>
6386		</xsl:variable>
6387		<xsl:element name="table:table-cell">
6388			<xsl:if test="not($style-name = '')">
6389				<xsl:choose>
6390					<xsl:when test="starts-with($style-name, 'val')">
6391						<xsl:attribute name="table:content-validation-name">
6392							<xsl:value-of select="$style-name"/>
6393						</xsl:attribute>
6394					</xsl:when>
6395					<xsl:when test="starts-with($style-name, 'ce')">
6396						<xsl:attribute name="table:style-name">
6397							<xsl:value-of select="$style-name"/>
6398						</xsl:attribute>
6399					</xsl:when>
6400					<xsl:otherwise>
6401						<xsl:attribute name="table:style-name">
6402							<xsl:value-of select="$style-name"/>
6403						</xsl:attribute>
6404					</xsl:otherwise>
6405				</xsl:choose>
6406			</xsl:if>
6407			<xsl:if test="$c-start &lt; $c-end">
6408				<xsl:attribute name="table:number-columns-repeated">
6409					<xsl:value-of select="$c-end - $c-start + 1"/>
6410				</xsl:attribute>
6411			</xsl:if>
6412		</xsl:element>
6413	</xsl:template>
6414	<xsl:template name="condition-row-col-pos-max">
6415		<!-- returns the max position of the column or row from condition-pos-str -->
6416		<xsl:param name="condition-pos-str"/>
6417		<xsl:param name="last-value"/>
6418		<xsl:param name="div-value"/>
6419		<xsl:variable name="pre-value">
6420			<xsl:choose>
6421				<xsl:when test="$div-value = 'R'">
6422					<xsl:value-of select="substring-before(substring-after($condition-pos-str,$div-value),'C')"/>
6423				</xsl:when>
6424				<xsl:otherwise>
6425					<xsl:value-of select="substring-before(substring-after($condition-pos-str,$div-value),',')"/>
6426				</xsl:otherwise>
6427			</xsl:choose>
6428		</xsl:variable>
6429		<xsl:variable name="end-value">
6430			<xsl:choose>
6431				<xsl:when test="$last-value &lt; $pre-value">
6432					<xsl:value-of select="$pre-value"/>
6433				</xsl:when>
6434				<xsl:otherwise>
6435					<xsl:value-of select="$last-value"/>
6436				</xsl:otherwise>
6437			</xsl:choose>
6438		</xsl:variable>
6439		<xsl:choose>
6440			<xsl:when test="contains($condition-pos-str,$div-value)">
6441				<xsl:call-template name="condition-row-col-pos-max">
6442					<xsl:with-param name="condition-pos-str" select="substring-after($condition-pos-str,$div-value)"/>
6443					<xsl:with-param name="last-value" select="$end-value"/>
6444					<xsl:with-param name="div-value" select="$div-value"/>
6445				</xsl:call-template>
6446			</xsl:when>
6447			<xsl:otherwise>
6448				<xsl:value-of select="$end-value"/>
6449			</xsl:otherwise>
6450		</xsl:choose>
6451	</xsl:template>
6452	<xsl:template name="condition-str">
6453		<!-- returns the string of style name of condition-pos-str -->
6454		<xsl:param name="param-str"/>
6455		<xsl:choose>
6456			<xsl:when test="contains($param-str,'(')">
6457				<xsl:call-template name="condition-str">
6458					<xsl:with-param name="param-str" select="substring-after($param-str,'(')"/>
6459				</xsl:call-template>
6460			</xsl:when>
6461			<xsl:otherwise>
6462				<xsl:value-of select="substring-before($param-str,':')"/>
6463			</xsl:otherwise>
6464		</xsl:choose>
6465	</xsl:template>
6466	<xsl:key name="Style" match="/ss:Workbook/ss:Styles/ss:Style" use="@ss:ID"/>
6467	<xsl:template name="create-cells">
6468		<xsl:param name="row-pos"/>
6469		<xsl:param name="expandedColumnCount"/>
6470		<xsl:param name="condition-pos-str"/>
6471		<xsl:choose>
6472			<xsl:when test="ss:Cell">
6473				<xsl:apply-templates select="ss:Cell[1]" mode="selected">
6474					<xsl:with-param name="row-pos" select="$row-pos"/>
6475					<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6476					<xsl:with-param name="col-pos-max" select="$expandedColumnCount"/>
6477					<!--
6478						<xsl:call-template name="condition-row-col-pos-max">
6479							<xsl:with-param name="condition-pos-str" select="$condition-pos-str" />
6480							<xsl:with-param name="last-value" select="0" />
6481							<xsl:with-param name="div-value" select="'C'" />
6482						</xsl:call-template>
6483					</xsl:with-param> -->
6484					<xsl:with-param name="col-pos-written" select="0"/>
6485				</xsl:apply-templates>
6486			</xsl:when>
6487			<xsl:otherwise>
6488				<xsl:variable name="current" select="concat('R',$row-pos,'C')"/>
6489				<xsl:choose>
6490					<xsl:when test="contains($condition-pos-str,$current)">
6491						<xsl:call-template name="create-spanning-cells">
6492							<xsl:with-param name="row-pos" select="$row-pos"/>
6493							<xsl:with-param name="c-start" select="1"/>
6494							<xsl:with-param name="c-end">
6495								<xsl:call-template name="condition-row-col-pos-max">
6496									<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6497									<xsl:with-param name="last-value" select="0"/>
6498									<xsl:with-param name="div-value" select="'C'"/>
6499								</xsl:call-template>
6500							</xsl:with-param>
6501							<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6502							<xsl:with-param name="col-pos" select="1"/>
6503						</xsl:call-template>
6504					</xsl:when>
6505					<xsl:otherwise>
6506						<!-- OASIS XML does not allow an empty row -->
6507						<xsl:choose>
6508							<xsl:when test="$expandedColumnCount != 0">
6509								<table:table-cell table:number-columns-repeated="{$expandedColumnCount}"/>
6510							</xsl:when>
6511							<xsl:otherwise>
6512								<!-- OASIS XML row can not be empty -->
6513								<table:table-cell table:number-columns-repeated="256"/>
6514							</xsl:otherwise>
6515						</xsl:choose>
6516					</xsl:otherwise>
6517				</xsl:choose>
6518			</xsl:otherwise>
6519		</xsl:choose>
6520	</xsl:template>
6521	<xsl:template match="ss:Cell" name="ss:Cell" mode="selected">
6522		<!-- Contains the max position of the column or row from the concatenation from
6523			x:ConditionalFormatting
6524				and
6525			x:DataValidation -->
6526		<xsl:param name="condition-pos-str"/>
6527		<xsl:param name="col-pos-max"/>
6528		<xsl:param name="col-pos-written" select="0"/>
6529		<xsl:param name="col-pos-current" select="0"/>
6530		<xsl:param name="row-pos"/>
6531		<xsl:param name="col-repeated" select="1"/>
6532
6533		<!-- The column position of the cell (might jumped by ss:Index) -->
6534		<xsl:variable name="col-pos">
6535			<xsl:choose>
6536				<xsl:when test="@ss:Index">
6537					<xsl:choose>
6538						<xsl:when test="@ss:MergeAcross">
6539							<xsl:value-of select="@ss:MergeAcross + @ss:Index"/>
6540						</xsl:when>
6541						<xsl:otherwise>
6542							<xsl:value-of select="@ss:Index"/>
6543						</xsl:otherwise>
6544					</xsl:choose>
6545				</xsl:when>
6546				<xsl:otherwise>
6547					<xsl:choose>
6548						<xsl:when test="@ss:MergeAcross">
6549							<xsl:value-of select="1 + @ss:MergeAcross + $col-pos-current"/>
6550						</xsl:when>
6551						<xsl:otherwise>
6552							<xsl:value-of select="1 + $col-pos-current"/>
6553						</xsl:otherwise>
6554					</xsl:choose>
6555				</xsl:otherwise>
6556			</xsl:choose>
6557		</xsl:variable>
6558		<xsl:variable name="nextCell" select="following-sibling::ss:Cell[1]"/>
6559		<!-- Multiple empty cells with the same or no style will be moved to one cell with a 'table:number-columns-repeated' attribute -->
6560		<xsl:variable name="cell-is-repeatable" select="
6561														not(current()/*)
6562													and
6563														not(current()/text())
6564													and
6565														(
6566															not($nextCell)
6567															and $col-pos &gt; $col-pos-written + 1
6568														or
6569															(
6570																$nextCell
6571																and
6572																not($nextCell/*)
6573																and
6574																not($nextCell/text())
6575																and
6576																(
6577																	(current()/@ss:StyleID = $nextCell/@ss:StyleID)
6578																	or
6579																	(not(current()/@ss:StyleID) and not($nextCell/@ss:StyleID))
6580																)
6581																and
6582																(
6583																	not($nextCell/@ss:Index)
6584																	or
6585																	   ($nextCell/@ss:Index = $col-pos + 1)
6586																 )
6587															 )
6588														 ) "/>
6589		<xsl:choose>
6590			<!-- Scenario: The missing cells scipped by using the ss:Index attribute will be added -->
6591			<xsl:when test="@ss:Index and @ss:Index &gt; $col-pos-written + 1">
6592				<!-- In Open Document nothing comparable to Index exists,
6593					the missing cells might have to be created, if they had content as only style will be repeated-->
6594				<xsl:call-template name="create-spanning-cells">
6595					<xsl:with-param name="row-pos" select="$row-pos"/>
6596					<xsl:with-param name="c-start" select="$col-pos-current + 1"/>
6597					<xsl:with-param name="c-end" select="@ss:Index - 1"/>
6598					<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6599				</xsl:call-template>
6600				<xsl:call-template name="ss:Cell">
6601					<xsl:with-param name="row-pos" select="$row-pos"/>
6602					<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6603					<xsl:with-param name="col-pos-max" select="$col-pos-max"/>
6604					<xsl:with-param name="col-pos-written" select="@ss:Index - 1"/>
6605					<xsl:with-param name="col-pos-current" select="$col-pos"/>
6606					<xsl:with-param name="col-repeated" select="$col-repeated"/>
6607				</xsl:call-template>
6608			</xsl:when>
6609			<!-- Scenario: A sequence of cells can be put together as one cell -->
6610			<xsl:when test="$cell-is-repeatable">
6611				<xsl:apply-templates select="$nextCell" mode="selected">
6612					<xsl:with-param name="row-pos" select="$row-pos"/>
6613					<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6614					<xsl:with-param name="col-pos-max" select="$col-pos-max"/>
6615					<xsl:with-param name="col-pos-written" select="$col-pos-written"/>
6616					<xsl:with-param name="col-pos-current" select="$col-pos"/>
6617					<xsl:with-param name="col-repeated" select="$col-repeated"/>
6618				</xsl:apply-templates>
6619			</xsl:when>
6620			<xsl:otherwise>
6621				<!-- if the cell wasn't repeated yet, created first -->
6622				<xsl:if test="$col-repeated = 1">
6623					<xsl:element name="table:table-cell">
6624						<!-- in case the cell has an Index and is repeatable (s.above) and therefore has not been repeated earlier  -->
6625						<xsl:choose>
6626							<xsl:when test="@ss:MergeAcross">
6627								<xsl:if test="$col-pos - @ss:MergeAcross &gt; $col-pos-written + 1">
6628									<xsl:attribute name="table:number-columns-repeated">
6629										<xsl:value-of select="$col-pos - $col-pos-written"/>
6630									</xsl:attribute>
6631								</xsl:if>
6632							</xsl:when>
6633							<xsl:otherwise>
6634								<xsl:if test="$col-pos &gt; $col-pos-written + 1">
6635									<xsl:attribute name="table:number-columns-repeated">
6636										<xsl:value-of select="$col-pos - $col-pos-written"/>
6637									</xsl:attribute>
6638								</xsl:if>
6639							</xsl:otherwise>
6640						</xsl:choose>
6641						<xsl:call-template name="create-table-cell-attributes">
6642							<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6643							<xsl:with-param name="col-pos-max" select="$col-pos-max"/>
6644							<xsl:with-param name="col-pos" select="$col-pos"/>
6645							<xsl:with-param name="row-pos" select="$row-pos"/>
6646						</xsl:call-template>
6647						<xsl:call-template name="create-table-cell-content">
6648							<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6649							<xsl:with-param name="col-pos-max" select="$col-pos-max"/>
6650							<xsl:with-param name="col-pos" select="$col-pos"/>
6651							<xsl:with-param name="row-pos" select="$row-pos"/>
6652						</xsl:call-template>
6653					</xsl:element>
6654					<!-- ss:MergeAcross (column spanned) indicates a covered table-cell in Open Document XML-->
6655					<xsl:if test="@ss:MergeAcross">
6656						<xsl:element name="table:covered-table-cell">
6657							<xsl:if test="@ss:MergeAcross &gt; 1">
6658								<xsl:attribute name="table:number-columns-repeated">
6659									<xsl:value-of select="@ss:MergeAcross"/>
6660								</xsl:attribute>
6661							</xsl:if>
6662						</xsl:element>
6663					</xsl:if>
6664				</xsl:if>
6665				<xsl:choose>
6666					<!-- the following block is not used, if the cell had been repeated earlier -->
6667					<xsl:when test="$nextCell and not($cell-is-repeatable and $col-repeated = 1)">
6668						<xsl:choose>
6669							<!-- After cells can not longer be repeated write out the attribute -->
6670							<xsl:when test="not($cell-is-repeatable) and $col-repeated > 1">
6671								<xsl:attribute name="table:number-columns-repeated">
6672									<xsl:value-of select="$col-repeated"/>
6673								</xsl:attribute>
6674							</xsl:when>
6675							<!-- At the end of the row -->
6676							<xsl:when test="not($nextCell)">
6677								<xsl:if test="../../../x:ConditionalFormatting">
6678									<!-- at the last position of the Cell tag,inspecting the following cell before condition-row-col-pos-max -->
6679									<xsl:call-template name="create-spanning-cells">
6680										<xsl:with-param name="row-pos" select="$row-pos"/>
6681										<xsl:with-param name="c-start" select="$col-pos"/>
6682										<xsl:with-param name="c-end" select="$col-pos-max"/>
6683										<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6684									</xsl:call-template>
6685								</xsl:if>
6686							</xsl:when>
6687							<!-- If the cells can not be repeated (default) -->
6688							<xsl:when test="not($cell-is-repeatable)">
6689								<!-- Traverse the following Cell -->
6690								<xsl:apply-templates select="$nextCell" mode="selected">
6691									<xsl:with-param name="row-pos" select="$row-pos"/>
6692									<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6693									<xsl:with-param name="col-pos-max" select="$col-pos-max"/>
6694									<xsl:with-param name="col-pos-written" select="$col-pos"/>
6695									<xsl:with-param name="col-pos-current" select="$col-pos"/>
6696								</xsl:apply-templates>
6697							</xsl:when>
6698							<!-- Go on with started repetition -->
6699							<xsl:otherwise>
6700								<xsl:apply-templates select="$nextCell" mode="selected">
6701									<xsl:with-param name="row-pos" select="$row-pos"/>
6702									<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6703									<xsl:with-param name="col-pos-max" select="$col-pos-max"/>
6704									<xsl:with-param name="col-pos-written" select="$col-pos"/>
6705									<xsl:with-param name="col-pos-current" select="$col-pos"/>
6706									<xsl:with-param name="col-repeated" select="$col-repeated + 1"/>
6707								</xsl:apply-templates>
6708							</xsl:otherwise>
6709						</xsl:choose>
6710					</xsl:when>
6711					<xsl:when test="not($nextCell)">
6712						<xsl:choose>
6713							<xsl:when test="$col-repeated = 1 and ($col-pos &lt; $col-pos-max)">
6714								<table:table-cell table:number-columns-repeated="{$col-pos-max - $col-pos}"/>
6715							</xsl:when>
6716							<xsl:when test="$col-repeated &gt; 1">
6717								<xsl:attribute name="table:number-columns-repeated">
6718									<xsl:value-of select="$col-repeated"/>
6719								</xsl:attribute>
6720							</xsl:when>
6721						</xsl:choose>
6722					</xsl:when>
6723					<xsl:otherwise>
6724						<xsl:apply-templates select="$nextCell" mode="skip">
6725							<xsl:with-param name="row-pos" select="$row-pos"/>
6726							<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6727							<xsl:with-param name="col-pos-max" select="$col-pos-max"/>
6728							<xsl:with-param name="col-pos-written" select="$col-pos"/>
6729						</xsl:apply-templates>
6730					</xsl:otherwise>
6731				</xsl:choose>
6732			</xsl:otherwise>
6733		</xsl:choose>
6734	</xsl:template>
6735	<xsl:template match="ss:Cell" mode="skip">
6736		<xsl:param name="condition-pos-str"/>
6737		<xsl:param name="col-pos-max"/>
6738		<xsl:param name="col-pos-written"/>
6739		<xsl:param name="row-pos"/>
6740
6741		<xsl:variable name="nextCell" select="following-sibling::ss:Cell[1]"/>
6742		<!-- Multiple empty cells with the same style will be moved to one cell with a 'table:number-columns-repeated' attribute -->
6743		<xsl:variable name="cell-is-repeatable" select="not($nextCell/*) and not($nextCell/text()) and ((current()/@ss:StyleID = $nextCell/@ss:StyleID) or (not(current()/@ss:StyleID) and not($nextCell/@ss:StyleID))) and not($nextCell/@ss:Index)"/>
6744		<xsl:choose>
6745			<xsl:when test="$cell-is-repeatable">
6746				<xsl:apply-templates select="$nextCell" mode="skip">
6747					<xsl:with-param name="row-pos" select="$row-pos"/>
6748					<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6749					<xsl:with-param name="col-pos-max" select="$col-pos-max"/>
6750					<xsl:with-param name="col-pos-written" select="$col-pos-written + 1"/>
6751				</xsl:apply-templates>
6752			</xsl:when>
6753			<xsl:otherwise>
6754				<xsl:apply-templates select="$nextCell" mode="selected">
6755					<xsl:with-param name="row-pos" select="$row-pos"/>
6756					<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6757					<xsl:with-param name="col-pos-max" select="$col-pos-max"/>
6758					<xsl:with-param name="col-pos-written" select="$col-pos-written + 1"/>
6759					<xsl:with-param name="col-pos-current" select="$col-pos-written + 1"/>
6760				</xsl:apply-templates>
6761			</xsl:otherwise>
6762		</xsl:choose>
6763	</xsl:template>
6764	<xsl:template name="create-table-cell-attributes">
6765		<xsl:param name="condition-pos-str"/>
6766		<xsl:param name="col-pos-max"/>
6767		<xsl:param name="col-pos"/>
6768		<xsl:param name="row-pos"/>
6769
6770		<xsl:choose>
6771			<xsl:when test="$condition-pos-str">
6772				<xsl:call-template name="get-condition-dependent-cell-attributes">
6773					<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
6774					<xsl:with-param name="current-pos-str" select="concat('R',$row-pos,'C',$col-pos,',')"/>
6775				</xsl:call-template>
6776			</xsl:when>
6777			<xsl:otherwise>
6778				<xsl:choose>
6779					<xsl:when test="@ss:StyleID">
6780						<xsl:attribute name="table:style-name">
6781							<xsl:value-of select="@ss:StyleID"/>
6782						</xsl:attribute>
6783					</xsl:when>
6784					<!-- inherit style from parent row style-->
6785					<xsl:when test="../@ss:StyleID">
6786						<xsl:attribute name="table:style-name">
6787							<xsl:value-of select="../@ss:StyleID"/>
6788						</xsl:attribute>
6789					</xsl:when>
6790					<!-- if no correspondent column style exisit.. -->
6791					<!-- inherit style from parent table style -->
6792					<xsl:when test="../../@ss:StyleID">
6793						<!-- function to give in col-pos and get back column style  -->
6794						<xsl:variable name="relatedColumnStyle">
6795							<xsl:call-template name="get-related-column-style">
6796								<!-- the given position of the cell in the table, a column style is searched -->
6797								<xsl:with-param name="calculatedCellPosition" select="$col-pos" />
6798								<!-- all columns in XML -->
6799								<xsl:with-param name="columnXMLNodes" select="../../ss:Column"/>
6800							</xsl:call-template>
6801						</xsl:variable>
6802						<xsl:if test="$relatedColumnStyle = ''">
6803							<xsl:attribute name="table:style-name">
6804								<xsl:value-of select="../../@ss:StyleID"/>
6805							</xsl:attribute>
6806						</xsl:if>
6807					</xsl:when>
6808				</xsl:choose>
6809			</xsl:otherwise>
6810		</xsl:choose>
6811		<xsl:if test="@ss:MergeAcross or @ss:MergeDown">
6812			<xsl:choose>
6813				<xsl:when test="@ss:MergeAcross">
6814					<xsl:attribute name="table:number-columns-spanned">
6815						<xsl:value-of select="@ss:MergeAcross + 1"/>
6816					</xsl:attribute>
6817				</xsl:when>
6818				<xsl:otherwise>
6819					<xsl:attribute name="table:number-columns-spanned">1</xsl:attribute>
6820				</xsl:otherwise>
6821			</xsl:choose>
6822			<xsl:choose>
6823				<xsl:when test="@ss:MergeDown">
6824					<xsl:attribute name="table:number-rows-spanned">
6825						<xsl:value-of select="@ss:MergeDown+1"/>
6826					</xsl:attribute>
6827				</xsl:when>
6828				<xsl:otherwise>
6829					<xsl:attribute name="table:number-rows-spanned">1</xsl:attribute>
6830				</xsl:otherwise>
6831			</xsl:choose>
6832		</xsl:if>
6833		<xsl:if test="@ss:Formula">
6834			<!-- formula translation from Excel to Calc -->
6835			<xsl:variable name="calc-formula">
6836				<xsl:call-template name="translate-expression">
6837					<xsl:with-param name="cell-row-pos" select="$row-pos"/>
6838					<xsl:with-param name="cell-column-pos" select="$col-pos"/>
6839					<xsl:with-param name="expression" select="@ss:Formula"/>
6840					<xsl:with-param name="return-value" select="''"/>
6841				</xsl:call-template>
6842			</xsl:variable>
6843			<xsl:attribute name="table:formula">
6844				<xsl:value-of select="$calc-formula"/>
6845			</xsl:attribute>
6846		</xsl:if>
6847		<xsl:if test="ss:Data">
6848			<xsl:variable name="data-format">
6849				<xsl:value-of select="key('Style', @ss:StyleID)/ss:NumberFormat/@ss:Format"/>
6850			</xsl:variable>
6851			<xsl:choose>
6852				<xsl:when test="ss:Data/@ss:Type = 'Number'">
6853					<xsl:choose>
6854						<xsl:when test="$data-format = 'Percent' or contains( $data-format, '%')">
6855							<xsl:attribute name="office:value-type">percentage</xsl:attribute>
6856						</xsl:when>
6857						<xsl:when test="contains(key('Style', @ss:StyleID)/ss:NumberFormat/@ss:Format, 'Currency')">
6858							<xsl:attribute name="office:value-type">currency</xsl:attribute>
6859						</xsl:when>
6860						<xsl:otherwise>
6861							<xsl:attribute name="office:value-type">float</xsl:attribute>
6862						</xsl:otherwise>
6863					</xsl:choose>
6864					<xsl:attribute name="office:value">
6865						<xsl:value-of select="ss:Data"/>
6866					</xsl:attribute>
6867				</xsl:when>
6868				<xsl:when test="ss:Data/@ss:Type = 'DateTime'">
6869					<xsl:choose>
6870						<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') ) )">
6871							<xsl:attribute name="office:value-type">date</xsl:attribute>
6872							<xsl:attribute name="office:date-value">
6873								<xsl:value-of select="substring-before(ss:Data, 'T')"/>
6874							</xsl:attribute>
6875						</xsl:when>
6876						<xsl:otherwise>
6877							<xsl:attribute name="office:value-type">time</xsl:attribute>
6878							<xsl:attribute name="office:time-value">
6879								<xsl:value-of select="concat('P',substring(ss:Data, 11, 3), 'H', substring(ss:Data, 15, 2), 'M', substring(ss:Data, 18,2), 'S')"/>
6880							</xsl:attribute>
6881						</xsl:otherwise>
6882					</xsl:choose>
6883				</xsl:when>
6884				<xsl:when test="ss:Data/@ss:Type = 'Boolean'">
6885					<xsl:attribute name="office:value-type">boolean</xsl:attribute>
6886					<xsl:attribute name="office:boolean-value">
6887						<xsl:choose>
6888							<xsl:when test="ss:Data = '1'">true</xsl:when>
6889							<xsl:otherwise>false</xsl:otherwise>
6890						</xsl:choose>
6891					</xsl:attribute>
6892				</xsl:when>
6893				<xsl:when test="ss:Data/@ss:Type = 'String'">
6894					<xsl:attribute name="office:value-type">string</xsl:attribute>
6895				</xsl:when>
6896			</xsl:choose>
6897		</xsl:if>
6898	</xsl:template>
6899	<xsl:template name="get-related-column-style">
6900		<!-- the given position of the cell in the table, a column style is searched -->
6901		<xsl:param name="calculatedCellPosition" />
6902		<!-- the current position of the column as XML node -->
6903		<xsl:param name="columnXMLPosition" select="1" />
6904		<!-- all columns in XML -->
6905		<xsl:param name="columnXMLNodes" />
6906		<!-- the ending column position of the earlier column style in the table -->
6907		<xsl:param name="earlierCalculatedColumnEnd" select="0" />
6908
6909		<!-- the current column as XML node -->
6910		<xsl:variable name="columnXMLNode" select="$columnXMLNodes[1]" />
6911		<xsl:if test="$columnXMLNodes and count($columnXMLNodes) > 0">
6912			<!-- the starting column position of the style in the table -->
6913			<xsl:variable name="calculatedColumnStart">
6914				<!-- if ss:Index exists, this is the start of the column -->
6915				<xsl:choose>
6916					<xsl:when test="$columnXMLNode/@ss:Index">
6917						<xsl:value-of select="$columnXMLNode/@ss:Index" />
6918					</xsl:when>
6919					<xsl:otherwise>
6920						<xsl:value-of select="$earlierCalculatedColumnEnd + 1" />
6921					</xsl:otherwise>
6922				</xsl:choose>
6923			</xsl:variable>
6924			<!-- the ending column position of the style in the table -->
6925			<xsl:variable name="calculatedColumnEnd">
6926				<xsl:choose>
6927					<xsl:when test="$columnXMLNode/@ss:Span">
6928						<xsl:value-of select="$calculatedColumnStart + $columnXMLNode/@ss:Span" />
6929					</xsl:when>
6930					<xsl:otherwise>
6931						<xsl:value-of select="$calculatedColumnStart" />
6932					</xsl:otherwise>
6933				</xsl:choose>
6934			</xsl:variable>
6935			<xsl:choose>
6936				<xsl:when test="$calculatedColumnStart &gt;= $calculatedCellPosition and $calculatedCellPosition &lt;= $calculatedColumnEnd">
6937					<xsl:value-of select="$columnXMLNode/@ss:StyleID"/>
6938				</xsl:when>
6939				<xsl:when test="$calculatedColumnEnd &lt;= $calculatedCellPosition">
6940					<xsl:call-template name="get-related-column-style">
6941						<!-- the given position of the cell in the table, a column style is searched -->
6942						<xsl:with-param name="calculatedCellPosition" select="$calculatedCellPosition" />
6943						<!-- all columns in XML -->
6944						<xsl:with-param name="columnXMLNodes" select="$columnXMLNodes[position() != 1]"/>
6945						<!-- the ending column position of the style in the table -->
6946						<xsl:with-param name="earlierCalculatedColumnEnd" select="$calculatedColumnEnd" />
6947					</xsl:call-template>
6948				</xsl:when>
6949			</xsl:choose>
6950		</xsl:if>
6951	</xsl:template>
6952
6953	<xsl:template name="create-table-cell-content">
6954		<xsl:param name="condition-pos-str"/>
6955		<xsl:param name="col-pos-max"/>
6956		<xsl:param name="col-pos"/>
6957		<xsl:param name="row-pos"/>
6958		<xsl:apply-templates select="ss:Comment" mode="body"/>
6959		<xsl:if test="ss:Data">
6960			<text:p>
6961				<xsl:call-template name="create-data-content">
6962					<xsl:with-param name="style-id" select="@ss:StyleID"/>
6963				</xsl:call-template>
6964			</text:p>
6965		</xsl:if>
6966	</xsl:template>
6967	<xsl:template name="create-data-content">
6968		<xsl:param name="style-id" select="@ss:StyleID"/>
6969		<!-- collect every HTML 3.2 children, which are not empty -->
6970		<xsl:variable name="html-children" select="ss:Data/descendant-or-self::*[namespace-uri()='http://www.w3.org/TR/REC-html40'][string-length(text()) != 0]"/>
6971		<xsl:choose>
6972			<xsl:when test="$html-children and $html-children != ''">
6973				<xsl:for-each select="$html-children">
6974					<text:span text:style-name="{concat($style-id, 'T', count(preceding::ss:Data[child::html:*]), '_', position())}">
6975						<xsl:copy-of select="text()"/>
6976					</text:span>
6977				</xsl:for-each>
6978			</xsl:when>
6979			<xsl:when test="contains(key('Style', $style-id)/ss:Font/@ss:VerticalAlign, 'script')">
6980				<text:span text:style-name="{concat($style-id, 'T0')}">
6981					<xsl:choose>
6982						<xsl:when test="@ss:HRef">
6983							<text:a xlink:href="{@ss:HRef}">
6984								<xsl:value-of select="ss:Data"/>
6985							</text:a>
6986						</xsl:when>
6987						<xsl:otherwise>
6988							<xsl:value-of select="ss:Data"/>
6989						</xsl:otherwise>
6990					</xsl:choose>
6991				</text:span>
6992			</xsl:when>
6993			<xsl:when test="@ss:HRef">
6994				<text:a xlink:href="{@ss:HRef}">
6995					<xsl:value-of select="ss:Data"/>
6996				</text:a>
6997			</xsl:when>
6998			<xsl:otherwise>
6999				<xsl:value-of select="ss:Data"/>
7000			</xsl:otherwise>
7001		</xsl:choose>
7002	</xsl:template>
7003	<xsl:template name="get-condition-dependent-cell-attributes">
7004		<xsl:param name="condition-pos-str"/>
7005		<xsl:param name="current-pos-str"/>
7006		<xsl:variable name="temp-str">
7007			<xsl:call-template name="condition-str">
7008				<xsl:with-param name="param-str" select="substring-before($condition-pos-str,$current-pos-str)"/>
7009			</xsl:call-template>
7010		</xsl:variable>
7011		<xsl:variable name="style-name">
7012			<xsl:choose>
7013				<xsl:when test="contains($condition-pos-str, $current-pos-str) and starts-with($temp-str, 'c')">
7014					<xsl:value-of select="concat(@ss:StyleID, '-ce', substring-after($temp-str, 'c'))"/>
7015				</xsl:when>
7016				<xsl:otherwise>
7017					<xsl:choose>
7018						<xsl:when test="@ss:StyleID">
7019							<xsl:value-of select="@ss:StyleID"/>
7020						</xsl:when>
7021						<xsl:when test="../@ss:StyleID">
7022							<xsl:value-of select="../@ss:StyleID"/>
7023						</xsl:when>
7024						<xsl:when test="../../@ss:StyleID">
7025							<xsl:value-of select="../../@ss:StyleID"/>
7026						</xsl:when>
7027					</xsl:choose>
7028				</xsl:otherwise>
7029			</xsl:choose>
7030		</xsl:variable>
7031		<xsl:choose>
7032			<xsl:when test="starts-with($style-name, 'val')">
7033				<xsl:attribute name="table:content-validation-name">
7034					<xsl:value-of select="$style-name"/>
7035				</xsl:attribute>
7036			</xsl:when>
7037			<xsl:when test="not($style-name = '')">
7038				<xsl:attribute name="table:style-name">
7039					<xsl:value-of select="$style-name"/>
7040				</xsl:attribute>
7041			</xsl:when>
7042		</xsl:choose>
7043		<!-- maybe multi functions occur at same time in the same Cell, such as ConditionalFormatting and DataValidation -->
7044		<xsl:if test="contains($condition-pos-str, $current-pos-str)">
7045			<xsl:choose>
7046				<xsl:when test="starts-with($temp-str, 'v')">
7047					<xsl:attribute name="table:content-validation-name">
7048						<xsl:value-of select="concat('val', substring-after($temp-str, 'v'))"/>
7049					</xsl:attribute>
7050				</xsl:when>
7051				<xsl:otherwise>
7052					<xsl:variable name="after-str" select="substring-after($condition-pos-str, $current-pos-str)"/>
7053					<xsl:if test="contains( $after-str, $current-pos-str)">
7054						<xsl:variable name="temp-str-2">
7055							<xsl:call-template name="condition-str">
7056								<xsl:with-param name="param-str" select="substring-before( $after-str,$current-pos-str)"/>
7057							</xsl:call-template>
7058						</xsl:variable>
7059						<xsl:if test="starts-with( $temp-str-2, 'v')">
7060							<xsl:attribute name="table:content-validation-name">
7061								<xsl:value-of select="concat('val', substring-after($temp-str-2, 'v'))"/>
7062							</xsl:attribute>
7063						</xsl:if>
7064					</xsl:if>
7065				</xsl:otherwise>
7066			</xsl:choose>
7067		</xsl:if>
7068	</xsl:template>
7069	<xsl:template name="validation-row-column-string">
7070		<!-- returns a string with structer,including row\column position by extraction from x:DataValidation -->
7071		<xsl:param name="last"/>
7072		<xsl:param name="total"/>
7073		<xsl:param name="index"/>
7074		<xsl:variable name="table-pos" select="count(preceding-sibling::ss:Worksheet)+1"/>
7075		<xsl:variable name="current">
7076			<xsl:call-template name="parse-range">
7077				<xsl:with-param name="range-value" select="./x:DataValidation[position() = $index]/x:Range"/>
7078			</xsl:call-template>
7079		</xsl:variable>
7080		<xsl:variable name="current-value" select="concat('(v',$index,':', $current,');')"/>
7081		<xsl:if test="$index &lt; $total">
7082			<xsl:call-template name="validation-row-column-string">
7083				<xsl:with-param name="last" select="concat($last, $current-value)"/>
7084				<xsl:with-param name="total" select="$total"/>
7085				<xsl:with-param name="index" select="$index + 1"/>
7086			</xsl:call-template>
7087		</xsl:if>
7088		<xsl:if test="$index = $total">
7089			<xsl:value-of select="concat($last, $current-value)"/>
7090		</xsl:if>
7091	</xsl:template>
7092	<xsl:template name="condition-row-column-string">
7093		<!-- returns a string with structer,including row\column position by extraction from x:ConditionalFormatting -->
7094		<xsl:param name="last"/>
7095		<xsl:param name="total"/>
7096		<xsl:param name="index"/>
7097		<xsl:variable name="table-pos" select="count(preceding-sibling::ss:Worksheet)+1"/>
7098		<xsl:variable name="current">
7099			<xsl:call-template name="parse-range">
7100				<xsl:with-param name="range-value" select="./x:ConditionalFormatting[position() = $index]/x:Range"/>
7101			</xsl:call-template>
7102		</xsl:variable>
7103		<xsl:variable name="current-value" select="concat('(c',$table-pos,'-',$index,':', $current,');')"/>
7104		<xsl:if test="$index &lt; $total">
7105			<xsl:call-template name="condition-row-column-string">
7106				<xsl:with-param name="last" select="concat($last, $current-value)"/>
7107				<xsl:with-param name="total" select="$total"/>
7108				<xsl:with-param name="index" select="$index + 1"/>
7109			</xsl:call-template>
7110		</xsl:if>
7111		<xsl:if test="$index = $total">
7112			<xsl:value-of select="concat($last, $current-value)"/>
7113		</xsl:if>
7114	</xsl:template>
7115	<xsl:template name="parse-range">
7116		<!-- returns a string,input param:the value of x:Range -->
7117		<xsl:param name="range-value"/>
7118		<xsl:param name="last"/>
7119		<xsl:variable name="first-pit">
7120			<xsl:choose>
7121				<xsl:when test="contains($range-value,',')">
7122					<xsl:value-of select="substring-before($range-value,',')"/>
7123				</xsl:when>
7124				<xsl:otherwise>
7125					<xsl:value-of select="$range-value"/>
7126				</xsl:otherwise>
7127			</xsl:choose>
7128		</xsl:variable>
7129		<xsl:variable name="current">
7130			<xsl:choose>
7131				<xsl:when test="contains($first-pit,':')">
7132					<xsl:variable name="R-start" select="substring-before(substring-after($first-pit,'R'),'C')"/>
7133					<xsl:variable name="C-start" select="substring-before(substring-after($first-pit,'C'),':')"/>
7134					<xsl:variable name="second-pit" select="substring-after($first-pit,':')"/>
7135					<xsl:variable name="R-end" select="substring-before(substring-after($second-pit,'R'),'C')"/>
7136					<xsl:variable name="C-end" select="substring-after($second-pit,'C')"/>
7137					<xsl:variable name="the-str">
7138						<xsl:call-template name="condition-rc-str">
7139							<xsl:with-param name="r-start" select="$R-start"/>
7140							<xsl:with-param name="r-end" select="$R-end"/>
7141							<xsl:with-param name="c-start" select="$C-start"/>
7142							<xsl:with-param name="c-end" select="$C-end"/>
7143							<xsl:with-param name="last" select="''"/>
7144						</xsl:call-template>
7145					</xsl:variable>
7146					<xsl:value-of select="$the-str"/>
7147				</xsl:when>
7148				<xsl:otherwise>
7149					<xsl:value-of select="concat($first-pit,',')"/>
7150				</xsl:otherwise>
7151			</xsl:choose>
7152		</xsl:variable>
7153		<xsl:choose>
7154			<xsl:when test="contains($range-value,',')">
7155				<xsl:call-template name="parse-range">
7156					<xsl:with-param name="range-value" select="substring-after($range-value,',')"/>
7157					<xsl:with-param name="last" select="concat($last,$current)"/>
7158				</xsl:call-template>
7159			</xsl:when>
7160			<xsl:otherwise>
7161				<xsl:value-of select="concat($last,$current)"/>
7162			</xsl:otherwise>
7163		</xsl:choose>
7164	</xsl:template>
7165	<xsl:template name="condition-rc-str">
7166		<!-- dealing the range of row\column -->
7167		<xsl:param name="r-start"/>
7168		<xsl:param name="r-end"/>
7169		<xsl:param name="c-start"/>
7170		<xsl:param name="c-end"/>
7171		<xsl:param name="last"/>
7172		<xsl:variable name="current">
7173			<xsl:call-template name="condition-c-str">
7174				<xsl:with-param name="rc-str" select="concat('R',$r-start)"/>
7175				<xsl:with-param name="start" select="$c-start"/>
7176				<xsl:with-param name="end" select="$c-end"/>
7177				<xsl:with-param name="last" select="''"/>
7178			</xsl:call-template>
7179		</xsl:variable>
7180		<xsl:if test="$r-start &lt; $r-end">
7181			<xsl:call-template name="condition-rc-str">
7182				<xsl:with-param name="r-start" select="$r-start + 1"/>
7183				<xsl:with-param name="r-end" select="$r-end"/>
7184				<xsl:with-param name="c-start" select="$c-start"/>
7185				<xsl:with-param name="c-end" select="$c-end"/>
7186				<xsl:with-param name="last" select="concat($last,$current)"/>
7187			</xsl:call-template>
7188		</xsl:if>
7189		<xsl:if test="$r-start = $r-end">
7190			<xsl:value-of select="concat($last,$current)"/>
7191		</xsl:if>
7192	</xsl:template>
7193	<xsl:template name="condition-c-str">
7194		<!-- return value for the template condition-rc-str -->
7195		<xsl:param name="rc-str"/>
7196		<xsl:param name="start"/>
7197		<xsl:param name="end"/>
7198		<xsl:param name="last"/>
7199		<xsl:variable name="current" select="concat($rc-str,'C',$start,',')"/>
7200		<xsl:if test="$start &lt; $end">
7201			<xsl:call-template name="condition-c-str">
7202				<xsl:with-param name="rc-str" select="$rc-str"/>
7203				<xsl:with-param name="start" select="$start + 1"/>
7204				<xsl:with-param name="end" select="$end"/>
7205				<xsl:with-param name="last" select="concat($last,$current)"/>
7206			</xsl:call-template>
7207		</xsl:if>
7208		<xsl:if test="$start = $end">
7209			<xsl:value-of select="concat($last,$current)"/>
7210		</xsl:if>
7211	</xsl:template>
7212	<xsl:template match="ss:Data">
7213		<xsl:for-each select="descendant-or-self::*[namespace-uri()='http://www.w3.org/TR/REC-html40'][string-length(text()) != 0]">
7214			<style:style style:name="{concat(ancestor::ss:Cell/@ss:StyleID,'T',count(preceding::ss:Data[child::html:*]), '_', position())}" style:family="text">
7215				<xsl:element name="style:text-properties">
7216					<xsl:if test="ancestor-or-self::html:Font/@html:Face">
7217						<xsl:attribute name="style:font-name">
7218							<xsl:value-of select="ancestor-or-self::html:Font/@html:Face"/>
7219						</xsl:attribute>
7220					</xsl:if>
7221					<xsl:if test="ancestor-or-self::html:Font/@html:Size">
7222						<xsl:attribute name="fo:font-size">
7223							<xsl:value-of select="concat(ancestor-or-self::html:Font/@html:Size,'pt')"/>
7224						</xsl:attribute>
7225						<xsl:attribute name="style:font-size-asian">
7226							<xsl:value-of select="concat(ancestor-or-self::html:Font/@html:Size,'pt')"/>
7227						</xsl:attribute>
7228						<xsl:attribute name="style:font-size-complex">
7229							<xsl:value-of select="concat(ancestor-or-self::html:Font/@html:Size,'pt')"/>
7230						</xsl:attribute>
7231					</xsl:if>
7232					<xsl:if test="ancestor-or-self::html:Font/@html:Color">
7233						<xsl:attribute name="fo:color">
7234							<xsl:value-of select="ancestor-or-self::html:Font/@html:Color"/>
7235						</xsl:attribute>
7236					</xsl:if>
7237					<xsl:if test="ancestor-or-self::html:B">
7238						<xsl:attribute name="fo:font-weight">bold</xsl:attribute>
7239						<xsl:attribute name="style:font-weight-asian">bold</xsl:attribute>
7240						<xsl:attribute name="style:font-weight-complex">bold</xsl:attribute>
7241					</xsl:if>
7242					<xsl:if test="ancestor-or-self::html:I">
7243						<xsl:attribute name="fo:font-style">italic</xsl:attribute>
7244						<xsl:attribute name="style:font-style-asian">italic</xsl:attribute>
7245						<xsl:attribute name="style:font-style-complex">italic</xsl:attribute>
7246					</xsl:if>
7247					<xsl:if test="ancestor-or-self::html:U">
7248						<xsl:attribute name="style:text-underline-type">single</xsl:attribute>
7249					</xsl:if>
7250					<xsl:if test="ancestor-or-self::html:S">
7251						<xsl:attribute name="style:text-line-through-style">solid</xsl:attribute>
7252					</xsl:if>
7253					<xsl:if test="ancestor-or-self::html:Sup">
7254						<xsl:attribute name="style:text-position">33% 58%</xsl:attribute>
7255					</xsl:if>
7256					<xsl:if test="ancestor-or-self::html:Sub">
7257						<xsl:attribute name="style:text-position">-33% 58%</xsl:attribute>
7258					</xsl:if>
7259				</xsl:element>
7260			</style:style>
7261		</xsl:for-each>
7262	</xsl:template>
7263	<xsl:template name="get-pos-content">
7264		<xsl:param name="content"/>
7265		<xsl:param name="pos"/>
7266		<xsl:choose>
7267			<xsl:when test="$pos = 'left'">
7268				<xsl:choose>
7269					<xsl:when test="contains($content,'&amp;C')">
7270						<xsl:value-of select="substring-before( substring-after( $content, '&amp;L'), '&amp;C')"/>
7271					</xsl:when>
7272					<xsl:when test="contains($content,'&amp;R')">
7273						<xsl:value-of select="substring-before( substring-after( $content, '&amp;L'), '&amp;R')"/>
7274					</xsl:when>
7275					<xsl:when test="contains($content,'&amp;L')">
7276						<xsl:value-of select="substring-after( $content, '&amp;L')"/>
7277					</xsl:when>
7278					<xsl:otherwise/>
7279				</xsl:choose>
7280			</xsl:when>
7281			<xsl:when test="$pos = 'center'">
7282				<xsl:choose>
7283					<xsl:when test="contains($content,'&amp;R')">
7284						<xsl:value-of select="substring-before( substring-after( $content, '&amp;C'), '&amp;R')"/>
7285					</xsl:when>
7286					<xsl:when test="contains($content,'&amp;C')">
7287						<xsl:value-of select="substring-after( $content, '&amp;C')"/>
7288					</xsl:when>
7289					<xsl:when test="contains($content,'&amp;L')"/>
7290					<xsl:otherwise>
7291						<xsl:value-of select="$content"/>
7292					</xsl:otherwise>
7293				</xsl:choose>
7294			</xsl:when>
7295			<xsl:when test="$pos = 'right'">
7296				<xsl:value-of select="substring-after( $content, '&amp;R')"/>
7297			</xsl:when>
7298		</xsl:choose>
7299	</xsl:template>
7300	<xsl:template match="@x:Data">
7301		<xsl:variable name="style-name-header">
7302			<xsl:value-of select="concat(ancestor::ss:Worksheet/@ss:Name, substring(name(..),1,1))"/>
7303		</xsl:variable>
7304		<xsl:variable name="left-style-data">
7305			<xsl:call-template name="get-pos-content">
7306				<xsl:with-param name="content" select="."/>
7307				<xsl:with-param name="pos" select="'left'"/>
7308			</xsl:call-template>
7309		</xsl:variable>
7310		<xsl:if test="string-length($left-style-data)&gt;0 and contains($left-style-data,'&amp;')">
7311			<xsl:call-template name="create-header-footer-style">
7312				<xsl:with-param name="style-name-header" select="concat($style-name-header,'L')"/>
7313				<xsl:with-param name="style-data" select="$left-style-data"/>
7314				<xsl:with-param name="index" select="0"/>
7315				<xsl:with-param name="current-pos" select="1"/>
7316			</xsl:call-template>
7317		</xsl:if>
7318		<xsl:variable name="center-style-data">
7319			<xsl:call-template name="get-pos-content">
7320				<xsl:with-param name="content" select="."/>
7321				<xsl:with-param name="pos" select="'center'"/>
7322			</xsl:call-template>
7323		</xsl:variable>
7324		<xsl:if test="string-length($center-style-data)&gt;0 and contains($center-style-data,'&amp;')">
7325			<xsl:call-template name="create-header-footer-style">
7326				<xsl:with-param name="style-name-header" select="concat($style-name-header,'C')"/>
7327				<xsl:with-param name="style-data" select="$center-style-data"/>
7328				<xsl:with-param name="index" select="0"/>
7329				<xsl:with-param name="current-pos" select="1"/>
7330			</xsl:call-template>
7331		</xsl:if>
7332		<xsl:variable name="right-style-data">
7333			<xsl:call-template name="get-pos-content">
7334				<xsl:with-param name="content" select="."/>
7335				<xsl:with-param name="pos" select="'right'"/>
7336			</xsl:call-template>
7337		</xsl:variable>
7338		<xsl:if test="string-length($right-style-data)&gt;0 and contains($right-style-data,'&amp;')">
7339			<xsl:call-template name="create-header-footer-style">
7340				<xsl:with-param name="style-name-header" select="concat($style-name-header,'R')"/>
7341				<xsl:with-param name="style-data" select="$right-style-data"/>
7342				<xsl:with-param name="index" select="0"/>
7343				<xsl:with-param name="current-pos" select="1"/>
7344			</xsl:call-template>
7345		</xsl:if>
7346	</xsl:template>
7347	<xsl:template name="create-header-footer-style">
7348		<xsl:param name="style-name-header"/>
7349		<xsl:param name="style-data"/>
7350		<xsl:param name="index"/>
7351		<xsl:param name="current-pos"/>
7352		<xsl:variable name="current-style-data">
7353			<xsl:value-of select="substring($style-data,$current-pos)"/>
7354		</xsl:variable>
7355		<xsl:choose>
7356			<xsl:when test="starts-with($current-style-data,'&amp;D') or starts-with($current-style-data,'&amp;T') or starts-with($current-style-data,'&amp;P') or starts-with($current-style-data,'&amp;N') or starts-with($current-style-data,'&amp;A') or starts-with($current-style-data,'&amp;F') or starts-with($current-style-data,'&amp;Z')">
7357				<xsl:call-template name="create-header-footer-style">
7358					<xsl:with-param name="style-name-header" select="$style-name-header"/>
7359					<xsl:with-param name="style-data" select="$style-data"/>
7360					<xsl:with-param name="index" select="$index"/>
7361					<xsl:with-param name="current-pos" select="$current-pos +2"/>
7362				</xsl:call-template>
7363			</xsl:when>
7364			<xsl:when test="starts-with($current-style-data,'&amp;')">
7365				<xsl:element name="style:style">
7366					<xsl:attribute name="style:name">
7367						<xsl:value-of select="concat($style-name-header,$index)"/>
7368					</xsl:attribute>
7369					<xsl:attribute name="style:family">text</xsl:attribute>
7370					<xsl:element name="style:text-properties">
7371						<xsl:call-template name="process-header-footer-style-properties">
7372							<xsl:with-param name="style-data" select="$style-data"/>
7373							<xsl:with-param name="current-pos" select="$current-pos"/>
7374						</xsl:call-template>
7375					</xsl:element>
7376				</xsl:element>
7377				<xsl:variable name="next-style-header-pos">
7378					<xsl:call-template name="get-current-content-pos">
7379						<xsl:with-param name="style-data" select="$style-data"/>
7380						<xsl:with-param name="current-pos" select="$current-pos"/>
7381					</xsl:call-template>
7382				</xsl:variable>
7383				<xsl:call-template name="create-header-footer-style">
7384					<xsl:with-param name="style-name-header" select="$style-name-header"/>
7385					<xsl:with-param name="style-data" select="$style-data"/>
7386					<xsl:with-param name="index" select="$index+1"/>
7387					<xsl:with-param name="current-pos" select="$next-style-header-pos"/>
7388				</xsl:call-template>
7389			</xsl:when>
7390			<xsl:when test="contains($current-style-data,'&amp;')">
7391				<xsl:variable name="temp" select="substring-before($current-style-data,'&amp;')"/>
7392				<xsl:call-template name="create-header-footer-style">
7393					<xsl:with-param name="style-name-header" select="$style-name-header"/>
7394					<xsl:with-param name="style-data" select="$style-data"/>
7395					<xsl:with-param name="index" select="$index"/>
7396					<xsl:with-param name="current-pos" select="string-length($temp)+$current-pos"/>
7397				</xsl:call-template>
7398			</xsl:when>
7399			<xsl:otherwise/>
7400		</xsl:choose>
7401	</xsl:template>
7402	<xsl:template name="process-header-footer-style-properties">
7403		<xsl:param name="style-data"/>
7404		<xsl:param name="current-pos"/>
7405		<xsl:variable name="current-style-data">
7406			<xsl:value-of select="substring($style-data,$current-pos)"/>
7407		</xsl:variable>
7408		<xsl:choose>
7409			<!-- stack operations necessary -->
7410			<xsl:when test="starts-with($current-style-data,'&amp;&quot;')">
7411				<xsl:attribute name="style:font-name">
7412					<xsl:value-of select="substring-before(substring-after($current-style-data,'&amp;&quot;'),',')"/>
7413				</xsl:attribute>
7414				<xsl:if test="contains(substring-before(substring-after($current-style-data,','),'&quot;'),'Bold')">
7415					<xsl:attribute name="fo:font-weight">bold</xsl:attribute>
7416					<xsl:attribute name="style:font-weight-asian">bold</xsl:attribute>
7417					<xsl:attribute name="style:font-weight-complex">bold</xsl:attribute>
7418				</xsl:if>
7419				<xsl:if test="contains(substring-before(substring-after($current-style-data,','),'&quot;'),'Italic')">
7420					<xsl:attribute name="fo:font-style">italic</xsl:attribute>
7421					<xsl:attribute name="style:font-style-asian">italic</xsl:attribute>
7422					<xsl:attribute name="style:font-style-complex">italic</xsl:attribute>
7423				</xsl:if>
7424				<xsl:variable name="temp" select="substring-before(substring($style-data,$current-pos+2),'&quot;')"/>
7425				<xsl:call-template name="process-header-footer-style-properties">
7426					<xsl:with-param name="style-data" select="$style-data"/>
7427					<xsl:with-param name="current-pos" select="string-length($temp)+$current-pos+3"/>
7428				</xsl:call-template>
7429			</xsl:when>
7430			<xsl:when test="starts-with($current-style-data,'&amp;0') or starts-with($current-style-data,'&amp;1') or starts-with($current-style-data,'&amp;2') or starts-with($current-style-data,'&amp;3') or starts-with($current-style-data,'&amp;4') or starts-with($current-style-data,'&amp;5') or starts-with($current-style-data,'&amp;6') or starts-with($current-style-data,'&amp;7') or starts-with($current-style-data,'&amp;8') or starts-with($current-style-data,'&amp;9')">
7431				<xsl:variable name="font-size-length">
7432					<xsl:call-template name="get-digit-length">
7433						<xsl:with-param name="complexive-string" select="substring-after($current-style-data,'&amp;')"/>
7434					</xsl:call-template>
7435				</xsl:variable>
7436				<xsl:attribute name="fo:font-size">
7437					<xsl:value-of select="concat(substring($current-style-data,2,$font-size-length),'pt')"/>
7438				</xsl:attribute>
7439				<xsl:call-template name="process-header-footer-style-properties">
7440					<xsl:with-param name="style-data" select="$style-data"/>
7441					<xsl:with-param name="current-pos" select="$current-pos + 1 + $font-size-length"/>
7442				</xsl:call-template>
7443			</xsl:when>
7444			<!-- dont' consider tangled or adjoined '&X' and '&Y', '&U' & '&E', processing-check is necessary, too complex. :( -->
7445			<xsl:when test="starts-with($current-style-data,'&amp;X')">
7446				<xsl:variable name="superscript-count-before">
7447					<xsl:call-template name="get-substyle-count-in-data">
7448						<xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
7449						<xsl:with-param name="substyle" select="'&amp;X'"/>
7450						<xsl:with-param name="count" select="0"/>
7451					</xsl:call-template>
7452				</xsl:variable>
7453				<xsl:if test="$superscript-count-before mod 2 = 0">
7454					<xsl:attribute name="style:text-position">33% 58%</xsl:attribute>
7455				</xsl:if>
7456				<xsl:call-template name="process-header-footer-style-properties">
7457					<xsl:with-param name="style-data" select="$style-data"/>
7458					<xsl:with-param name="current-pos" select="$current-pos + 2"/>
7459				</xsl:call-template>
7460			</xsl:when>
7461			<xsl:when test="starts-with($current-style-data,'&amp;B')">
7462				<xsl:variable name="subscript-count-before">
7463					<xsl:call-template name="get-substyle-count-in-data">
7464						<xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
7465						<xsl:with-param name="substyle" select="'&amp;B'"/>
7466						<xsl:with-param name="count" select="0"/>
7467					</xsl:call-template>
7468				</xsl:variable>
7469				<xsl:if test="$subscript-count-before mod 2 = 0">
7470					<xsl:attribute name="fo:font-weight">bold</xsl:attribute>
7471					<xsl:attribute name="style:font-weight-asian">bold</xsl:attribute>
7472					<xsl:attribute name="style:font-weight-complex">bold</xsl:attribute>
7473				</xsl:if>
7474				<xsl:call-template name="process-header-footer-style-properties">
7475					<xsl:with-param name="style-data" select="$style-data"/>
7476					<xsl:with-param name="current-pos" select="$current-pos + 2"/>
7477				</xsl:call-template>
7478			</xsl:when>
7479			<xsl:when test="starts-with($current-style-data,'&amp;Y')">
7480				<xsl:variable name="subscript-count-before">
7481					<xsl:call-template name="get-substyle-count-in-data">
7482						<xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
7483						<xsl:with-param name="substyle" select="'&amp;Y'"/>
7484						<xsl:with-param name="count" select="0"/>
7485					</xsl:call-template>
7486				</xsl:variable>
7487				<xsl:if test="$subscript-count-before mod 2 = 0">
7488					<xsl:attribute name="style:text-position">-33% 58%</xsl:attribute>
7489				</xsl:if>
7490				<xsl:call-template name="process-header-footer-style-properties">
7491					<xsl:with-param name="style-data" select="$style-data"/>
7492					<xsl:with-param name="current-pos" select="$current-pos + 2"/>
7493				</xsl:call-template>
7494			</xsl:when>
7495			<xsl:when test="starts-with($current-style-data,'&amp;S')">
7496				<xsl:variable name="strikethrough-count-before">
7497					<xsl:call-template name="get-substyle-count-in-data">
7498						<xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
7499						<xsl:with-param name="substyle" select="'&amp;S'"/>
7500						<xsl:with-param name="count" select="0"/>
7501					</xsl:call-template>
7502				</xsl:variable>
7503				<xsl:if test="$strikethrough-count-before mod 2 = 0">
7504					<xsl:attribute name="style:text-line-through-style">solid</xsl:attribute>
7505				</xsl:if>
7506				<xsl:call-template name="process-header-footer-style-properties">
7507					<xsl:with-param name="style-data" select="$style-data"/>
7508					<xsl:with-param name="current-pos" select="$current-pos + 2"/>
7509				</xsl:call-template>
7510			</xsl:when>
7511			<xsl:when test="starts-with($current-style-data,'&amp;U')">
7512				<xsl:variable name="single-underline-count-before">
7513					<xsl:call-template name="get-substyle-count-in-data">
7514						<xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
7515						<xsl:with-param name="substyle" select="'&amp;U'"/>
7516						<xsl:with-param name="count" select="0"/>
7517					</xsl:call-template>
7518				</xsl:variable>
7519				<xsl:if test="$single-underline-count-before mod 2 = 0">
7520					<xsl:attribute name="style:text-underline-type">single</xsl:attribute>
7521				</xsl:if>
7522				<xsl:call-template name="process-header-footer-style-properties">
7523					<xsl:with-param name="style-data" select="$style-data"/>
7524					<xsl:with-param name="current-pos" select="$current-pos + 2"/>
7525				</xsl:call-template>
7526			</xsl:when>
7527			<xsl:when test="starts-with($current-style-data,'&amp;E')">
7528				<xsl:variable name="double-underline-count-before">
7529					<xsl:call-template name="get-substyle-count-in-data">
7530						<xsl:with-param name="style-data" select="substring($style-data,1,$current-pos)"/>
7531						<xsl:with-param name="substyle" select="'&amp;E'"/>
7532						<xsl:with-param name="count" select="0"/>
7533					</xsl:call-template>
7534				</xsl:variable>
7535				<xsl:if test="$double-underline-count-before mod 2 = 0">
7536					<xsl:attribute name="style:text-underline-type">double</xsl:attribute>
7537				</xsl:if>
7538				<xsl:call-template name="process-header-footer-style-properties">
7539					<xsl:with-param name="style-data" select="$style-data"/>
7540					<xsl:with-param name="current-pos" select="$current-pos + 2"/>
7541				</xsl:call-template>
7542			</xsl:when>
7543			<xsl:otherwise/>
7544		</xsl:choose>
7545	</xsl:template>
7546	<xsl:template name="get-substyle-count-in-data">
7547		<xsl:param name="style-data"/>
7548		<xsl:param name="substyle"/>
7549		<xsl:param name="count"/>
7550		<xsl:choose>
7551			<xsl:when test="contains($style-data,$substyle)">
7552				<xsl:call-template name="get-substyle-count-in-data">
7553					<xsl:with-param name="style-data" select="substring-after($style-data,$substyle)"/>
7554					<xsl:with-param name="substyle" select="$substyle"/>
7555					<xsl:with-param name="count" select="$count+1"/>
7556				</xsl:call-template>
7557			</xsl:when>
7558			<xsl:otherwise>
7559				<xsl:value-of select="$count"/>
7560			</xsl:otherwise>
7561		</xsl:choose>
7562	</xsl:template>
7563	<xsl:template name="get-current-content-pos">
7564		<xsl:param name="style-data"/>
7565		<xsl:param name="current-pos"/>
7566		<xsl:variable name="current-style-data">
7567			<xsl:value-of select="substring($style-data,$current-pos)"/>
7568		</xsl:variable>
7569		<xsl:choose>
7570			<xsl:when test="starts-with($current-style-data,'&amp;X') or starts-with($current-style-data,'&amp;Y') or starts-with($current-style-data,'&amp;S') or starts-with($current-style-data,'&amp;U') or starts-with($current-style-data,'&amp;E') or starts-with($current-style-data,'&amp;B')">
7571				<xsl:call-template name="get-current-content-pos">
7572					<xsl:with-param name="style-data" select="$style-data"/>
7573					<xsl:with-param name="current-pos" select="$current-pos+2"/>
7574				</xsl:call-template>
7575			</xsl:when>
7576			<xsl:when test="starts-with($current-style-data,'&amp;0') or starts-with($current-style-data,'&amp;1') or starts-with($current-style-data,'&amp;2') or starts-with($current-style-data,'&amp;3') or starts-with($current-style-data,'&amp;4') or starts-with($current-style-data,'&amp;5') or starts-with($current-style-data,'&amp;6') or starts-with($current-style-data,'&amp;7') or starts-with($current-style-data,'&amp;8') or starts-with($current-style-data,'&amp;9')">
7577				<xsl:variable name="font-size-length">
7578					<xsl:call-template name="get-digit-length">
7579						<xsl:with-param name="complexive-string" select="substring-after($current-style-data,'&amp;')"/>
7580					</xsl:call-template>
7581				</xsl:variable>
7582				<xsl:call-template name="get-current-content-pos">
7583					<xsl:with-param name="style-data" select="$style-data"/>
7584					<xsl:with-param name="current-pos" select="$current-pos+1+$font-size-length"/>
7585				</xsl:call-template>
7586			</xsl:when>
7587			<xsl:when test="starts-with($current-style-data,'&amp;&quot;')">
7588				<xsl:variable name="temp" select="substring-before(substring($style-data,$current-pos+2),'&quot;')"/>
7589				<xsl:call-template name="get-current-content-pos">
7590					<xsl:with-param name="style-data" select="$style-data"/>
7591					<xsl:with-param name="current-pos" select="string-length($temp)+$current-pos+3"/>
7592				</xsl:call-template>
7593			</xsl:when>
7594			<xsl:otherwise>
7595				<xsl:value-of select="$current-pos"/>
7596			</xsl:otherwise>
7597		</xsl:choose>
7598	</xsl:template>
7599	<!-- OASIS OpenDocument Format change:
7600		Excel   "=RC4*6"
7601		OOoXML "=$D22*6"
7602	 OASIS XML "oooc:=[.$D22]*6" -->
7603	<xsl:template name="translate-expression">
7604		<!--  return position or range for formula or other -->
7605		<xsl:param name="cell-row-pos"/>
7606		<!-- the position in row (vertical) of cell -->
7607		<xsl:param name="cell-column-pos"/>
7608		<!-- the position in column (horizontal of cell -->
7609		<xsl:param name="expression"/>
7610		<!-- recomposed expression containing cell positions after every conversion -->
7611		<xsl:param name="is-range-mode" select="false()"/>
7612		<!-- as mode changes a '[.' resp. ']' is written out  -->
7613		<xsl:param name="return-value"/>
7614		<!-- expression of table:cell-range-address is different than formula (e.g. no prefix)  -->
7615		<xsl:param name="isRangeAddress"/>
7616		<!-- determines if the currently processed expression is relative -->
7617		<xsl:param name="isRelative" select="false()" />
7618
7619		<!-- value to be given out later -->
7620		<!-- to judge whether this input expression contains any cell position to convert -->
7621		<xsl:variable name="temp-range">
7622			<xsl:choose>
7623				<xsl:when test="$expression != ''">
7624					<xsl:call-template name="parse-range-name">
7625						<xsl:with-param name="expression" select="$expression"/>
7626						<xsl:with-param name="return-value" select="''"/>
7627					</xsl:call-template>
7628				</xsl:when>
7629				<xsl:otherwise>
7630					<xsl:value-of select="''"/>
7631				</xsl:otherwise>
7632			</xsl:choose>
7633		</xsl:variable>
7634		<!-- if $range-type = 1, then range is representing a sheet, function's name or separated symbol, but not cell position,
7635			 or if $range-type = 2, range should be handled because it contains certain cell position.
7636			 The first character marks the type of that expression. -->
7637		<xsl:variable name="range-type">
7638			<xsl:choose>
7639				<xsl:when test="substring($temp-range, 1, 1) = '1'">
7640					<xsl:value-of select="1"/>
7641				</xsl:when>
7642				<xsl:when test="substring($temp-range, 1, 1) = '2'">
7643					<xsl:value-of select="2"/>
7644				</xsl:when>
7645				<xsl:otherwise>
7646					<xsl:value-of select="2"/>
7647				</xsl:otherwise>
7648			</xsl:choose>
7649		</xsl:variable>
7650		<!-- remove that added range type token -->
7651		<xsl:variable name="current-range">
7652			<xsl:value-of select="substring($temp-range, 2)"/>
7653		</xsl:variable>
7654		<xsl:choose>
7655			<xsl:when test="$range-type = 1">
7656				<!-- Nothing to convert, so just join the front and behind strings. -->
7657				<xsl:call-template name="translate-expression">
7658					<xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
7659					<xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
7660					<xsl:with-param name="expression">
7661						<!-- get current converting position from $temp-token or $current-range, then join the expression. -->
7662						<xsl:choose>
7663							<xsl:when test="contains($current-range, '#$')">
7664								<!-- because of recomposing of string, the $current-range may not be the pit
7665							of $expression, so the char #$ should not be used for nominal -->
7666								<xsl:variable name="temp-token">
7667									<xsl:choose>
7668										<xsl:when test="contains($current-range, '\')">
7669											<xsl:value-of select="concat(']', substring-after($current-range, '#$'), &quot;&apos;&quot;)"/>
7670										</xsl:when>
7671										<xsl:otherwise>
7672											<xsl:value-of select="substring-after($current-range, '#$')"/>
7673										</xsl:otherwise>
7674									</xsl:choose>
7675								</xsl:variable>
7676								<xsl:value-of select="substring-after($expression, $temp-token)"/>
7677							</xsl:when>
7678							<xsl:otherwise>
7679								<xsl:value-of select="substring-after($expression, $current-range)"/>
7680							</xsl:otherwise>
7681						</xsl:choose>
7682					</xsl:with-param>
7683					<xsl:with-param name="return-value">
7684						<!-- react on range mode change (when to insert closing ']' or in case of '!' change the mode to RANGE and create open '[' -->
7685						<xsl:choose>
7686							<xsl:when test="$current-range = '=' and $return-value = '' and not($isRangeAddress)">
7687								<xsl:text>oooc:=</xsl:text>
7688							</xsl:when>
7689							<xsl:when test="contains($current-range, '!') and not($isRangeAddress)">
7690								<xsl:value-of select="concat($return-value, '[', $current-range)"/>
7691							</xsl:when>
7692							<xsl:otherwise>
7693								<xsl:choose>
7694									<xsl:when test="$is-range-mode = 'true' and $current-range != ':' and not($isRangeAddress)">
7695										<xsl:value-of select="concat($return-value, ']', substring-before($expression, $current-range), $current-range)"/>
7696									</xsl:when>
7697									<xsl:otherwise>
7698										<xsl:value-of select="concat($return-value, substring-before($expression, $current-range), $current-range)"/>
7699									</xsl:otherwise>
7700								</xsl:choose>
7701							</xsl:otherwise>
7702						</xsl:choose>
7703					</xsl:with-param>
7704					<xsl:with-param name="is-range-mode">
7705						<xsl:choose>
7706							<!-- ! is the separator of worksheet and range
7707								 : is the separator for a cell range -->
7708							<xsl:when test="contains($current-range, '!') or $current-range = ':'">
7709								<xsl:value-of select="true()"/>
7710							</xsl:when>
7711							<xsl:otherwise>
7712								<xsl:value-of select="false()"/>
7713							</xsl:otherwise>
7714						</xsl:choose>
7715					</xsl:with-param>
7716					<xsl:with-param name="isRangeAddress" select="$isRangeAddress"/>
7717				</xsl:call-template>
7718			</xsl:when>
7719			<xsl:otherwise>
7720				<!-- types of range to handle in $current-range, i.e. the cell position expression to convert
7721					1: special cell including row and column; e.g. R4C5
7722					2: whole row; e.g. R3
7723					3: whole column; e.g. C5
7724					4: other name not for cell or row/column; e.g. RANDOM() or something unknown
7725				-->
7726				<xsl:variable name="handle-type">
7727					<xsl:choose>
7728						<xsl:when test="starts-with($current-range, 'R')">
7729							<!-- It's type 1 or type 2 or 4/unknown cell position. -->
7730							<xsl:choose>
7731								<xsl:when test="contains($current-range, 'C')">
7732									<!-- It's type 1, specifying the cell position or 4/unknown -->
7733									<xsl:variable name="part-type-r">
7734										<xsl:call-template name="handle-type-number">
7735											<xsl:with-param name="t-part" select="substring-before( substring-after($current-range, 'R'), 'C')"/>
7736										</xsl:call-template>
7737									</xsl:variable>
7738									<xsl:variable name="part-type-c">
7739										<xsl:call-template name="handle-type-number">
7740											<xsl:with-param name="t-part" select="substring-after($current-range, 'C')"/>
7741										</xsl:call-template>
7742									</xsl:variable>
7743									<xsl:choose>
7744										<xsl:when test="($part-type-r = 1) and ($part-type-c = 1)">
7745											<xsl:value-of select="1"/>
7746										</xsl:when>
7747										<xsl:otherwise>
7748											<xsl:value-of select="4"/>
7749										</xsl:otherwise>
7750									</xsl:choose>
7751								</xsl:when>
7752								<xsl:otherwise>
7753									<!-- It's type 2 specifying the cell position, or 4/unknown. -->
7754									<xsl:variable name="part-type">
7755										<xsl:call-template name="handle-type-number">
7756											<xsl:with-param name="t-part" select="substring-after($current-range, 'R')"/>
7757										</xsl:call-template>
7758									</xsl:variable>
7759									<xsl:choose>
7760										<xsl:when test="$part-type = 1">
7761											<xsl:value-of select="2"/>
7762										</xsl:when>
7763										<xsl:when test="$part-type = 2">
7764											<xsl:value-of select="4"/>
7765										</xsl:when>
7766										<xsl:otherwise>
7767											<xsl:value-of select="4"/>
7768										</xsl:otherwise>
7769									</xsl:choose>
7770								</xsl:otherwise>
7771							</xsl:choose>
7772						</xsl:when>
7773						<xsl:when test="starts-with($current-range, 'C')">
7774							<!-- It's type 3 of cell position, or 4/unknown -->
7775							<xsl:variable name="part-type">
7776								<xsl:call-template name="handle-type-number">
7777									<xsl:with-param name="t-part" select="substring-after($current-range, 'C')"/>
7778								</xsl:call-template>
7779							</xsl:variable>
7780							<xsl:choose>
7781								<xsl:when test="$part-type = 1">
7782									<xsl:value-of select="3"/>
7783								</xsl:when>
7784								<xsl:when test="$part-type = 2">
7785									<xsl:value-of select="4"/>
7786								</xsl:when>
7787								<xsl:otherwise>
7788									<xsl:value-of select="4"/>
7789								</xsl:otherwise>
7790							</xsl:choose>
7791						</xsl:when>
7792						<xsl:otherwise>
7793							<!-- It's type 4, not cell position -->
7794							<xsl:value-of select="4"/>
7795						</xsl:otherwise>
7796					</xsl:choose>
7797				</xsl:variable>
7798				<!-- Start to convert that cell position expression, that cell position unit -->
7799				<xsl:choose>
7800					<xsl:when test="$handle-type = 1">
7801						<!-- It's type 1, e.g. R1C2 -->
7802						<!-- process the row part -->
7803						<xsl:variable name="after-R">
7804							<xsl:value-of select="substring(substring-after($current-range,'R'),1,1)"/>
7805						</xsl:variable>
7806						<xsl:choose>
7807							<!-- found one cell unit -->
7808							<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'">
7809								<xsl:variable name="row-pos">
7810									<xsl:choose>
7811										<xsl:when test="$after-R='['">
7812											<xsl:value-of select="$cell-row-pos+substring-before( substring-after($current-range,'R['),']')"/>
7813										</xsl:when>
7814										<xsl:when test="$after-R='C'">
7815											<xsl:value-of select="$cell-row-pos"/>
7816										</xsl:when>
7817										<xsl:otherwise>
7818											<xsl:value-of select="substring-before(substring-after($current-range,'R'),'C')"/>
7819										</xsl:otherwise>
7820									</xsl:choose>
7821								</xsl:variable>
7822								<xsl:variable name="row-pos-style">
7823									<xsl:choose>
7824										<xsl:when test="$after-R='[' or $after-R='C'">relative</xsl:when>
7825										<xsl:otherwise>absolute</xsl:otherwise>
7826									</xsl:choose>
7827								</xsl:variable>
7828								<!-- process the column part -->
7829								<xsl:variable name="after-C">
7830									<xsl:value-of select="substring(substring-after(substring-after($current-range,'R'),'C'),1,1)"/>
7831								</xsl:variable>
7832								<xsl:variable name="column-digit-length">
7833									<xsl:choose>
7834										<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'">
7835											<xsl:call-template name="get-digit-length">
7836												<xsl:with-param name="complexive-string" select="substring-after(substring-after($current-range,'R'),'C')"/>
7837											</xsl:call-template>
7838										</xsl:when>
7839									</xsl:choose>
7840								</xsl:variable>
7841								<xsl:variable name="column-pos">
7842									<xsl:choose>
7843										<xsl:when test="$after-C='['">
7844											<xsl:value-of select="$cell-column-pos + substring-before(substring-after(substring-after($current-range,'R'),'C['),']')"/>
7845										</xsl:when>
7846										<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'">
7847											<xsl:value-of select="substring(substring-after(substring-after($current-range,'R'),'C'),1,$column-digit-length)"/>
7848										</xsl:when>
7849										<xsl:otherwise>
7850											<xsl:value-of select="$cell-column-pos"/>
7851										</xsl:otherwise>
7852									</xsl:choose>
7853								</xsl:variable>
7854								<xsl:variable name="column-pos-style">
7855									<xsl:choose>
7856										<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>
7857										<xsl:otherwise>relative</xsl:otherwise>
7858									</xsl:choose>
7859								</xsl:variable>
7860								<xsl:variable name="trans-unit">
7861									<xsl:call-template name="translate-unit">
7862										<xsl:with-param name="column-number" select="$column-pos"/>
7863										<xsl:with-param name="row-number" select="$row-pos"/>
7864										<xsl:with-param name="column-pos-style" select="$column-pos-style"/>
7865										<xsl:with-param name="row-pos-style" select="$row-pos-style"/>
7866									</xsl:call-template>
7867								</xsl:variable>
7868								<xsl:variable name="name-unit" select="concat(substring-before($expression, $current-range), $trans-unit)"/>
7869								<xsl:call-template name="translate-expression">
7870									<xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
7871									<xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
7872									<xsl:with-param name="expression" select="substring-after($expression, $current-range)"/>
7873									<xsl:with-param name="return-value">
7874										<xsl:choose>
7875											<xsl:when test="$is-range-mode = 'true'">
7876												<xsl:value-of select="concat($return-value, $name-unit)"/>
7877											</xsl:when>
7878											<xsl:otherwise>
7879												<xsl:value-of select="concat($return-value, '[.', $name-unit)"/>
7880											</xsl:otherwise>
7881										</xsl:choose>
7882									</xsl:with-param>
7883									<xsl:with-param name="is-range-mode" select="true()"/>
7884									<xsl:with-param name="isRangeAddress" select="$isRangeAddress"/>
7885								</xsl:call-template>
7886							</xsl:when>
7887							<xsl:otherwise>
7888								<xsl:variable name="name-unit" select="concat(substring-before($expression, $current-range), translate( substring-before(substring-after($expression, '('),'R'),',!', ';.'))"/>
7889								<xsl:call-template name="translate-expression">
7890									<xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
7891									<xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
7892									<xsl:with-param name="expression" select="substring-after($current-range,'R')"/>
7893									<xsl:with-param name="return-value">
7894										<xsl:choose>
7895											<xsl:when test="$is-range-mode = 'true'">
7896												<xsl:value-of select="concat($return-value, $name-unit)"/>
7897											</xsl:when>
7898											<xsl:otherwise>
7899												<xsl:value-of select="concat($return-value, '[.', $name-unit)"/>
7900											</xsl:otherwise>
7901										</xsl:choose>
7902									</xsl:with-param>
7903									<xsl:with-param name="is-range-mode" select="true()"/>
7904									<xsl:with-param name="isRangeAddress" select="$isRangeAddress"/>
7905								</xsl:call-template>
7906							</xsl:otherwise>
7907						</xsl:choose>
7908					</xsl:when>
7909					<xsl:when test="$handle-type = 2">
7910						<!-- It's type 2, e.g. R3 -->
7911						<!-- process the range only including a whole row -->
7912						<xsl:variable name="after-R">
7913							<xsl:value-of select="substring(substring-after($current-range,'R'),1,1)"/>
7914						</xsl:variable>
7915						<xsl:choose>
7916							<xsl:when test="$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'">
7917								<xsl:variable name="row-number">
7918									<xsl:choose>
7919										<xsl:when test="$after-R = '['">
7920											<xsl:value-of select="substring-before(substring-after($current-range, 'R['), ']')"/>
7921										</xsl:when>
7922										<xsl:otherwise>
7923											<xsl:value-of select="substring-after($current-range, 'R')"/>
7924										</xsl:otherwise>
7925									</xsl:choose>
7926								</xsl:variable>
7927								<xsl:variable name="row-pos">
7928									<xsl:choose>
7929										<xsl:when test="$after-R='['">
7930											<xsl:value-of select="$cell-row-pos + $row-number"/>
7931										</xsl:when>
7932										<xsl:when test="$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'">
7933											<xsl:value-of select="$row-number"/>
7934										</xsl:when>
7935										<xsl:otherwise>
7936											<xsl:value-of select="$cell-row-pos"/>
7937										</xsl:otherwise>
7938									</xsl:choose>
7939								</xsl:variable>
7940								<xsl:variable name="trans-unit1">
7941									<xsl:call-template name="translate-unit">
7942										<xsl:with-param name="column-number" select="1"/>
7943										<xsl:with-param name="row-number" select="$row-pos"/>
7944										<xsl:with-param name="column-pos-style" select="'relative'"/>
7945										<xsl:with-param name="row-pos-style" select="'relative'"/>
7946									</xsl:call-template>
7947								</xsl:variable>
7948								<xsl:variable name="trans-unit2">
7949									<xsl:call-template name="translate-unit">
7950										<xsl:with-param name="column-number" select="256"/>
7951										<xsl:with-param name="row-number" select="$row-pos"/>
7952										<xsl:with-param name="column-pos-style" select="'relative'"/>
7953										<xsl:with-param name="row-pos-style" select="'relative'"/>
7954									</xsl:call-template>
7955								</xsl:variable>
7956								<xsl:variable name="name-unit" select="concat(substring-before($expression, $current-range), $trans-unit1, ':', $trans-unit2)"/>
7957								<xsl:call-template name="translate-expression">
7958									<xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
7959									<xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
7960									<xsl:with-param name="expression" select="substring-after($expression, $current-range)"/>
7961									<xsl:with-param name="return-value">
7962										<xsl:choose>
7963											<xsl:when test="$is-range-mode = 'true'">
7964												<xsl:value-of select="concat($return-value, $name-unit)"/>
7965											</xsl:when>
7966											<xsl:otherwise>
7967												<xsl:value-of select="concat($return-value, '[.', $name-unit)"/>
7968											</xsl:otherwise>
7969										</xsl:choose>
7970									</xsl:with-param>
7971									<xsl:with-param name="is-range-mode" select="true()"/>
7972									<xsl:with-param name="isRangeAddress" select="$isRangeAddress"/>
7973								</xsl:call-template>
7974							</xsl:when>
7975							<xsl:otherwise>
7976								<xsl:variable name="name-unit" select="concat(substring-before($expression, $current-range), translate( substring-before($current-range,'R'),',!', ';.'),'R')"/>
7977								<xsl:call-template name="translate-expression">
7978									<xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
7979									<xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
7980									<xsl:with-param name="expression" select="substring-after($current-range,'R')"/>
7981									<xsl:with-param name="return-value">
7982										<xsl:choose>
7983											<xsl:when test="$is-range-mode = 'true'">
7984												<xsl:value-of select="concat($return-value, $name-unit)"/>
7985											</xsl:when>
7986											<xsl:otherwise>
7987												<xsl:value-of select="concat($return-value, '[.', $name-unit)"/>
7988											</xsl:otherwise>
7989										</xsl:choose>
7990									</xsl:with-param>
7991									<xsl:with-param name="is-range-mode" select="true()"/>
7992									<xsl:with-param name="isRangeAddress" select="$isRangeAddress"/>
7993								</xsl:call-template>
7994							</xsl:otherwise>
7995						</xsl:choose>
7996					</xsl:when>
7997					<xsl:when test="$handle-type = 3">
7998						<!-- It's type 3, e.g. C4 -->
7999						<!-- process the range only including a whole column -->
8000						<xsl:variable name="after-C">
8001							<xsl:value-of select="substring(substring-after($current-range,'C'),1,1)"/>
8002						</xsl:variable>
8003						<xsl:choose>
8004							<xsl:when test="$after-C='[' or $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'">
8005								<xsl:variable name="column-number">
8006									<xsl:choose>
8007										<xsl:when test="$after-C = '['">
8008											<xsl:value-of select="substring-before(substring-after($current-range, 'C['), ']')"/>
8009										</xsl:when>
8010										<xsl:otherwise>
8011											<xsl:value-of select="substring-after($current-range, 'C')"/>
8012										</xsl:otherwise>
8013									</xsl:choose>
8014								</xsl:variable>
8015								<xsl:variable name="column-pos">
8016									<xsl:choose>
8017										<xsl:when test="$after-C='['">
8018											<xsl:value-of select="$cell-column-pos + $column-number"/>
8019										</xsl:when>
8020										<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'">
8021											<xsl:value-of select="$column-number"/>
8022										</xsl:when>
8023										<xsl:otherwise>
8024											<xsl:value-of select="$cell-column-pos"/>
8025										</xsl:otherwise>
8026									</xsl:choose>
8027								</xsl:variable>
8028								<xsl:variable name="trans-unit1">
8029									<xsl:call-template name="translate-unit">
8030										<xsl:with-param name="column-number" select="$column-pos"/>
8031										<xsl:with-param name="row-number" select="1"/>
8032										<xsl:with-param name="column-pos-style" select="'relative'"/>
8033										<xsl:with-param name="row-pos-style" select="'relative'"/>
8034									</xsl:call-template>
8035								</xsl:variable>
8036								<xsl:variable name="trans-unit2">
8037									<xsl:call-template name="translate-unit">
8038										<xsl:with-param name="column-number" select="$column-pos"/>
8039										<xsl:with-param name="row-number" select="65565"/>
8040										<xsl:with-param name="column-pos-style" select="'relative'"/>
8041										<xsl:with-param name="row-pos-style" select="'relative'"/>
8042									</xsl:call-template>
8043								</xsl:variable>
8044								<xsl:variable name="name-unit" select="concat(substring-before($expression, $current-range), $trans-unit1, ':', $trans-unit2)"/>
8045								<xsl:call-template name="translate-expression">
8046									<xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
8047									<xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
8048									<xsl:with-param name="expression" select="substring-after($expression, $current-range)"/>
8049									<xsl:with-param name="return-value">
8050										<xsl:choose>
8051											<xsl:when test="$is-range-mode = 'true'">
8052												<xsl:value-of select="concat($return-value, $name-unit)"/>
8053											</xsl:when>
8054											<xsl:otherwise>
8055												<xsl:value-of select="concat($return-value, '[.', $name-unit)"/>
8056											</xsl:otherwise>
8057										</xsl:choose>
8058									</xsl:with-param>
8059									<xsl:with-param name="is-range-mode" select="true()"/>
8060									<xsl:with-param name="isRangeAddress" select="$isRangeAddress"/>
8061								</xsl:call-template>
8062							</xsl:when>
8063							<xsl:otherwise>
8064								<xsl:variable name="name-unit" select="concat(substring-before($expression, $current-range), translate( substring-before($current-range,'C'),',!', ';.'),'C')"/>
8065								<xsl:call-template name="translate-expression">
8066									<xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
8067									<xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
8068									<xsl:with-param name="expression" select="substring-after($current-range,'C')"/>
8069									<xsl:with-param name="return-value">
8070										<xsl:choose>
8071											<xsl:when test="$is-range-mode = 'true'">
8072												<xsl:value-of select="concat($return-value, $name-unit)"/>
8073											</xsl:when>
8074											<xsl:otherwise>
8075												<xsl:value-of select="concat($return-value, '[.', $name-unit)"/>
8076											</xsl:otherwise>
8077										</xsl:choose>
8078									</xsl:with-param>
8079									<xsl:with-param name="is-range-mode" select="true()"/>
8080									<xsl:with-param name="isRangeAddress" select="$isRangeAddress"/>
8081								</xsl:call-template>
8082							</xsl:otherwise>
8083						</xsl:choose>
8084					</xsl:when>
8085					<xsl:otherwise>
8086						<!-- It's unknown, so just jump over it -->
8087						<xsl:variable name="next-pit" select="substring-after($expression, $current-range)"/>
8088						<xsl:choose>
8089							<xsl:when test="contains($next-pit, '+') or contains($next-pit, '-') or contains($next-pit, '*') or contains($next-pit, '/') or contains($next-pit, ')') or contains($next-pit, '^') or contains($next-pit, ':') or contains($next-pit, '&quot;') or contains($next-pit, ';') or contains($next-pit, ',') or contains($next-pit, '[')">
8090								<xsl:call-template name="translate-expression">
8091									<xsl:with-param name="cell-row-pos" select="$cell-row-pos"/>
8092									<xsl:with-param name="cell-column-pos" select="$cell-column-pos"/>
8093									<xsl:with-param name="expression" select="substring-after($expression, $current-range)"/>
8094									<xsl:with-param name="return-value" select="concat($return-value, substring-before($expression, $current-range), $current-range)"/>
8095									<xsl:with-param name="is-range-mode" select="false()"/>
8096									<xsl:with-param name="isRangeAddress" select="$isRangeAddress"/>
8097								</xsl:call-template>
8098							</xsl:when>
8099							<xsl:otherwise>
8100								<!-- return the final range or formula -->
8101								<xsl:choose>
8102									<!-- in case the closing bracket of the range wasn't set, do it now  -->
8103									<xsl:when test="$is-range-mode = 'true' and $current-range = ''">
8104										<xsl:value-of select="translate( concat($return-value, ']'),',!', ';.')"/>
8105									</xsl:when>
8106									<xsl:otherwise>
8107										<xsl:value-of select="translate( concat($return-value, substring-before($expression, $current-range), $current-range),',!', ';.')"/>
8108									</xsl:otherwise>
8109								</xsl:choose>
8110							</xsl:otherwise>
8111						</xsl:choose>
8112					</xsl:otherwise>
8113				</xsl:choose>
8114			</xsl:otherwise>
8115		</xsl:choose>
8116	</xsl:template>
8117	<xsl:template name="parse-range-name">
8118		<!-- return the string or name for next handle. the type 1 is names of function, sheet, special separated symbol, not to parse as range; type 2 is the range including R/C to be parsed -->
8119		<xsl:param name="expression"/>
8120		<xsl:param name="return-value"/>
8121		<xsl:variable name="first-one" select="substring($expression,1,1)"/>
8122		<xsl:choose>
8123			<xsl:when test="$first-one = '='">
8124				<xsl:choose>
8125					<xsl:when test="string-length(normalize-space($return-value)) &gt; 0">
8126						<xsl:value-of select="concat('2', $return-value)"/>
8127					</xsl:when>
8128					<xsl:otherwise>
8129						<xsl:text>1=</xsl:text>
8130					</xsl:otherwise>
8131				</xsl:choose>
8132			</xsl:when>
8133			<xsl:when test="$first-one='(' or $first-one='!' or $first-one='&amp;'">
8134				<xsl:value-of select="concat('1', $return-value, $first-one)"/>
8135			</xsl:when>
8136			<xsl:when test="$first-one='['">
8137				<xsl:choose>
8138					<xsl:when test="starts-with(substring-after($expression, ']'), 'C')">
8139						<xsl:call-template name="parse-range-name">
8140							<xsl:with-param name="expression" select="substring-after($expression, ']')"/>
8141							<xsl:with-param name="return-value" select="concat($return-value, substring-before($expression, ']'), ']')"/>
8142						</xsl:call-template>
8143					</xsl:when>
8144					<xsl:when test="contains(substring-before($expression, ']'), '.') and contains(substring-after($expression, ']'), '!')">
8145						<xsl:value-of select="concat('1', &quot;&apos;&quot;, substring-before(substring-after($expression, '['), ']'), &quot;&apos;&quot;, '#$', substring-before(substring-after($expression, ']'), '!'))"/>
8146					</xsl:when>
8147					<xsl:otherwise>
8148						<xsl:value-of select="concat('2', $return-value, substring-before($expression, ']'), ']')"/>
8149					</xsl:otherwise>
8150				</xsl:choose>
8151			</xsl:when>
8152			<xsl:when test="$first-one='&quot;'">
8153				<xsl:value-of select="concat('1', $first-one, substring-before(substring-after($expression, '&quot;'), '&quot;'), '&quot;')"/>
8154			</xsl:when>
8155			<xsl:when test="$first-one=&quot;&apos;&quot;">
8156				<!-- here the string &quot;&apos;&quot; represents a char &apos;  -->
8157				<xsl:variable name="str-in" select="substring-before(substring-after($expression, &quot;&apos;&quot;), &quot;&apos;&quot;)"/>
8158				<xsl:choose>
8159					<!-- for file path transformation -->
8160					<xsl:when test="contains($str-in, '\') and contains($str-in, '[') and contains($str-in, ']')">
8161						<xsl:variable name="first-pos" select="substring-before($str-in, '[')"/>
8162						<xsl:variable name="second-pos" select="substring-before(substring-after($str-in, '['), ']')"/>
8163						<xsl:variable name="third-pos" select="substring-after($str-in, ']')"/>
8164						<xsl:value-of select="concat('1', &quot;&apos;&quot;, $first-pos, $second-pos, &quot;&apos;&quot;, '#$', $third-pos)"/>
8165					</xsl:when>
8166					<xsl:otherwise>
8167						<xsl:value-of select="concat('1', &quot;&apos;&quot;, $str-in, &quot;&apos;&quot;)"/>
8168					</xsl:otherwise>
8169				</xsl:choose>
8170			</xsl:when>
8171			<xsl:when test="$first-one='+' or $first-one='-' or $first-one='*' or $first-one='/' or $first-one=')' or $first-one='^' or $first-one=':' or $first-one='&quot;' or $first-one=';' or $first-one=',' or $first-one='&gt;' or $first-one='&lt;'">
8172				<xsl:choose>
8173					<xsl:when test="$return-value = ''">
8174						<xsl:value-of select="concat('1', $first-one)"/>
8175					</xsl:when>
8176					<xsl:otherwise>
8177						<xsl:value-of select="concat('2', $return-value)"/>
8178					</xsl:otherwise>
8179				</xsl:choose>
8180			</xsl:when>
8181			<xsl:otherwise>
8182				<xsl:choose>
8183					<xsl:when test="$expression = ''">
8184						<xsl:value-of select="concat('2', $return-value)"/>
8185					</xsl:when>
8186					<xsl:otherwise>
8187						<xsl:call-template name="parse-range-name">
8188							<xsl:with-param name="expression" select="substring($expression, 2, string-length($expression)-1)"/>
8189							<xsl:with-param name="return-value" select="concat($return-value, substring($expression, 1, 1))"/>
8190						</xsl:call-template>
8191					</xsl:otherwise>
8192				</xsl:choose>
8193			</xsl:otherwise>
8194		</xsl:choose>
8195	</xsl:template>
8196	<xsl:template name="handle-type-number">
8197		<!-- to handle the part between R and C, or after C in range string in translate-expression. return type: 1: number or cell range; 2: other, not for next step -->
8198		<xsl:param name="t-part"/>
8199		<xsl:choose>
8200			<xsl:when test="starts-with($t-part, '[')">
8201				<xsl:variable name="tt-str" select="substring-before( substring-after( $t-part, '['), ']')"/>
8202				<xsl:choose>
8203					<xsl:when test="($tt-str &lt; 0) or ($tt-str &gt; 0) or ($tt-str = 0)">
8204						<xsl:value-of select="1"/>
8205					</xsl:when>
8206					<xsl:otherwise>
8207						<xsl:value-of select="2"/>
8208					</xsl:otherwise>
8209				</xsl:choose>
8210			</xsl:when>
8211			<xsl:when test="($t-part &lt; 0) or ($t-part &gt; 0) or ($t-part = 0)">
8212				<xsl:value-of select="1"/>
8213			</xsl:when>
8214			<xsl:when test="$t-part = ''">
8215				<xsl:value-of select="1"/>
8216			</xsl:when>
8217			<xsl:otherwise>
8218				<xsl:value-of select="2"/>
8219			</xsl:otherwise>
8220		</xsl:choose>
8221	</xsl:template>
8222	<xsl:template name="translate-unit">
8223		<!-- convert cell position expression unit, R1C1, R3, C4 -->
8224		<xsl:param name="column-number"/>
8225		<xsl:param name="row-number"/>
8226		<xsl:param name="column-pos-style"/>
8227		<xsl:param name="row-pos-style"/>
8228		<xsl:variable name="column-number1">
8229			<xsl:value-of select="floor( $column-number div 26 )"/>
8230		</xsl:variable>
8231		<xsl:variable name="column-number2">
8232			<xsl:value-of select="$column-number mod 26"/>
8233		</xsl:variable>
8234		<xsl:variable name="column-character1">
8235			<xsl:call-template name="number-to-character">
8236				<xsl:with-param name="number" select="$column-number1"/>
8237			</xsl:call-template>
8238		</xsl:variable>
8239		<xsl:variable name="column-character2">
8240			<xsl:call-template name="number-to-character">
8241				<xsl:with-param name="number" select="$column-number2"/>
8242			</xsl:call-template>
8243		</xsl:variable>
8244		<!-- position styles are 'absolute' or 'relative', -->
8245		<xsl:choose>
8246			<xsl:when test="$column-pos-style = 'absolute'">
8247				<xsl:value-of select="concat( '$', $column-character1, $column-character2)"/>
8248			</xsl:when>
8249			<xsl:otherwise>
8250				<xsl:value-of select="concat( $column-character1, $column-character2)"/>
8251			</xsl:otherwise>
8252		</xsl:choose>
8253		<xsl:choose>
8254			<xsl:when test="$row-pos-style ='absolute'">
8255				<xsl:value-of select="concat( '$', $row-number)"/>
8256			</xsl:when>
8257			<xsl:otherwise>
8258				<xsl:value-of select="$row-number"/>
8259			</xsl:otherwise>
8260		</xsl:choose>
8261	</xsl:template>
8262	<xsl:template name="number-to-character">
8263		<xsl:param name="number"/>
8264		<xsl:choose>
8265			<xsl:when test="$number = 0"/>
8266			<xsl:when test="$number = 1">A</xsl:when>
8267			<xsl:when test="$number = 2">B</xsl:when>
8268			<xsl:when test="$number = 3">C</xsl:when>
8269			<xsl:when test="$number = 4">D</xsl:when>
8270			<xsl:when test="$number = 5">E</xsl:when>
8271			<xsl:when test="$number = 6">F</xsl:when>
8272			<xsl:when test="$number = 7">G</xsl:when>
8273			<xsl:when test="$number = 8">H</xsl:when>
8274			<xsl:when test="$number = 9">I</xsl:when>
8275			<xsl:when test="$number = 10">J</xsl:when>
8276			<xsl:when test="$number = 11">K</xsl:when>
8277			<xsl:when test="$number = 12">L</xsl:when>
8278			<xsl:when test="$number = 13">M</xsl:when>
8279			<xsl:when test="$number = 14">N</xsl:when>
8280			<xsl:when test="$number = 15">O</xsl:when>
8281			<xsl:when test="$number = 16">P</xsl:when>
8282			<xsl:when test="$number = 17">Q</xsl:when>
8283			<xsl:when test="$number = 18">R</xsl:when>
8284			<xsl:when test="$number = 19">S</xsl:when>
8285			<xsl:when test="$number = 20">T</xsl:when>
8286			<xsl:when test="$number = 21">U</xsl:when>
8287			<xsl:when test="$number = 22">V</xsl:when>
8288			<xsl:when test="$number = 23">W</xsl:when>
8289			<xsl:when test="$number = 24">X</xsl:when>
8290			<xsl:when test="$number = 25">Y</xsl:when>
8291			<xsl:when test="$number = 26">Z</xsl:when>
8292			<xsl:otherwise/>
8293		</xsl:choose>
8294	</xsl:template>
8295	<xsl:template name="get-digit-length">
8296		<xsl:param name="complexive-string"/>
8297		<xsl:variable name="first-char">
8298			<xsl:value-of select="substring( $complexive-string, 1, 1)"/>
8299		</xsl:variable>
8300		<xsl:choose>
8301			<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' ">
8302				<xsl:variable name="temp">
8303					<xsl:call-template name="get-digit-length">
8304						<xsl:with-param name="complexive-string" select="substring( $complexive-string, 2)"/>
8305					</xsl:call-template>
8306				</xsl:variable>
8307				<xsl:value-of select="$temp+1"/>
8308			</xsl:when>
8309			<xsl:otherwise>0</xsl:otherwise>
8310		</xsl:choose>
8311	</xsl:template>
8312	<xsl:template match="ss:Comment" mode="body">
8313		<xsl:element name="office:annotation">
8314			<xsl:if test="@ss:ShowAlways = '1'">
8315				<xsl:attribute name="office:display">true</xsl:attribute>
8316			</xsl:if>
8317			<xsl:if test="@ss:Author">
8318				<xsl:element name="dc:creator">
8319					<xsl:value-of select="@ss:Author"/>
8320				</xsl:element>
8321			</xsl:if>
8322			<xsl:if test="ss:Data">
8323				<text:p>
8324					<xsl:call-template name="create-data-content">
8325						<xsl:with-param name="style-id" select="@ss:StyleID"/>
8326					</xsl:call-template>
8327				</text:p>
8328			</xsl:if>
8329		</xsl:element>
8330	</xsl:template>
8331	<xsl:template name="Names">
8332		<xsl:variable name="namedRanges" select="/ss:Workbook/ss:Worksheet/ss:Names/ss:NamedRange |
8333												 /ss:Workbook/ss:Names/ss:NamedRange" />
8334		<xsl:if test="$namedRanges">
8335			<table:named-expressions>
8336				<xsl:for-each select="$namedRanges">
8337					<xsl:choose>
8338						<xsl:when test="contains( @ss:RefersTo, '!R')">
8339							<xsl:variable name="referto">
8340								<xsl:call-template name="translate-expression">
8341									<xsl:with-param name="isRangeAddress" select="true()"/>
8342									<xsl:with-param name="cell-row-pos" select="0"/>
8343									<xsl:with-param name="cell-column-pos" select="0"/>
8344									<xsl:with-param name="expression" select="@ss:RefersTo"/>
8345									<xsl:with-param name="return-value" select="''"/>
8346								</xsl:call-template>
8347							</xsl:variable>
8348							<xsl:element name="table:named-range">
8349								<xsl:attribute name="table:name">
8350									<xsl:value-of select="@ss:Name"/>
8351								</xsl:attribute>
8352								<xsl:attribute name="table:base-cell-address">
8353									<xsl:variable name="worksheetName" select="translate(substring-before(@ss:RefersTo, '!'), '=', '$')" />
8354									<xsl:call-template name="encode-as-cell-address">
8355										<xsl:with-param name="string" select="concat($worksheetName,'.$A$1')"/>
8356									</xsl:call-template>
8357								</xsl:attribute>
8358								<xsl:attribute name="table:cell-range-address">
8359									<xsl:call-template name="encode-as-cell-range-address">
8360										<xsl:with-param name="string" select="translate( $referto, '=', '$')"/>
8361									</xsl:call-template>
8362								</xsl:attribute>
8363								<xsl:if test="@ss:Name = 'Print_Area'">
8364									<xsl:attribute name="table:range-usable-as">print-range</xsl:attribute>
8365								</xsl:if>
8366							</xsl:element>
8367						</xsl:when>
8368						<xsl:otherwise>
8369							<xsl:variable name="expression-name">
8370								<xsl:value-of select="@ss:Name"/>
8371							</xsl:variable>
8372							<xsl:element name="table:named-expression">
8373								<xsl:attribute name="table:name">
8374									<xsl:value-of select="@ss:Name"/>
8375								</xsl:attribute>
8376								<!-- just set '$Sheet1.$A$1' as named-expressions virtual base-cell-address -->
8377								<xsl:attribute name="table:base-cell-address">
8378									<xsl:variable name="worksheetName" select="following-sibling::ss:Worksheet/@ss:Name" />
8379									<xsl:call-template name="encode-as-cell-address">
8380										<xsl:with-param name="string" select="concat('$', $worksheetName,'.$A$1')"/>
8381									</xsl:call-template>
8382								</xsl:attribute>
8383								<xsl:attribute name="table:expression">
8384									<xsl:value-of select="substring( @ss:RefersTo, 2)"/>
8385								</xsl:attribute>
8386							</xsl:element>
8387						</xsl:otherwise>
8388					</xsl:choose>
8389				</xsl:for-each>
8390			</table:named-expressions>
8391		</xsl:if>
8392	</xsl:template>
8393	<xsl:template name="transform-advanced-filter">
8394		<!-- transform the params of Advanced Filter.it's different from AutoFilter -->
8395		<xsl:param name="target-value"/>
8396		<xsl:param name="condition-pos"/>
8397		<xsl:element name="table:database-range">
8398			<xsl:variable name="target-range">
8399				<xsl:call-template name="translate-expression">
8400					<xsl:with-param name="cell-row-pos" select="0"/>
8401					<xsl:with-param name="cell-column-pos" select="0"/>
8402					<xsl:with-param name="expression" select="$target-value"/>
8403					<xsl:with-param name="return-value" select="''"/>
8404				</xsl:call-template>
8405			</xsl:variable>
8406			<xsl:variable name="condition-range">
8407				<xsl:call-template name="translate-expression">
8408					<xsl:with-param name="cell-row-pos" select="0"/>
8409					<xsl:with-param name="cell-column-pos" select="0"/>
8410					<xsl:with-param name="expression" select="$condition-pos"/>
8411					<xsl:with-param name="return-value" select="''"/>
8412				</xsl:call-template>
8413			</xsl:variable>
8414			<xsl:attribute name="table:target-range-address">
8415				<xsl:value-of select="$target-range"/>
8416			</xsl:attribute>
8417			<xsl:attribute name="table:name">
8418				<xsl:value-of select="concat($target-range, '.filter')"/>
8419			</xsl:attribute>
8420			<xsl:element name="table:filter">
8421				<xsl:attribute name="table:condition-source-range-address">
8422					<xsl:value-of select="$condition-range"/>
8423				</xsl:attribute>
8424				<xsl:element name="table:filter-condition">
8425					<xsl:attribute name="table:field-number">0</xsl:attribute>
8426					<!-- The two attributes are recommended by OASIS -->
8427					<xsl:attribute name="table:value"/>
8428					<xsl:attribute name="table:operator"/>
8429				</xsl:element>
8430			</xsl:element>
8431		</xsl:element>
8432	</xsl:template>
8433	<xsl:template match="x:AutoFilter">
8434		<!-- for AutoFilter -->
8435		<xsl:element name="table:database-range">
8436			<xsl:attribute name="table:name">
8437				<xsl:value-of select="concat(../@ss:Name,'_',@x:Range)"/>
8438			</xsl:attribute>
8439			<xsl:variable name="range">
8440				<xsl:call-template name="translate-expression">
8441					<xsl:with-param name="cell-row-pos" select="0"/>
8442					<xsl:with-param name="cell-column-pos" select="0"/>
8443					<xsl:with-param name="expression" select="@x:Range"/>
8444					<xsl:with-param name="return-value" select="''"/>
8445				</xsl:call-template>
8446			</xsl:variable>
8447			<xsl:attribute name="table:target-range-address">
8448				<xsl:value-of select="concat('$',../@ss:Name,'.',$range)"/>
8449			</xsl:attribute>
8450			<xsl:attribute name="table:display-filter-buttons">true</xsl:attribute>
8451			<xsl:element name="table:filter">
8452				<xsl:call-template name="auto-filter-condition">
8453					<xsl:with-param name="item-pos" select="1"/>
8454					<xsl:with-param name="index" select="1"/>
8455					<xsl:with-param name="total" select="count(./x:AutoFilterColumn)"/>
8456				</xsl:call-template>
8457			</xsl:element>
8458		</xsl:element>
8459	</xsl:template>
8460	<xsl:template name="auto-filter-condition">
8461		<!--?? generate element of filter-condition for AutoCondition to get position of index -->
8462		<xsl:param name="item-pos"/>
8463		<xsl:param name="index"/>
8464		<xsl:param name="total"/>
8465		<xsl:if test="($index - 1 &lt; $total) or ($index - 1 = $total)">
8466			<xsl:element name="table:filter-condition">
8467				<xsl:attribute name="table:data-type">number</xsl:attribute>
8468				<xsl:choose>
8469					<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]/@x:Type = 'TopPercent'">
8470						<xsl:attribute name="table:operator">
8471							<xsl:value-of select="'top value'"/>
8472						</xsl:attribute>
8473						<xsl:attribute name="table:value">
8474							<xsl:value-of select="./x:AutoFilterColumn[position() = $item-pos]/@x:Value"/>
8475						</xsl:attribute>
8476					</xsl:when>
8477					<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]/@x:Type = 'Top'">
8478						<xsl:attribute name="table:operator">
8479							<xsl:value-of select="'top values'"/>
8480						</xsl:attribute>
8481						<xsl:attribute name="table:value">
8482							<xsl:value-of select="./x:AutoFilterColumn[position() = $item-pos]/@x:Value"/>
8483						</xsl:attribute>
8484					</xsl:when>
8485					<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]/@x:Type = 'TopPercent'">
8486						<xsl:attribute name="table:operator">
8487							<xsl:value-of select="'top percent'"/>
8488						</xsl:attribute>
8489						<xsl:attribute name="table:value">
8490							<xsl:value-of select="./x:AutoFilterColumn[position() = $item-pos]/@x:Value"/>
8491						</xsl:attribute>
8492					</xsl:when>
8493					<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]/@x:Type = 'Bottom'">
8494						<xsl:attribute name="table:operator">
8495							<xsl:value-of select="'bottom values'"/>
8496						</xsl:attribute>
8497						<xsl:attribute name="table:value">
8498							<xsl:value-of select="./x:AutoFilterColumn[position() = $item-pos]/@x:Value"/>
8499						</xsl:attribute>
8500					</xsl:when>
8501					<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]/@x:Type = 'BottomPercent'">
8502						<xsl:attribute name="table:operator">
8503							<xsl:value-of select="'bottom percent'"/>
8504						</xsl:attribute>
8505						<xsl:attribute name="table:value">
8506							<xsl:value-of select="./x:AutoFilterColumn[position() = $item-pos]/@x:Value"/>
8507						</xsl:attribute>
8508					</xsl:when>
8509					<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]/@x:Type = 'Custom'">
8510						<xsl:choose>
8511							<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]/x:AutoFilterOr or ./x:AutoFilterColumn[position() = $item-pos]/x:AutoFilterAnd">
8512								<xsl:attribute name="table:operator">
8513									<xsl:choose>
8514										<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]//@x:Operator = 'Equals'">
8515											<xsl:value-of select="'='"/>
8516										</xsl:when>
8517										<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]//@x:Operator = 'DoesNotEquals'">
8518											<xsl:value-of select="'!='"/>
8519										</xsl:when>
8520										<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]//@x:Operator = 'GreaterThan'">
8521											<xsl:value-of select="'&gt;'"/>
8522										</xsl:when>
8523										<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]//@x:Operator = 'GreaterThanOrEqual'">
8524											<xsl:value-of select="'&gt;='"/>
8525										</xsl:when>
8526										<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]//@x:Operator = 'LessThan'">
8527											<xsl:value-of select="'&lt;'"/>
8528										</xsl:when>
8529										<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]//@x:Operator = 'LessThanOrEqual'">
8530											<xsl:value-of select="'&lt;='"/>
8531										</xsl:when>
8532										<xsl:otherwise>
8533											<xsl:value-of select="'='"/>
8534										</xsl:otherwise>
8535									</xsl:choose>
8536								</xsl:attribute>
8537								<xsl:attribute name="table:value">
8538									<xsl:value-of select="./x:AutoFilterColumn[position() = $item-pos]//@x:Value"/>
8539								</xsl:attribute>
8540							</xsl:when>
8541							<xsl:otherwise>
8542								<xsl:attribute name="table:operator">
8543									<xsl:value-of select="'bottom percent'"/>
8544								</xsl:attribute>
8545								<xsl:attribute name="table:value">
8546									<xsl:value-of select="./x:AutoFilterColumn[position() = $item-pos]//@x:Value"/>
8547								</xsl:attribute>
8548							</xsl:otherwise>
8549						</xsl:choose>
8550					</xsl:when>
8551				</xsl:choose>
8552				<xsl:attribute name="table:field-number">
8553					<xsl:choose>
8554						<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]/@x:Index">
8555							<xsl:value-of select="./x:AutoFilterColumn[position() = $item-pos]/@x:Index - 1"/>
8556						</xsl:when>
8557						<xsl:otherwise>
8558							<xsl:value-of select="$index - 1"/>
8559						</xsl:otherwise>
8560					</xsl:choose>
8561				</xsl:attribute>
8562			</xsl:element>
8563			<xsl:call-template name="auto-filter-condition">
8564				<xsl:with-param name="item-pos" select="$item-pos + 1"/>
8565				<xsl:with-param name="index">
8566					<xsl:choose>
8567						<xsl:when test="./x:AutoFilterColumn[position() = $item-pos]/@x:Index">
8568							<xsl:value-of select="./x:AutoFilterColumn[position() = $item-pos]/@x:Index + 1"/>
8569						</xsl:when>
8570						<xsl:otherwise>
8571							<xsl:value-of select="$index + 1"/>
8572						</xsl:otherwise>
8573					</xsl:choose>
8574				</xsl:with-param>
8575				<xsl:with-param name="total" select="count(./x:AutoFilterColumn)"/>
8576			</xsl:call-template>
8577		</xsl:if>
8578	</xsl:template>
8579	<xsl:template match="x:Sorting">
8580		<!-- for Sorting don't contains header row -->
8581		<xsl:if test="contains(./x:Sort, 'Column')">
8582			<xsl:element name="table:database-range">
8583				<xsl:variable name="first-sort-letter" select="normalize-space(substring-after(./x:Sort[position() = 1], 'Column'))"/>
8584				<xsl:variable name="second-sort-letter" select="normalize-space(substring-after(./x:Sort[position() = 2], 'Column'))"/>
8585				<xsl:variable name="third-sort-letter" select="normalize-space(substring-after(./x:Sort[position() = 3], 'Column'))"/>
8586				<xsl:variable name="first-sort-num">
8587					<xsl:call-template name="letter-to-number">
8588						<xsl:with-param name="source-letter" select="$first-sort-letter"/>
8589						<xsl:with-param name="return-value" select="0"/>
8590					</xsl:call-template>
8591				</xsl:variable>
8592				<xsl:variable name="second-sort-num">
8593					<xsl:call-template name="letter-to-number">
8594						<xsl:with-param name="source-letter" select="$second-sort-letter"/>
8595						<xsl:with-param name="return-value" select="0"/>
8596					</xsl:call-template>
8597				</xsl:variable>
8598				<xsl:variable name="third-sort-num">
8599					<xsl:call-template name="letter-to-number">
8600						<xsl:with-param name="source-letter" select="$third-sort-letter"/>
8601						<xsl:with-param name="return-value" select="0"/>
8602					</xsl:call-template>
8603				</xsl:variable>
8604				<xsl:variable name="min-left-num">
8605					<xsl:call-template name="min-of-three">
8606						<xsl:with-param name="first-num" select="$first-sort-num"/>
8607						<xsl:with-param name="second-num" select="$second-sort-num"/>
8608						<xsl:with-param name="third-num" select="$third-sort-num"/>
8609					</xsl:call-template>
8610				</xsl:variable>
8611				<xsl:variable name="max-right-num">
8612					<xsl:call-template name="max-of-three">
8613						<xsl:with-param name="first-num" select="$first-sort-num"/>
8614						<xsl:with-param name="second-num" select="$second-sort-num"/>
8615						<xsl:with-param name="third-num" select="$third-sort-num"/>
8616					</xsl:call-template>
8617				</xsl:variable>
8618				<xsl:variable name="left-column">
8619					<xsl:call-template name="number-to-letter">
8620						<xsl:with-param name="source-number" select="$min-left-num"/>
8621						<xsl:with-param name="return-value" select="''"/>
8622					</xsl:call-template>
8623				</xsl:variable>
8624				<xsl:variable name="right-column">
8625					<xsl:call-template name="number-to-letter">
8626						<xsl:with-param name="source-number" select="$max-right-num"/>
8627						<xsl:with-param name="return-value" select="''"/>
8628					</xsl:call-template>
8629				</xsl:variable>
8630				<xsl:attribute name="table:target-range-address">
8631					<xsl:value-of select="concat(../@ss:Name, '.', $left-column, '1:', ../@ss:Name, '.', $right-column, '32000')"/>
8632				</xsl:attribute>
8633				<xsl:attribute name="table:name">
8634					<xsl:value-of select="concat(../@ss:Name, '.sort')"/>
8635				</xsl:attribute>
8636				<xsl:attribute name="table:contains-header">
8637					<xsl:value-of select="'false'"/>
8638				</xsl:attribute>
8639				<xsl:element name="table:sort">
8640					<xsl:for-each select="./x:Sort">
8641						<xsl:element name="table:sort-by">
8642							<xsl:attribute name="table:field-number">
8643								<xsl:value-of select="0"/>
8644							</xsl:attribute>
8645							<xsl:attribute name="table:data-type">
8646								<xsl:value-of select="'automatic'"/>
8647							</xsl:attribute>
8648							<xsl:variable name="after-sort" select="following-sibling::*"/>
8649							<xsl:if test="name($after-sort[position() = 1]) = 'Descending'">
8650								<xsl:attribute name="table:order">
8651									<xsl:value-of select="'descending'"/>
8652								</xsl:attribute>
8653							</xsl:if>
8654							<xsl:choose>
8655								<xsl:when test="position() = 1">
8656									<xsl:attribute name="table:field-number">
8657										<xsl:value-of select="$first-sort-num - $min-left-num"/>
8658									</xsl:attribute>
8659								</xsl:when>
8660								<xsl:when test="position() = 2">
8661									<xsl:attribute name="table:field-number">
8662										<xsl:value-of select="$second-sort-num - $min-left-num"/>
8663									</xsl:attribute>
8664								</xsl:when>
8665								<xsl:when test="position() = 3">
8666									<xsl:attribute name="table:field-number">
8667										<xsl:value-of select="$third-sort-num - $min-left-num"/>
8668									</xsl:attribute>
8669								</xsl:when>
8670							</xsl:choose>
8671						</xsl:element>
8672					</xsl:for-each>
8673				</xsl:element>
8674			</xsl:element>
8675		</xsl:if>
8676	</xsl:template>
8677	<xsl:template name="letter-to-number">
8678		<!-- convert letter to number for sorting. the string source-letter should be normalize-space and the first return-value should be zero -->
8679		<xsl:param name="source-letter"/>
8680		<xsl:param name="return-value"/>
8681		<xsl:choose>
8682			<xsl:when test="string-length($source-letter) &gt; 0">
8683				<xsl:variable name="first-pit" select="substring($source-letter, 1, 1)"/>
8684				<xsl:variable name="pit-number">
8685					<xsl:choose>
8686						<xsl:when test="($first-pit = 'A') or ($first-pit = 'a')">
8687							<xsl:value-of select="1"/>
8688						</xsl:when>
8689						<xsl:when test="($first-pit = 'B') or ($first-pit = 'b')">
8690							<xsl:value-of select="2"/>
8691						</xsl:when>
8692						<xsl:when test="($first-pit = 'C') or ($first-pit = 'c')">
8693							<xsl:value-of select="3"/>
8694						</xsl:when>
8695						<xsl:when test="($first-pit = 'D') or ($first-pit = 'd')">
8696							<xsl:value-of select="4"/>
8697						</xsl:when>
8698						<xsl:when test="($first-pit = 'E') or ($first-pit = 'e')">
8699							<xsl:value-of select="5"/>
8700						</xsl:when>
8701						<xsl:when test="($first-pit = 'F') or ($first-pit = 'f')">
8702							<xsl:value-of select="6"/>
8703						</xsl:when>
8704						<xsl:when test="($first-pit = 'G') or ($first-pit = 'g')">
8705							<xsl:value-of select="7"/>
8706						</xsl:when>
8707						<xsl:when test="($first-pit = 'H') or ($first-pit = 'h')">
8708							<xsl:value-of select="8"/>
8709						</xsl:when>
8710						<xsl:when test="($first-pit = 'I') or ($first-pit = 'i')">
8711							<xsl:value-of select="9"/>
8712						</xsl:when>
8713						<xsl:when test="($first-pit = 'J') or ($first-pit = 'j')">
8714							<xsl:value-of select="10"/>
8715						</xsl:when>
8716						<xsl:when test="($first-pit = 'K') or ($first-pit = 'k')">
8717							<xsl:value-of select="11"/>
8718						</xsl:when>
8719						<xsl:when test="($first-pit = 'L') or ($first-pit = 'l')">
8720							<xsl:value-of select="12"/>
8721						</xsl:when>
8722						<xsl:when test="($first-pit = 'M') or ($first-pit = 'm')">
8723							<xsl:value-of select="13"/>
8724						</xsl:when>
8725						<xsl:when test="($first-pit = 'N') or ($first-pit = 'n')">
8726							<xsl:value-of select="14"/>
8727						</xsl:when>
8728						<xsl:when test="($first-pit = 'O') or ($first-pit = 'o')">
8729							<xsl:value-of select="15"/>
8730						</xsl:when>
8731						<xsl:when test="($first-pit = 'P') or ($first-pit = 'p')">
8732							<xsl:value-of select="16"/>
8733						</xsl:when>
8734						<xsl:when test="($first-pit = 'Q') or ($first-pit = 'q')">
8735							<xsl:value-of select="17"/>
8736						</xsl:when>
8737						<xsl:when test="($first-pit = 'R') or ($first-pit = 'r')">
8738							<xsl:value-of select="18"/>
8739						</xsl:when>
8740						<xsl:when test="($first-pit = 'S') or ($first-pit = 's')">
8741							<xsl:value-of select="19"/>
8742						</xsl:when>
8743						<xsl:when test="($first-pit = 'T') or ($first-pit = 't')">
8744							<xsl:value-of select="20"/>
8745						</xsl:when>
8746						<xsl:when test="($first-pit = 'U') or ($first-pit = 'u')">
8747							<xsl:value-of select="21"/>
8748						</xsl:when>
8749						<xsl:when test="($first-pit = 'V') or ($first-pit = 'v')">
8750							<xsl:value-of select="22"/>
8751						</xsl:when>
8752						<xsl:when test="($first-pit = 'W') or ($first-pit = 'w')">
8753							<xsl:value-of select="23"/>
8754						</xsl:when>
8755						<xsl:when test="($first-pit = 'X') or ($first-pit = 'x')">
8756							<xsl:value-of select="24"/>
8757						</xsl:when>
8758						<xsl:when test="($first-pit = 'Y') or ($first-pit = 'y')">
8759							<xsl:value-of select="25"/>
8760						</xsl:when>
8761						<xsl:when test="($first-pit = 'Z') or ($first-pit = 'z')">
8762							<xsl:value-of select="26"/>
8763						</xsl:when>
8764						<xsl:otherwise>
8765							<xsl:value-of select="1"/>
8766						</xsl:otherwise>
8767					</xsl:choose>
8768				</xsl:variable>
8769				<xsl:call-template name="letter-to-number">
8770					<xsl:with-param name="source-letter" select="substring($source-letter, 2)"/>
8771					<xsl:with-param name="return-value">
8772						<xsl:choose>
8773							<xsl:when test="string-length($source-letter) &gt;= 2">
8774								<xsl:value-of select="$pit-number * 26 + $return-value"/>
8775							</xsl:when>
8776							<xsl:otherwise>
8777								<xsl:value-of select="$pit-number + $return-value"/>
8778							</xsl:otherwise>
8779						</xsl:choose>
8780					</xsl:with-param>
8781				</xsl:call-template>
8782			</xsl:when>
8783			<xsl:otherwise>
8784				<xsl:value-of select="$return-value"/>
8785			</xsl:otherwise>
8786		</xsl:choose>
8787	</xsl:template>
8788	<xsl:template name="number-to-letter">
8789		<!--?? convert number to letter for sorting -->
8790		<xsl:param name="source-number"/>
8791		<xsl:param name="return-value"/>
8792		<xsl:variable name="current-value">
8793			<xsl:call-template name="num-conv-letter">
8794				<xsl:with-param name="first-pit">
8795					<xsl:choose>
8796						<xsl:when test="$source-number &gt; 26">
8797							<xsl:value-of select="floor($source-number div 26)"/>
8798						</xsl:when>
8799						<xsl:otherwise>
8800							<xsl:value-of select="$source-number"/>
8801						</xsl:otherwise>
8802					</xsl:choose>
8803				</xsl:with-param>
8804			</xsl:call-template>
8805		</xsl:variable>
8806		<xsl:if test="$source-number &gt; 26">
8807			<xsl:call-template name="number-to-letter">
8808				<xsl:with-param name="source-number" select="$source-number mod 26"/>
8809				<xsl:with-param name="return-value" select="concat($return-value,$current-value)"/>
8810			</xsl:call-template>
8811		</xsl:if>
8812		<xsl:if test="$source-number &lt; 27">
8813			<xsl:value-of select="concat($return-value,$current-value)"/>
8814		</xsl:if>
8815	</xsl:template>
8816	<xsl:template name="num-conv-letter">
8817		<!-- convert number to number by pit of 26 -->
8818		<xsl:param name="first-pit"/>
8819		<xsl:choose>
8820			<xsl:when test="$first-pit = 1">
8821				<xsl:value-of select="'A'"/>
8822			</xsl:when>
8823			<xsl:when test="$first-pit = 2">
8824				<xsl:value-of select="'B'"/>
8825			</xsl:when>
8826			<xsl:when test="$first-pit = 3">
8827				<xsl:value-of select="'C'"/>
8828			</xsl:when>
8829			<xsl:when test="$first-pit = 4">
8830				<xsl:value-of select="'D'"/>
8831			</xsl:when>
8832			<xsl:when test="$first-pit = 5">
8833				<xsl:value-of select="'E'"/>
8834			</xsl:when>
8835			<xsl:when test="$first-pit = 6">
8836				<xsl:value-of select="'F'"/>
8837			</xsl:when>
8838			<xsl:when test="$first-pit = 7">
8839				<xsl:value-of select="'G'"/>
8840			</xsl:when>
8841			<xsl:when test="$first-pit = 8">
8842				<xsl:value-of select="'H'"/>
8843			</xsl:when>
8844			<xsl:when test="$first-pit = 9">
8845				<xsl:value-of select="'I'"/>
8846			</xsl:when>
8847			<xsl:when test="$first-pit = 10">
8848				<xsl:value-of select="'J'"/>
8849			</xsl:when>
8850			<xsl:when test="$first-pit = 11">
8851				<xsl:value-of select="'K'"/>
8852			</xsl:when>
8853			<xsl:when test="$first-pit = 12">
8854				<xsl:value-of select="'L'"/>
8855			</xsl:when>
8856			<xsl:when test="$first-pit = 13">
8857				<xsl:value-of select="'M'"/>
8858			</xsl:when>
8859			<xsl:when test="$first-pit = 14">
8860				<xsl:value-of select="'N'"/>
8861			</xsl:when>
8862			<xsl:when test="$first-pit = 15">
8863				<xsl:value-of select="'O'"/>
8864			</xsl:when>
8865			<xsl:when test="$first-pit = 16">
8866				<xsl:value-of select="'P'"/>
8867			</xsl:when>
8868			<xsl:when test="$first-pit = 17">
8869				<xsl:value-of select="'Q'"/>
8870			</xsl:when>
8871			<xsl:when test="$first-pit = 18">
8872				<xsl:value-of select="'R'"/>
8873			</xsl:when>
8874			<xsl:when test="$first-pit = 19">
8875				<xsl:value-of select="'S'"/>
8876			</xsl:when>
8877			<xsl:when test="$first-pit = 20">
8878				<xsl:value-of select="'T'"/>
8879			</xsl:when>
8880			<xsl:when test="$first-pit = 21">
8881				<xsl:value-of select="'U'"/>
8882			</xsl:when>
8883			<xsl:when test="$first-pit = 22">
8884				<xsl:value-of select="'V'"/>
8885			</xsl:when>
8886			<xsl:when test="$first-pit = 23">
8887				<xsl:value-of select="'W'"/>
8888			</xsl:when>
8889			<xsl:when test="$first-pit = 24">
8890				<xsl:value-of select="'X'"/>
8891			</xsl:when>
8892			<xsl:when test="$first-pit = 25">
8893				<xsl:value-of select="'Y'"/>
8894			</xsl:when>
8895			<xsl:when test="$first-pit = 26">
8896				<xsl:value-of select="'Z'"/>
8897			</xsl:when>
8898			<xsl:otherwise>
8899				<xsl:value-of select="'A'"/>
8900			</xsl:otherwise>
8901		</xsl:choose>
8902	</xsl:template>
8903	<xsl:template name="min-of-three">
8904		<!-- return minest of three for sorting -->
8905		<xsl:param name="first-num"/>
8906		<xsl:param name="second-num"/>
8907		<xsl:param name="third-num"/>
8908		<xsl:variable name="first-comp">
8909			<xsl:choose>
8910				<xsl:when test="$first-num = 0">
8911					<xsl:value-of select="$second-num"/>
8912				</xsl:when>
8913				<xsl:when test="($first-num &lt; $second-num) or ($second-num = 0)">
8914					<xsl:value-of select="$first-num"/>
8915				</xsl:when>
8916				<xsl:otherwise>
8917					<xsl:value-of select="$second-num"/>
8918				</xsl:otherwise>
8919			</xsl:choose>
8920		</xsl:variable>
8921		<xsl:variable name="second-comp">
8922			<xsl:choose>
8923				<xsl:when test="($first-comp &lt; $third-num) or ($third-num = 0)">
8924					<xsl:value-of select="$first-comp"/>
8925				</xsl:when>
8926				<xsl:otherwise>
8927					<xsl:value-of select="$third-num"/>
8928				</xsl:otherwise>
8929			</xsl:choose>
8930		</xsl:variable>
8931		<xsl:value-of select="$second-comp"/>
8932	</xsl:template>
8933	<xsl:template name="max-of-three">
8934		<!-- return maxest of three for sorting -->
8935		<xsl:param name="first-num"/>
8936		<xsl:param name="second-num"/>
8937		<xsl:param name="third-num"/>
8938		<xsl:variable name="first-comp">
8939			<xsl:choose>
8940				<xsl:when test="$first-num &gt; $second-num">
8941					<xsl:value-of select="$first-num"/>
8942				</xsl:when>
8943				<xsl:otherwise>
8944					<xsl:value-of select="$second-num"/>
8945				</xsl:otherwise>
8946			</xsl:choose>
8947		</xsl:variable>
8948		<xsl:variable name="second-comp">
8949			<xsl:choose>
8950				<xsl:when test="$first-comp &gt; $third-num">
8951					<xsl:value-of select="$first-comp"/>
8952				</xsl:when>
8953				<xsl:otherwise>
8954					<xsl:value-of select="$third-num"/>
8955				</xsl:otherwise>
8956			</xsl:choose>
8957		</xsl:variable>
8958		<xsl:value-of select="$second-comp"/>
8959	</xsl:template>
8960	<xsl:template name="set-calculation">
8961		<xsl:element name="table:calculation-settings">
8962			<xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:PrecisionAsDisplayed">
8963				<xsl:attribute name="table:precision-as-shown">true</xsl:attribute>
8964			</xsl:if>
8965			<xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:Date1904">
8966				<table:null-date office:date-value="1904-01-01"/>
8967			</xsl:if>
8968			<xsl:element name="table:iteration">
8969				<xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:Iteration">
8970					<xsl:attribute name="table:status">enable</xsl:attribute>
8971				</xsl:if>
8972				<xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:MaxIterations">
8973					<xsl:attribute name="table:steps">
8974						<xsl:value-of select="/ss:Workbook/x:ExcelWorkbook/x:MaxIterations"/>
8975					</xsl:attribute>
8976				</xsl:if>
8977				<xsl:if test="/ss:Workbook/x:ExcelWorkbook/x:MaxChange">
8978					<xsl:attribute name="table:maximum-difference">
8979						<xsl:value-of select="/ss:Workbook/x:ExcelWorkbook/x:MaxChange"/>
8980					</xsl:attribute>
8981				</xsl:if>
8982			</xsl:element>
8983		</xsl:element>
8984	</xsl:template>
8985	<xsl:template match="x:DataValidation">
8986		<!-- for DataValidation. don't support the attribute IMEMode currently.  -->
8987		<xsl:element name="table:content-validation">
8988			<xsl:attribute name="table:name">
8989				<xsl:value-of select="concat('val', position())"/>
8990			</xsl:attribute>
8991			<xsl:attribute name="table:condition"><!-- don't support two type of qualifier: List, Custom -->
8992				<xsl:variable name="qualifier-content">
8993					<xsl:choose>
8994						<xsl:when test="./x:Qualifier = 'NotBetween'">
8995							<xsl:value-of select="concat('cell-content-is-not-between(', ./x:Min, ',', ./x:Max, ')')"/>
8996						</xsl:when>
8997						<xsl:when test="./x:Qualifier = 'NotEqual'">
8998							<xsl:value-of select="concat('!=', ./x:Value)"/>
8999						</xsl:when>
9000						<xsl:when test="./x:Qualifier = 'Equal'">
9001							<xsl:value-of select="concat('=', ./x:Value)"/>
9002						</xsl:when>
9003						<xsl:when test="./x:Qualifier = 'Less'">
9004							<xsl:value-of select="concat('&lt;', ./x:Value)"/>
9005						</xsl:when>
9006						<xsl:when test="./x:Qualifier = 'Greater'">
9007							<xsl:value-of select="concat('&gt;', ./x:Value)"/>
9008						</xsl:when>
9009						<xsl:when test="./x:Qualifier = 'GreaterOrEqual'">
9010							<xsl:value-of select="concat('&gt;=', ./x:Value)"/>
9011						</xsl:when>
9012						<xsl:when test="./x:Qualifier = 'LessOrEqual'">
9013							<xsl:value-of select="concat('&lt;=', ./x:Value)"/>
9014						</xsl:when>
9015						<xsl:otherwise>
9016							<xsl:value-of select="concat('cell-content-is-between(', ./x:Min, ',', ./x:Max)"/>
9017						</xsl:otherwise>
9018					</xsl:choose>
9019				</xsl:variable>
9020				<xsl:variable name="qualifier-value">
9021					<xsl:choose>
9022						<xsl:when test="./x:Type = 'Whole'">
9023							<xsl:choose>
9024								<xsl:when test="(./x:Qualifier = 'NotBetween') or ./x:Max">
9025									<xsl:value-of select="concat('cell-content-is-whole-number() and ', $qualifier-content, ')')"/>
9026								</xsl:when>
9027								<xsl:otherwise>
9028									<xsl:value-of select="concat('cell-content-is-whole-number() and ', 'cell-content()', $qualifier-content)"/>
9029								</xsl:otherwise>
9030							</xsl:choose>
9031						</xsl:when>
9032						<xsl:when test="./x:Type = 'Decimal'">
9033							<xsl:choose>
9034								<xsl:when test="(./x:Qualifier = 'NotBetween') or ./x:Max">
9035									<xsl:value-of select="concat('cell-content-is-decimal-number() and ', $qualifier-content, ')')"/>
9036								</xsl:when>
9037								<xsl:otherwise>
9038									<xsl:value-of select="concat('cell-content-is-decimal-number() and ', 'cell-content()', $qualifier-content)"/>
9039								</xsl:otherwise>
9040							</xsl:choose>
9041						</xsl:when>
9042						<xsl:when test="./x:Type = 'Date'">
9043							<xsl:choose>
9044								<xsl:when test="(./x:Qualifier = 'NotBetween') or ./x:Max">
9045									<xsl:value-of select="concat('cell-content-is-date() and ', $qualifier-content, ')')"/>
9046								</xsl:when>
9047								<xsl:otherwise>
9048									<xsl:value-of select="concat('cell-content-is-date() and ', 'cell-content()', $qualifier-content)"/>
9049								</xsl:otherwise>
9050							</xsl:choose>
9051						</xsl:when>
9052						<xsl:when test="./x:Type = 'Time'">
9053							<xsl:choose>
9054								<xsl:when test="(./x:Qualifier = 'NotBetween') or ./x:Max">
9055									<xsl:value-of select="concat('cell-content-is-time() and ', $qualifier-content, ')')"/>
9056								</xsl:when>
9057								<xsl:otherwise>
9058									<xsl:value-of select="concat('cell-content-is-time() and ', 'cell-content()', $qualifier-content)"/>
9059								</xsl:otherwise>
9060							</xsl:choose>
9061						</xsl:when>
9062						<xsl:when test="./x:Type = 'TextLength'">
9063							<xsl:choose>
9064								<xsl:when test="./x:Qualifier = 'NotBetween'">
9065									<xsl:value-of select="concat('cell-content-text-length-is-not-between(', ./x:Min, ',', ./x:Max, ')')"/>
9066								</xsl:when>
9067								<xsl:when test="./x:Max and ./x:Min">
9068									<xsl:value-of select="concat('cell-content-text-length-is-between(', ./x:Min, ',', ./x:Max, ')')"/>
9069								</xsl:when>
9070								<xsl:otherwise>
9071									<xsl:value-of select="concat('cell-content-text-length()', $qualifier-content)"/>
9072								</xsl:otherwise>
9073							</xsl:choose>
9074						</xsl:when>
9075						<xsl:otherwise>
9076							<xsl:value-of select="./x:Type"/>
9077						</xsl:otherwise>
9078					</xsl:choose>
9079				</xsl:variable>
9080				<xsl:value-of select="$qualifier-value"/>
9081			</xsl:attribute>
9082			<xsl:attribute name="table:base-cell-address">
9083				<xsl:variable name="first-range">
9084					<xsl:choose>
9085						<xsl:when test="contains(./x:Range, ',')">
9086							<xsl:value-of select="substring-before(./x:Range, ',')"/>
9087						</xsl:when>
9088						<xsl:otherwise>
9089							<xsl:value-of select="./x:Range"/>
9090						</xsl:otherwise>
9091					</xsl:choose>
9092				</xsl:variable>
9093				<xsl:variable name="range">
9094					<xsl:call-template name="translate-expression">
9095						<xsl:with-param name="cell-row-pos" select="0"/>
9096						<xsl:with-param name="cell-column-pos" select="0"/>
9097						<xsl:with-param name="expression" select="$first-range"/>
9098						<xsl:with-param name="return-value" select="''"/>
9099					</xsl:call-template>
9100				</xsl:variable>
9101				<xsl:call-template name="encode-as-cell-address">
9102					<xsl:with-param name="string" select="concat(../../ss:Worksheet/@ss:Name, '.', $range)"/>
9103				</xsl:call-template>
9104			</xsl:attribute>
9105			<xsl:element name="table:help-message">
9106				<xsl:attribute name="table:title">
9107					<xsl:value-of select="./x:InputTitle"/>
9108				</xsl:attribute>
9109				<xsl:attribute name="table:display">
9110					<xsl:choose>
9111						<xsl:when test="./x:InputHide">
9112							<xsl:value-of select="'false'"/>
9113						</xsl:when>
9114						<xsl:otherwise>
9115							<xsl:value-of select="'true'"/>
9116						</xsl:otherwise>
9117					</xsl:choose>
9118				</xsl:attribute>
9119				<xsl:element name="text:p">
9120					<xsl:value-of select="./x:InputMessage"/>
9121				</xsl:element>
9122			</xsl:element>
9123			<xsl:element name="table:error-message">
9124				<xsl:attribute name="table:message-type">
9125					<xsl:choose>
9126						<xsl:when test="./x:ErrorStyle= 'Info'">
9127							<xsl:value-of select="'information'"/>
9128						</xsl:when>
9129						<xsl:when test="./x:ErrorStyle= 'Warn'">
9130							<xsl:value-of select="'warning'"/>
9131						</xsl:when>
9132						<xsl:otherwise>
9133							<xsl:value-of select="'stop'"/>
9134						</xsl:otherwise>
9135					</xsl:choose>
9136				</xsl:attribute>
9137				<xsl:attribute name="table:title">
9138					<xsl:value-of select="./x:ErrorTitle"/>
9139				</xsl:attribute>
9140				<xsl:attribute name="table:display">
9141					<xsl:choose>
9142						<xsl:when test="./x:ErrorHide">
9143							<xsl:value-of select="'false'"/>
9144						</xsl:when>
9145						<xsl:otherwise>
9146							<xsl:value-of select="'true'"/>
9147						</xsl:otherwise>
9148					</xsl:choose>
9149				</xsl:attribute>
9150				<xsl:element name="text:p">
9151					<xsl:value-of select="./x:ErrorMessage"/>
9152				</xsl:element>
9153			</xsl:element>
9154		</xsl:element>
9155	</xsl:template>
9156	<!-- Note: Move template to common section -->
9157	<xsl:template name="encode-as-cell-range-address">
9158		<xsl:param name="string"/>
9159		<xsl:value-of select="$string"/>
9160	</xsl:template>
9161	<xsl:template name="encode-as-cell-address">
9162		<xsl:param name="string"/>
9163		<xsl:value-of select="$string"/>
9164	</xsl:template>
9165	<xsl:template name="encode-as-nc-name">
9166		<xsl:param name="string"/>
9167		<xsl:value-of select="translate($string, '.%()/\+[]', '')"/>
9168	</xsl:template>
9169</xsl:stylesheet>
9170