MsWordXMLImport.xsl.data revision 779:2b61bfcaa586
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 *
4 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 *
7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 *
25 -->
26 
27<!-- Start of OOo2.0 import/wordml/wordml2ooo.xsl stylesheet  -->
28<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
29    xmlns:v="urn:schemas-microsoft-com:vml" 
30    xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" 
31    xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" 
32    xmlns:o="urn:schemas-microsoft-com:office:office" 
33    xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
34    xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" 
35    xmlns:dc="http://purl.org/dc/elements/1.1/"    
36    xmlns:office="http://openoffice.org/2000/office"
37    xmlns:style="http://openoffice.org/2000/style"
38    xmlns:text="http://openoffice.org/2000/text"
39    xmlns:table="http://openoffice.org/2000/table"
40    xmlns:draw="http://openoffice.org/2000/drawing"
41    xmlns:fo="http://www.w3.org/1999/XSL/Format"
42    xmlns:xlink="http://www.w3.org/1999/xlink"
43    xmlns:number="http://openoffice.org/2000/datastyle"
44    xmlns:svg="http://www.w3.org/2000/svg"
45    xmlns:chart="http://openoffice.org/2000/chart"
46    xmlns:dr3d="http://openoffice.org/2000/dr3d"
47    xmlns:math="http://www.w3.org/1998/Math/MathML"
48    xmlns:form="http://openoffice.org/2000/form"
49    xmlns:script="http://openoffice.org/2000/script"
50    xmlns:meta="http://openoffice.org/2000/meta"
51    xmlns:config="http://openoffice.org/2001/config"
52    xmlns:help="http://openoffice.org/2000/help"
53    exclude-result-prefixes="v w wx aml o aml dt" 
54    office:version="1.0"
55    >
56    <xsl:output method="xml" indent="no" encoding="UTF-8" version="1.0"/>
57    <!--
58    <xsl:include href="../../common/measure_conversion.xsl"/>
59    <xsl:include href="../common/ms2ooo_docpr.xsl"/>
60    <xsl:include href="wordml2ooo_text.xsl"/>
61    <xsl:include href="wordml2ooo_settings.xsl"/>
62    <xsl:include href="wordml2ooo_table.xsl"/>
63    <xsl:include href="wordml2ooo_page.xsl"/>
64    <xsl:include href="wordml2ooo_list.xsl"/>
65    <xsl:include href="wordml2ooo_draw.xsl"/>
66    -->
67    <xsl:key name="paragraph-style" match="w:style[@w:type = 'paragraph']" use="@w:styleId"/>
68    <xsl:key name="heading-style" match="w:style[@w:type = 'paragraph' and w:pPr/w:outlineLvl]" use="@w:styleId"/>
69    <xsl:template match="/">
70        <xsl:apply-templates select="w:wordDocument"/>
71    </xsl:template>
72    <xsl:template match="w:wordDocument">
73        <office:document office:class="text" office:version="1.0">
74            <xsl:apply-templates select="o:DocumentProperties"/>
75            <xsl:apply-templates select="w:docPr"/>
76            <xsl:apply-templates select="w:fonts"/>
77            <xsl:apply-templates select="w:styles"/>
78            <xsl:apply-templates select="w:body"/>
79        </office:document>
80    </xsl:template>
81    <xsl:template match="w:fonts">
82        <xsl:element name="office:font-decls">
83            <!-- MS Word's default font declaration, added for Writer automatically. glu -->
84            <style:font-decl style:name="Arial" fo:font-family="Arial" style:font-family-generic="roman" style:font-pitch="variable"/>
85            <style:font-decl style:name="Times New Roman" fo:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/>
86            <style:font-decl style:name="Symbol" fo:font-family="Symbol" style:font-family-generic="roman" style:font-pitch="variable" style:font-charset="x-symbol"/>
87            <style:font-decl style:name="Courier New" fo:font-family="'Courier New'" style:font-family-generic="modern" style:font-pitch="fixed"/>
88            <xsl:if test="not(w:font[@w:name='StarSymbol'])">
89                <style:font-decl style:name="StarSymbol" fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
90            </xsl:if>
91            <xsl:for-each select="w:font">
92                <xsl:element name="style:font-decl">
93                    <xsl:attribute name="style:name"><xsl:value-of select="@w:name"/></xsl:attribute>
94                    <xsl:attribute name="fo:font-family"><xsl:value-of select="@w:name"/></xsl:attribute>
95                    <!-- added by glu, for process special fonts e.g. Marlett, -->
96                    <xsl:if test="w:charset/@w:val = '02'">
97                        <xsl:attribute name="style:font-charset">x-symbol</xsl:attribute>
98                    </xsl:if>
99                    <xsl:if test="w:family">
100                        <xsl:choose>
101                            <xsl:when test="w:family/@w:val = 'Swiss'">
102                                <xsl:attribute name="style:font-family-generic">swiss</xsl:attribute>
103                            </xsl:when>
104                            <xsl:when test="w:family/@w:val='Modern'">
105                                <xsl:attribute name="style:font-family-generic">modern</xsl:attribute>
106                            </xsl:when>
107                            <xsl:when test="w:family/@w:val='Roman'">
108                                <xsl:attribute name="style:font-family-generic">roman</xsl:attribute>
109                            </xsl:when>
110                            <xsl:when test="w:family/@w:val='Script'">
111                                <xsl:attribute name="style:font-family-generic">script</xsl:attribute>
112                            </xsl:when>
113                            <xsl:when test="w:family/@w:val='Decorative'">
114                                <xsl:attribute name="style:font-family-generic">decorative</xsl:attribute>
115                            </xsl:when>
116                            <xsl:when test="w:family/@w:val='System'">
117                                <xsl:attribute name="style:font-family-generic">system</xsl:attribute>
118                            </xsl:when>
119                            <xsl:otherwise>
120                                <xsl:attribute name="style:font-family-generic">system</xsl:attribute>
121                            </xsl:otherwise>
122                        </xsl:choose>
123                    </xsl:if>
124                    <xsl:if test="w:pitch">
125                        <xsl:attribute name="style:font-pitch"><xsl:value-of select="w:pitch/@w:val"/></xsl:attribute>
126                    </xsl:if>
127                </xsl:element>
128            </xsl:for-each>
129        </xsl:element>
130    </xsl:template>
131    <xsl:template match="w:styles">
132        <office:styles>
133            <xsl:call-template name="create-default-paragraph-styles"/>
134            <xsl:call-template name="create-default-text-styles"/>
135            <xsl:call-template name="create-default-frame-style"/>
136            <!-- StarWriter has no default style family 'list'. glu -->
137            <xsl:if test="w:style[@w:type = 'paragraph' and w:pPr/w:outlineLvl and w:pPr/w:listPr]">
138                <xsl:call-template name="create-outline-style"/>
139            </xsl:if>
140            <xsl:apply-templates select="w:style[@w:type='list']" mode="list"/>
141            <xsl:apply-templates select="w:style[@w:type!='list']"/>
142        </office:styles>
143        <office:automatic-styles>
144            <xsl:apply-templates select="/w:wordDocument/w:body//w:p" mode="style"/>
145            <xsl:apply-templates select="/w:wordDocument/w:body//w:rPr[not(parent::w:pPr)]" mode="style"/>
146            <xsl:apply-templates select="/w:wordDocument/w:body//w:tblPr" mode="style"/>
147            <xsl:apply-templates select="/w:wordDocument/w:body//w:gridCol" mode="style"/>
148            <xsl:apply-templates select="/w:wordDocument/w:body//w:trHeight" mode="style"/>
149            <xsl:apply-templates select="/w:wordDocument/w:body//w:tcPr" mode="style"/>
150            <xsl:apply-templates select="/w:wordDocument/w:body//w:listPr" mode="style"/>
151            <xsl:apply-templates select="/w:wordDocument/w:body//w:sectPr" mode="page-master"/>
152        </office:automatic-styles>
153        <office:master-styles>
154            <xsl:apply-templates select="/w:wordDocument/w:body//w:sectPr" mode="master-page"/>
155        </office:master-styles>
156    </xsl:template>
157    <xsl:template match="w:style">
158        <style:style>
159            <xsl:attribute name="style:name"><xsl:value-of select="@w:styleId"/></xsl:attribute>
160            <xsl:if test="w:basedOn">
161                <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:basedOn/@w:val"/></xsl:attribute>
162            </xsl:if>
163            <xsl:if test="w:next">
164                <xsl:attribute name="style:next-style-name"><xsl:value-of select="w:next/@w:val"/></xsl:attribute>
165            </xsl:if>
166            <xsl:choose>
167                <xsl:when test="@w:type = 'character'">
168                    <xsl:attribute name="style:family">text</xsl:attribute>
169                </xsl:when>
170                <!-- table, paragraph are the same as in Writer . glu -->
171                <xsl:when test="@w:type">
172                    <xsl:attribute name="style:family"><xsl:value-of select="@w:type"/></xsl:attribute>
173                </xsl:when>
174                <xsl:otherwise>
175                    <xsl:attribute name="style:family">text</xsl:attribute>
176                </xsl:otherwise>
177            </xsl:choose>
178            <xsl:element name="style:properties">
179                <xsl:apply-templates select="w:pPr"/>
180                <xsl:apply-templates select="w:rPr"/>
181            </xsl:element>
182        </style:style>
183    </xsl:template>
184    <xsl:template match="w:body">
185        <xsl:element name="office:body">
186            <xsl:apply-templates/>
187        </xsl:element>
188    </xsl:template>
189    <xsl:template name="create-default-frame-style">
190        <!--add for default frame style -->
191        <style:style style:name="Frame" style:family="graphics">
192            <style:properties text:anchor-type="paragraph" svg:x="0inch" svg:y="0inch" style:wrap="parallel" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content"/>
193        </style:style>
194    </xsl:template>
195    
196<!-- End of OOo2.0 import/wordml/wordml2ooo.xsl stylesheet  -->
197<!-- Start of OOo2.0 import/wordml/wordml2ooo_draw.xsl stylesheet  -->
198    <xsl:template match="w:pict">
199        <xsl:choose>
200            <xsl:when test="descendant::w:binData">
201                <!-- Cannot load zipped Wmf file. glu <xsl:if test="not(contains(w:binData/@w:name,'.wmz'))"> -->
202                <xsl:element name="draw:image">
203                    <xsl:if test="v:shape/@style">
204                        <xsl:if test="contains( v:shape/@style, 'margin-left:')">
205                            <xsl:attribute name="svg:x"><xsl:value-of select="concat( number(substring-before( substring-after( v:shape/@style, 'margin-left:'), 'pt'))*0.0353, 'cm')"/></xsl:attribute>
206                        </xsl:if>
207                        <xsl:if test="contains( v:shape/@style, 'margin-top:')">
208                            <xsl:attribute name="svg:y"><xsl:value-of select="concat( number(substring-before( substring-after( v:shape/@style, 'margin-top:'), 'pt'))*0.0353, 'cm')"/></xsl:attribute>
209                        </xsl:if>
210                        <xsl:attribute name="svg:width"><xsl:value-of select="concat( number(substring-before( substring-after( v:shape/@style, 'width:'), 'pt'))*0.0353, 'cm')"/></xsl:attribute>
211                        <xsl:attribute name="svg:height"><xsl:value-of select="concat( number(substring-before( substring-after( v:shape/@style, 'height:'), 'pt'))*0.0353, 'cm')"/></xsl:attribute>
212                        <xsl:variable name="anchor-type">
213                            <xsl:if test="contains( v:shape/@style, 'mso-position-horizontal-relative')">
214                                <xsl:value-of select="substring-before( substring-after( v:shape/@style, 'mso-position-horizontal-relative:'), ';')"/>
215                            </xsl:if>
216                        </xsl:variable>
217                        <xsl:choose>
218                            <xsl:when test="$anchor-type = 'margin'">
219                                <xsl:attribute name="text:anchor-type">frame</xsl:attribute>
220                            </xsl:when>
221                            <xsl:when test="$anchor-type = 'page'">
222                                <xsl:attribute name="text:anchor-type">page</xsl:attribute>
223                            </xsl:when>
224                            <xsl:when test="$anchor-type = 'char'">
225                                <xsl:attribute name="text:anchor-type">as-char</xsl:attribute>
226                            </xsl:when>
227                            <xsl:otherwise>
228                                <xsl:attribute name="text:anchor-type">paragraph</xsl:attribute>
229                            </xsl:otherwise>
230                        </xsl:choose>
231                        <xsl:if test="v:shape/v:imagedata/@o:title">
232                            <xsl:attribute name="draw:name"><xsl:value-of select="v:shape/v:imagedata/@o:title"/></xsl:attribute>
233                        </xsl:if>
234                        <xsl:element name="office:binary-data">
235                            <xsl:value-of select="w:binData"/>
236                        </xsl:element>
237                    </xsl:if>
238                </xsl:element>
239            </xsl:when>
240            <xsl:otherwise>
241                <xsl:apply-templates/>
242            </xsl:otherwise>
243        </xsl:choose>
244    </xsl:template>
245    <xsl:template match="w:binData">
246        <xsl:element name="office:binary-data">
247            <xsl:value-of select="."/>
248        </xsl:element>
249    </xsl:template>
250    <xsl:template match="v:group">
251        <xsl:apply-templates/>
252    </xsl:template>
253    <xsl:template match="v:oval">
254        <xsl:element name="draw:ellipse">
255            <xsl:variable name="style" select="@style"/>
256            <xsl:variable name="position" select="substring-after($style,'position:')"/>
257            <xsl:variable name="positionval" select="substring-before($position,';')"/>
258            <xsl:variable name="left" select="substring-after($style,'left:')"/>
259            <xsl:variable name="leftval" select="substring-before($left,';')"/>
260            <xsl:variable name="top" select="substring-after($style,'top:')"/>
261            <xsl:variable name="topval" select="substring-before($top,';')"/>
262            <xsl:variable name="width" select="substring-after($style,'width:')"/>
263            <xsl:variable name="widthval" select="substring-before($width,';')"/>
264            <xsl:variable name="height" select="substring-after($style,'height:')"/>
265            <xsl:variable name="heightval" select="$height"/>
266            <xsl:if test="$positionval = 'absolute'">
267                <xsl:variable name="parentgroup" select="parent::v:group"/>
268                <xsl:variable name="origin" select="$parentgroup/@coordorigin"/>
269                <xsl:variable name="groupleft" select="substring-before($origin,',')"/>
270                <xsl:variable name="grouptop" select="substring-after($origin,',')"/>
271                <xsl:variable name="currsect" select="ancestor::wx:sect"/>
272                <xsl:variable name="currsectPr" select="$currsect/descendant::w:sectPr/w:pgMar"/>
273                <xsl:variable name="leftmar" select="$currsectPr/@w:left"/>
274                <xsl:variable name="topmar" select="$currsectPr/@w:top"/>
275                <xsl:attribute name="text:anchor-type">page</xsl:attribute>
276                <xsl:attribute name="svg:width"><xsl:value-of select="(number($widthval) div 1440) * 2.54"/>cm</xsl:attribute>
277                <xsl:attribute name="svg:height"><xsl:value-of select="(number($heightval) div 1440) * 2.54"/>cm</xsl:attribute>
278                <xsl:attribute name="svg:x"><xsl:value-of select="(number($topval + $topmar) div 1440) * 2.54"/>cm</xsl:attribute>
279                <xsl:attribute name="svg:y"><xsl:value-of select="(number($leftval + $leftmar) div 1440) * 2.54"/>cm</xsl:attribute>
280            </xsl:if>
281        </xsl:element>
282    </xsl:template>
283    <xsl:template match="v:rect">
284        <xsl:element name="draw:rect">
285            <xsl:variable name="style" select="@style"/>
286            <xsl:variable name="position" select="substring-after($style,'position:')"/>
287            <xsl:variable name="positionval" select="substring-before($position,';')"/>
288            <xsl:variable name="left" select="substring-after($style,'left:')"/>
289            <xsl:variable name="leftval" select="substring-before($left,';')"/>
290            <xsl:variable name="top" select="substring-after($style,'top:')"/>
291            <xsl:variable name="topval" select="substring-before($top,';')"/>
292            <xsl:variable name="width" select="substring-after($style,'width:')"/>
293            <xsl:variable name="widthval" select="substring-before($width,';')"/>
294            <xsl:variable name="height" select="substring-after($style,'height:')"/>
295            <xsl:variable name="heightval" select="$height"/>
296            <xsl:if test="$positionval = 'absolute'">
297                <xsl:variable name="parentgroup" select="parent::v:group"/>
298                <xsl:variable name="origin" select="$parentgroup/@coordorigin"/>
299                <xsl:variable name="groupleft" select="substring-before($origin,',')"/>
300                <xsl:variable name="grouptop" select="substring-after($origin,',')"/>
301                <xsl:variable name="currsect" select="ancestor::wx:sect"/>
302                <xsl:variable name="currsectPr" select="$currsect/descendant::w:sectPr/w:pgMar"/>
303                <xsl:variable name="leftmar" select="$currsectPr/@w:left"/>
304                <xsl:variable name="topmar" select="$currsectPr/@w:top"/>
305                <xsl:attribute name="text:anchor-type">page</xsl:attribute>
306                <xsl:attribute name="svg:width"><xsl:value-of select="(number($widthval) div 1440) * 2.54"/>cm</xsl:attribute>
307                <xsl:attribute name="svg:height"><xsl:value-of select="(number($heightval) div 1440) * 2.54"/>cm</xsl:attribute>
308                <xsl:attribute name="svg:x"><xsl:value-of select="(number($topval + $topmar) div 1440) * 2.54"/>cm</xsl:attribute>
309                <xsl:attribute name="svg:y"><xsl:value-of select="(number($leftval + $leftmar) div 1440) * 2.54"/>cm</xsl:attribute>
310            </xsl:if>
311        </xsl:element>
312    </xsl:template>
313<!-- End of OOo2.0 import/wordml/wordml2ooo_draw.xsl stylesheet  -->
314<!-- Start of OOo2.0 import/wordml/wordml2ooo_list.xsl stylesheet  -->
315    <xsl:template match="w:listPr" mode="style">
316        <xsl:variable name="currlistid" select="w:ilfo/@w:val"/>
317        <xsl:variable name="currlist" select="."/>
318        <xsl:variable name="rootlistid" select="/w:wordDocument/w:lists/w:list[@w:ilfo=$currlistid]/w:ilst/@w:val"/>
319        <xsl:variable name="rootlist" select="/w:wordDocument/w:lists/w:listDef[@w:listDefId =$rootlistid ]"/>
320        <xsl:if test="not(ancestor::w:p/preceding-sibling::w:p/w:pPr/w:listPr[1]/w:ilfo/@w:val= $currlistid) and $rootlist/w:lvl ">
321            <xsl:element name="text:list-style">
322                <xsl:attribute name="style:name">List<xsl:value-of select="count(preceding::w:listPr)"/></xsl:attribute>
323                <xsl:apply-templates select="$rootlist/w:lvl"/>
324            </xsl:element>
325        </xsl:if>
326    </xsl:template>
327    <xsl:template match="w:lvl">
328        <xsl:variable name="listtype">
329            <xsl:choose>
330                <xsl:when test="w:nfc/@w:val">
331                    <xsl:value-of select="w:nfc/@w:val"/>
332                </xsl:when>
333                <xsl:otherwise>0</xsl:otherwise>
334            </xsl:choose>
335        </xsl:variable>
336        <xsl:choose>
337            <xsl:when test="$listtype =23 and w:lvlPicBulletId">
338                <!-- image characters. wym -->
339                <xsl:element name="text:list-level-style-image">
340                    <xsl:call-template name="list-styles-image"/>
341                </xsl:element>
342            </xsl:when>
343            <xsl:when test="$listtype =23">
344                <!-- nfcBullet: Bullet character. glu -->
345                <xsl:element name="text:list-level-style-bullet">
346                    <xsl:call-template name="list-styles-common">
347                        <xsl:with-param name="listtype" select="$listtype"/>
348                        <xsl:with-param name="currlevel" select="number(@w:ilvl)+1"/>
349                    </xsl:call-template>
350                </xsl:element>
351            </xsl:when>
352            <xsl:otherwise>
353                <!-- all kinds of numbering characters. glu :( -->
354                <xsl:element name="text:list-level-style-number">
355                    <xsl:call-template name="list-styles-common">
356                        <xsl:with-param name="listtype" select="$listtype"/>
357                        <xsl:with-param name="currlevel" select="number(@w:ilvl)+1"/>
358                    </xsl:call-template>
359                </xsl:element>
360            </xsl:otherwise>
361        </xsl:choose>
362    </xsl:template>
363    <xsl:template name="list-styles-common">
364        <xsl:param name="listtype"/>
365        <xsl:param name="currlevel"/>
366        <xsl:variable name="startval" select="w:start/@w:val"/>
367        <xsl:attribute name="text:level"><xsl:value-of select="$currlevel"/></xsl:attribute>
368        <xsl:choose>
369            <xsl:when test="$listtype = 23">
370                <!-- bullet character. glu -->
371                <xsl:attribute name="text:style-name">Bullet Symbols</xsl:attribute>
372                <xsl:attribute name="text:bullet-char"><xsl:value-of select="w:lvlText/@w:val"/></xsl:attribute>
373            </xsl:when>
374            <xsl:when test="($listtype &gt;= 0) and ($listtype &lt; 60)">
375                <xsl:attribute name="text:style-name">Numbering Symbols</xsl:attribute>
376                <xsl:if test="$startval">
377                    <xsl:attribute name="text:start-value"><xsl:value-of select="$startval"/></xsl:attribute>
378                </xsl:if>
379                <xsl:attribute name="text:display-levels"><xsl:value-of select="string-length(w:lvlText/@w:val) - string-length(translate(w:lvlText/@w:val,'%','') )"/></xsl:attribute>
380                <xsl:call-template name="nfc2numformat">
381                    <xsl:with-param name="nfcvalue" select="$listtype"/>
382                    <xsl:with-param name="prefix" select="substring-before(w:lvlText/@w:val, '%')"/>
383                    <xsl:with-param name="suffix" select="substring-after(w:lvlText/@w:val, concat('%', $currlevel) )"/>
384                </xsl:call-template>
385            </xsl:when>
386            <xsl:otherwise>
387                <xsl:attribute name="text:style-name">Numbering Symbols</xsl:attribute>
388                <xsl:if test="$startval">
389                    <xsl:attribute name="text:start-value"><xsl:value-of select="$startval"/></xsl:attribute>
390                </xsl:if>
391                <xsl:attribute name="text:display-levels"><xsl:value-of select="string-length(w:lvlText/@w:val) - string-length(translate(w:lvlText/@w:val,'%','') )"/></xsl:attribute>
392                <!-- 'none' in Word 2003. wym -->
393                <xsl:attribute name="style:num-format"/>
394                <xsl:attribute name="style:num-prefix"><xsl:value-of select="substring-before(w:lvlText/@w:val, '%')"/></xsl:attribute>
395                <xsl:attribute name="style:num-suffix"><xsl:value-of select="substring-after(w:lvlText/@w:val, concat('%', $currlevel + 1) )"/></xsl:attribute>
396            </xsl:otherwise>
397        </xsl:choose>
398        <xsl:element name="style:properties">
399            <xsl:choose>
400                <xsl:when test="w:lvlJc/@w:val='right'">
401                    <xsl:attribute name="fo:text-align">end</xsl:attribute>
402                </xsl:when>
403                <xsl:when test="w:lvlJc/@w:val='center'">
404                    <xsl:attribute name="fo:text-align">center</xsl:attribute>
405                </xsl:when>
406                <xsl:otherwise>
407                    <xsl:attribute name="fo:text-align">start</xsl:attribute>
408                </xsl:otherwise>
409            </xsl:choose>
410            <xsl:variable name="labelwidth">
411                <xsl:choose>
412                    <xsl:when test="w:pPr/w:ind/@w:hanging">
413                        <xsl:call-template name="convert2cm">
414                            <xsl:with-param name="value" select="concat(w:pPr/w:ind/@w:hanging,'dxa')"/>
415                        </xsl:call-template>
416                    </xsl:when>
417                    <xsl:when test="w:pPr/w:ind/@w:first-line">
418                        <xsl:call-template name="convert2cm">
419                            <xsl:with-param name="value" select="concat('-',w:pPr/w:ind/@w:first-line,'dxa')"/>
420                        </xsl:call-template>
421                    </xsl:when>
422                    <xsl:otherwise>0</xsl:otherwise>
423                </xsl:choose>
424            </xsl:variable>
425            <xsl:variable name="leftwidth">
426                <xsl:call-template name="convert2cm">
427                    <xsl:with-param name="value" select="concat(w:pPr/w:ind/@w:left,'dxa')"/>
428                </xsl:call-template>
429            </xsl:variable>
430            <xsl:attribute name="text:space-before"><xsl:value-of select="concat(number($leftwidth)-number($labelwidth),'cm')"/></xsl:attribute>
431            <xsl:attribute name="text:min-label-width"><xsl:choose><xsl:when test="$labelwidth &gt; 0"><xsl:value-of select="concat($labelwidth,'cm')"/></xsl:when><xsl:otherwise>0cm</xsl:otherwise></xsl:choose></xsl:attribute>
432            <!-- In binary word translation, text:min-label-distance do not generate. So, the width of number-symbol will not effect the start position of text. But first line always start same position of second line, no indent. If text:min-label-distance generate, the look of list will change because of uncountable number-symbol's width, now use 0.25cm as default width-->
433            <xsl:choose>
434                <xsl:when test="w:suff/@w:val='Space'">
435                    <xsl:attribute name="text:min-label-distance">0.20cm</xsl:attribute>
436                </xsl:when>
437                <xsl:when test="w:pPr/w:tabs/w:tab/@w:pos">
438                    <xsl:variable name="tabpos">
439                        <xsl:call-template name="convert2cm">
440                            <xsl:with-param name="value" select="concat(w:pPr/w:tabs/w:tab/@w:pos,'dxa')"/>
441                        </xsl:call-template>
442                    </xsl:variable>
443                    <xsl:if test="number($tabpos) &gt; (number($leftwidth)-number($labelwidth))">
444                        <xsl:attribute name="text:min-label-distance"><xsl:value-of select="concat(number($tabpos)+number($labelwidth)-number($leftwidth)-0.25,'cm')"/></xsl:attribute>
445                    </xsl:if>
446                </xsl:when>
447            </xsl:choose>
448            <!-- Find the node that corresponds to the level being processed. We can use this to determine the indentation to be used
449            <xsl:variable name="currNode" select="/w:wordDocument/w:body//w:listPr[w:ilvl/@w:val = $currlevel][w:ilfo/@w:val = $currlist/w:ilfo/@w:val]"/>
450            <xsl:choose>
451                <xsl:when test="($currNode/wx:t/@wx:wTabBefore ) and ($currNode/wx:t/@wx:wTabAfter ) and (not($currNode/following-sibling::w:jc) or $currNode/following-sibling::w:jc/@w:val = 'left')">
452                    <xsl:attribute name="text:space-before"><xsl:value-of select="(number($currNode/wx:t/@wx:wTabBefore)div 1440) * 2.54"/>cm</xsl:attribute>
453                    <xsl:attribute name="text:min-label-distance"><xsl:value-of select="(number($currNode/wx:t/@wx:wTabAfter)div 1440) * 2.54"/>cm</xsl:attribute>
454                </xsl:when>
455                <xsl:otherwise>
456                    <xsl:attribute name="text:space-before"><xsl:value-of select="((number(w:pPr/w:ind/@w:left)  div 1440) * 2.54) "/>cm</xsl:attribute>
457                    <xsl:attribute name="text:min-label-distance"><xsl:value-of select="(number($currlist/wx:t/@wx:wTabAfter) div 1440) * 2.54"/>cm</xsl:attribute>
458                </xsl:otherwise>
459            </xsl:choose>-->
460            <xsl:if test="w:rPr/w:rFonts">
461                <xsl:if test="w:rPr/w:rFonts/@w:ascii">
462                    <xsl:attribute name="style:font-name"><xsl:value-of select="w:rPr/w:rFonts/@w:ascii"/></xsl:attribute>
463                </xsl:if>
464                <xsl:if test="w:rPr/w:rFonts/@w:fareast">
465                    <xsl:attribute name="style:font-name-asian"><xsl:value-of select="w:rPr/w:rFonts/@w:fareast"/></xsl:attribute>
466                </xsl:if>
467                <xsl:if test="w:rPr/w:rFonts/@w:cs">
468                    <xsl:attribute name="style:font-name-complex"><xsl:value-of select="w:rPr/w:rFonts/@w:cs"/></xsl:attribute>
469                </xsl:if>
470            </xsl:if>
471        </xsl:element>
472    </xsl:template>
473    <xsl:template name="list-styles-image">
474        <xsl:variable name="currlevel" select="number(@w:ilvl)"/>
475        <xsl:attribute name="text:level"><xsl:value-of select="$currlevel+1"/></xsl:attribute>
476        <xsl:variable name="picid" select="w:lvlPicBulletId/@w:val"/>
477        <xsl:element name="style:properties">
478            <xsl:attribute name="style:vertical-pos">middle</xsl:attribute>
479            <xsl:attribute name="style:vertical-rel">line</xsl:attribute>
480            <xsl:variable name="picsize" select="/descendant::w:lists/w:listPicBullet[@w:listPicBulletId=$picid]/w:pict/v:shape/@style"/>
481            <xsl:attribute name="fo:width"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="substring-before(substring-after($picsize,'width:'), ';')"/></xsl:call-template><xsl:text>cm</xsl:text></xsl:attribute>
482            <xsl:attribute name="fo:height"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="substring-after($picsize,'height:')"/></xsl:call-template><xsl:text>cm</xsl:text></xsl:attribute>
483            <xsl:variable name="labelwidth">
484                <xsl:choose>
485                    <xsl:when test="w:pPr/w:ind/@w:hanging">
486                        <xsl:call-template name="convert2cm">
487                            <xsl:with-param name="value" select="concat(w:pPr/w:ind/@w:hanging,'dxa')"/>
488                        </xsl:call-template>
489                    </xsl:when>
490                    <xsl:when test="w:pPr/w:ind/@w:first-line">
491                        <xsl:call-template name="convert2cm">
492                            <xsl:with-param name="value" select="concat('-',w:pPr/w:ind/@w:first-line,'dxa')"/>
493                        </xsl:call-template>
494                    </xsl:when>
495                    <xsl:otherwise>0</xsl:otherwise>
496                </xsl:choose>
497            </xsl:variable>
498            <xsl:variable name="leftwidth">
499                <xsl:call-template name="convert2cm">
500                    <xsl:with-param name="value" select="concat(w:pPr/w:ind/@w:left,'dxa')"/>
501                </xsl:call-template>
502            </xsl:variable>
503            <xsl:attribute name="text:space-before"><xsl:value-of select="concat(number($leftwidth)-number($labelwidth),'cm')"/></xsl:attribute>
504            <xsl:attribute name="text:min-label-width"><xsl:choose><xsl:when test="$labelwidth &gt; 0"><xsl:value-of select="concat($labelwidth,'cm')"/></xsl:when><xsl:otherwise>0cm</xsl:otherwise></xsl:choose></xsl:attribute>
505            <xsl:choose>
506                <xsl:when test="w:suff/@w:val='Space'">
507                    <xsl:attribute name="text:min-label-distance">0.20cm</xsl:attribute>
508                </xsl:when>
509                <xsl:when test="w:pPr/w:tabs/w:tab/@w:pos">
510                    <xsl:variable name="tabpos">
511                        <xsl:call-template name="convert2cm">
512                            <xsl:with-param name="value" select="concat(w:pPr/w:tabs/w:tab/@w:pos,'dxa')"/>
513                        </xsl:call-template>
514                    </xsl:variable>
515                    <xsl:if test="number($tabpos) &gt; (number($leftwidth)-number($labelwidth))">
516                        <xsl:attribute name="text:min-label-distance"><xsl:value-of select="concat(number($tabpos)+number($labelwidth)-number($leftwidth),'cm')"/></xsl:attribute>
517                    </xsl:if>
518                </xsl:when>
519            </xsl:choose>
520        </xsl:element>
521        <office:binary-data>
522            <xsl:value-of select="/descendant::w:lists/w:listPicBullet[@w:listPicBulletId=$picid]/w:pict/w:binData"/>
523        </office:binary-data>
524    </xsl:template>
525    <!-- avoid listPr in textbox. :( glu -->
526    <xsl:template match="w:p[w:pPr/w:listPr[w:ilvl and w:ilfo]]">
527        <xsl:call-template name="genlist"/>
528    </xsl:template>
529    <xsl:template name="genlist">
530        <xsl:variable name="currlistid" select="w:pPr/w:listPr/w:ilfo/@w:val"/>
531        <xsl:variable name="currlistlvl" select="w:pPr/w:listPr/w:ilvl/@w:val"/>
532        <xsl:variable name="firstoccur" select="/descendant::w:pPr[w:listPr/w:ilfo/@w:val = $currlistid][1]"/>
533        <xsl:variable name="rootlistid" select="/w:wordDocument/w:lists/w:list[@w:ilfo=$currlistid]/w:ilst/@w:val"/>
534        <xsl:variable name="rootlistname" select="/w:wordDocument/w:lists/w:listDef[@w:listDefId =$rootlistid ]/w:listStyleLink/@w:val"/>
535        <xsl:element name="text:ordered-list">
536            <xsl:attribute name="text:style-name"><xsl:choose><xsl:when test="string-length($rootlistname) &gt; 0"><xsl:value-of select="$rootlistname"/></xsl:when><xsl:otherwise>List<xsl:value-of select="count($firstoccur/preceding::w:listPr)"/></xsl:otherwise></xsl:choose></xsl:attribute>
537            <xsl:choose>
538                <xsl:when test="preceding::w:pPr/w:listPr/w:ilfo/@w:val = w:pPr/w:listPr/w:ilfo/@w:val">
539                    <xsl:attribute name="text:continue-numbering">true</xsl:attribute>
540                    <xsl:element name="text:list-item">
541                        <xsl:call-template name="levels">
542                            <xsl:with-param name="level" select="$currlistlvl"/>
543                        </xsl:call-template>
544                    </xsl:element>
545                </xsl:when>
546                <xsl:otherwise>
547                    <xsl:element name="text:list-item">
548                        <xsl:call-template name="levels">
549                            <xsl:with-param name="level" select="$currlistlvl"/>
550                        </xsl:call-template>
551                    </xsl:element>
552                </xsl:otherwise>
553            </xsl:choose>
554        </xsl:element>
555    </xsl:template>
556    <xsl:template name="levels">
557        <xsl:param name="level"/>
558        <xsl:choose>
559            <xsl:when test="$level = '0'">
560                <xsl:call-template name="process-common-paragraph"/>
561            </xsl:when>
562            <xsl:otherwise>
563                <xsl:element name="text:ordered-list">
564                    <xsl:element name="text:list-item">
565                        <xsl:call-template name="levels">
566                            <xsl:with-param name="level" select="$level -1"/>
567                        </xsl:call-template>
568                    </xsl:element>
569                </xsl:element>
570            </xsl:otherwise>
571        </xsl:choose>
572    </xsl:template>
573    <xsl:template match="w:style" mode="list">
574        <xsl:variable name="listname" select="@w:styleId"/>
575        <xsl:if test="/w:wordDocument/w:lists/w:listDef[w:styleLink/@w:val=$listname]">
576            <text:list-style style:name="{$listname}">
577                <xsl:apply-templates select="/w:wordDocument/w:lists/w:listDef[w:styleLink/@w:val=$listname]/w:lvl"/>
578            </text:list-style>
579        </xsl:if>
580    </xsl:template>
581    <!-- for create outline style in office:styles -->
582    <xsl:template name="create-outline-style">
583        <xsl:element name="text:outline-style">
584            <xsl:call-template name="outline-level-style">
585                <xsl:with-param name="level" select="1"/>
586            </xsl:call-template>
587            <xsl:call-template name="outline-level-style">
588                <xsl:with-param name="level" select="2"/>
589            </xsl:call-template>
590            <xsl:call-template name="outline-level-style">
591                <xsl:with-param name="level" select="3"/>
592            </xsl:call-template>
593            <xsl:call-template name="outline-level-style">
594                <xsl:with-param name="level" select="4"/>
595            </xsl:call-template>
596            <xsl:call-template name="outline-level-style">
597                <xsl:with-param name="level" select="5"/>
598            </xsl:call-template>
599            <xsl:call-template name="outline-level-style">
600                <xsl:with-param name="level" select="6"/>
601            </xsl:call-template>
602            <xsl:call-template name="outline-level-style">
603                <xsl:with-param name="level" select="7"/>
604            </xsl:call-template>
605            <xsl:call-template name="outline-level-style">
606                <xsl:with-param name="level" select="8"/>
607            </xsl:call-template>
608            <xsl:call-template name="outline-level-style">
609                <xsl:with-param name="level" select="9"/>
610            </xsl:call-template>
611            <xsl:call-template name="outline-level-style">
612                <xsl:with-param name="level" select="10"/>
613            </xsl:call-template>
614        </xsl:element>
615    </xsl:template>
616    <xsl:template name="outline-level-style">
617        <xsl:param name="level"/>
618        <xsl:element name="text:outline-level-style">
619            <xsl:choose>
620                <xsl:when test="w:style[@w:type = 'paragraph' and (w:pPr/w:outlineLvl/@w:val = $level -1) and w:pPr/w:listPr]">
621                    <xsl:apply-templates select="(w:style[@w:type = 'paragraph' and w:pPr/w:outlineLvl/@w:val = $level -1 and w:pPr/w:listPr ]/w:pPr/w:listPr)[position()=1]" mode="outline">
622                        <xsl:with-param name="outlinelevel" select="$level"/>
623                    </xsl:apply-templates>
624                </xsl:when>
625                <xsl:otherwise>
626                    <xsl:attribute name="text:level"><xsl:value-of select="$level"/></xsl:attribute>
627                    <xsl:attribute name="style:num-format"/>
628                </xsl:otherwise>
629            </xsl:choose>
630        </xsl:element>
631    </xsl:template>
632    <xsl:template match="w:listPr" mode="outline">
633        <xsl:param name="outlinelevel"/>
634        <xsl:variable name="currlistid" select="w:ilfo/@w:val"/>
635        <xsl:variable name="currlistlevel">
636            <xsl:choose>
637                <xsl:when test="w:ilvl">
638                    <xsl:value-of select="w:ilvl/@w:val"/>
639                </xsl:when>
640                <xsl:otherwise>0</xsl:otherwise>
641            </xsl:choose>
642        </xsl:variable>
643        <xsl:variable name="rootlistid" select="/w:wordDocument/w:lists/w:list[@w:ilfo=$currlistid]/w:ilst/@w:val"/>
644        <xsl:variable name="rootlist" select="/w:wordDocument/w:lists/w:listDef[@w:listDefId =$rootlistid ]"/>
645        <xsl:for-each select="$rootlist/w:lvl[@w:ilvl=$currlistlevel]">
646            <xsl:call-template name="list-styles-common">
647                <xsl:with-param name="listtype">
648                    <xsl:choose>
649                        <xsl:when test="w:nfc/@w:val">
650                            <xsl:value-of select="w:nfc/@w:val"/>
651                        </xsl:when>
652                        <xsl:otherwise>0</xsl:otherwise>
653                    </xsl:choose>
654                </xsl:with-param>
655                <xsl:with-param name="currlevel" select="$outlinelevel"/>
656            </xsl:call-template>
657        </xsl:for-each>
658    </xsl:template>
659    <xsl:template name="nfc2numformat">
660        <xsl:param name="nfcvalue"/>
661        <xsl:param name="prefix"/>
662        <xsl:param name="suffix"/>
663        <xsl:choose>
664            <xsl:when test="$nfcvalue=0">
665                <xsl:attribute name="style:num-format">1</xsl:attribute>
666            </xsl:when>
667            <xsl:when test="$nfcvalue=1">
668                <xsl:attribute name="style:num-format">I</xsl:attribute>
669            </xsl:when>
670            <xsl:when test="$nfcvalue=2">
671                <xsl:attribute name="style:num-format">i</xsl:attribute>
672            </xsl:when>
673            <xsl:when test="$nfcvalue=3">
674                <xsl:attribute name="style:num-format">A</xsl:attribute>
675            </xsl:when>
676            <xsl:when test="$nfcvalue=4">
677                <xsl:attribute name="style:num-format">a</xsl:attribute>
678            </xsl:when>
679            <xsl:when test="$nfcvalue=10 or $nfcvalue=11 or $nfcvalue=17 or $nfcvalue=29 or $nfcvalue=33 or $nfcvalue=35 or $nfcvalue=36 or $nfcvalue=37 or $nfcvalue=39 or $nfcvalue=44">
680                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
681            </xsl:when>
682            <xsl:when test="$nfcvalue=12">
683                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
684            </xsl:when>
685            <xsl:when test="$nfcvalue=13">
686                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
687            </xsl:when>
688            <xsl:when test="$nfcvalue=14 or $nfcvalue=19">
689                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
690            </xsl:when>
691            <xsl:when test="$nfcvalue=16">
692                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
693            </xsl:when>
694            <xsl:when test="$nfcvalue=18 or $nfcvalue=28">
695                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
696            </xsl:when>
697            <xsl:when test="$nfcvalue=20">
698                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
699            </xsl:when>
700            <xsl:when test="$nfcvalue=21">
701                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
702            </xsl:when>
703            <xsl:when test="$nfcvalue=24">
704                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
705            </xsl:when>
706            <xsl:when test="$nfcvalue=25">
707                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
708            </xsl:when>
709            <xsl:when test="$nfcvalue=30">
710                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
711            </xsl:when>
712            <xsl:when test="$nfcvalue=31">
713                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
714            </xsl:when>
715            <xsl:when test="$nfcvalue=34">
716                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
717            </xsl:when>
718            <xsl:when test="$nfcvalue=38">
719                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
720            </xsl:when>
721            <xsl:when test="$nfcvalue=41 or $nfcvalue=42 or $nfcvalue=43">
722                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
723            </xsl:when>
724            <xsl:when test="$nfcvalue=45 or $nfcvalue=47">
725                <xsl:attribute name="style:num-format">��, ��, ��, ...</xsl:attribute>
726            </xsl:when>
727            <xsl:when test="$nfcvalue=46 or $nfcvalue=48">
728                <xsl:attribute name="style:num-format">��, ��, ��, ...</xsl:attribute>
729            </xsl:when>
730            <xsl:when test="$nfcvalue=53">
731                <xsl:attribute name="style:num-format">���, ���, ���, ...</xsl:attribute>
732            </xsl:when>
733            <xsl:when test="$nfcvalue!=57 and $nfcvalue &gt; 48 and $nfcvalue &lt; 60">
734                <xsl:attribute name="style:num-format">Native Numbering</xsl:attribute>
735            </xsl:when>
736            <xsl:otherwise>
737                <xsl:attribute name="style:num-format">1</xsl:attribute>
738            </xsl:otherwise>
739        </xsl:choose>
740        <xsl:choose>
741            <xsl:when test="$nfcvalue=26">
742                <xsl:attribute name="style:num-prefix"><xsl:value-of select="$prefix"/></xsl:attribute>
743                <xsl:attribute name="style:num-suffix"><xsl:value-of select="concat( '.' , $suffix )"/></xsl:attribute>
744            </xsl:when>
745            <xsl:when test="$nfcvalue=27 or $nfcvalue=29">
746                <xsl:attribute name="style:num-prefix"><xsl:value-of select="concat( $prefix, '(' )"/></xsl:attribute>
747                <xsl:attribute name="style:num-suffix"><xsl:value-of select="concat( ')' , $suffix )"/></xsl:attribute>
748            </xsl:when>
749            <xsl:when test="$nfcvalue=57">
750                <xsl:attribute name="style:num-prefix"><xsl:value-of select="concat( $prefix, '- ' )"/></xsl:attribute>
751                <xsl:attribute name="style:num-suffix"><xsl:value-of select="concat( ' -' , $suffix )"/></xsl:attribute>
752            </xsl:when>
753            <xsl:otherwise>
754                <xsl:attribute name="style:num-prefix"><xsl:value-of select="$prefix"/></xsl:attribute>
755                <xsl:attribute name="style:num-suffix"><xsl:value-of select="$suffix"/></xsl:attribute>
756            </xsl:otherwise>
757        </xsl:choose>
758    </xsl:template>
759<!-- End of OOo2.0 import/wordml/wordml2ooo_list.xsl stylesheet  -->
760<!-- Start of OOo2.0 import/wordml/wordml2ooo_page.xsl stylesheet  -->
761    <xsl:template match="w:sectPr" mode="page-master">
762        <style:page-master>
763            <xsl:attribute name="style:name">pm<xsl:number from="/w:wordDocument/w:body" level="any" count="w:sectPr"/></xsl:attribute>
764            <style:properties>
765                <xsl:attribute name="fo:page-width"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgSz/@w:w,'dxa')"/></xsl:call-template>cm</xsl:attribute>
766                <xsl:attribute name="fo:page-height"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgSz/@w:h,'dxa')"/></xsl:call-template>cm</xsl:attribute>
767                <xsl:choose>
768                    <xsl:when test="/w:wordDocument/w:docPr/w:gutterAtTop">
769                        <xsl:attribute name="fo:margin-top"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:top + w:pgMar/@w:gutter,'dxa')"/></xsl:call-template>cm</xsl:attribute>
770                        <xsl:attribute name="fo:margin-left"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:left,'dxa')"/></xsl:call-template>cm</xsl:attribute>
771                        <xsl:attribute name="fo:margin-right"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:right,'dxa')"/></xsl:call-template>cm</xsl:attribute>
772                    </xsl:when>
773                    <xsl:when test="w:rtlGutter">
774                        <xsl:attribute name="fo:margin-top"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:top,'dxa')"/></xsl:call-template>cm</xsl:attribute>
775                        <xsl:attribute name="fo:margin-left"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:left,'dxa')"/></xsl:call-template>cm</xsl:attribute>
776                        <xsl:attribute name="fo:margin-right"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:right + w:pgMar/@w:gutter,'dxa')"/></xsl:call-template>cm</xsl:attribute>
777                    </xsl:when>
778                    <xsl:otherwise>
779                        <xsl:attribute name="fo:margin-top"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:top,'dxa')"/></xsl:call-template>cm</xsl:attribute>
780                        <xsl:attribute name="fo:margin-left"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:left + w:pgMar/@w:gutter,'dxa')"/></xsl:call-template>cm</xsl:attribute>
781                        <xsl:attribute name="fo:margin-right"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:right,'dxa')"/></xsl:call-template>cm</xsl:attribute>
782                    </xsl:otherwise>
783                </xsl:choose>
784                <xsl:attribute name="fo:margin-bottom"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:bottom,'dxa')"/></xsl:call-template>cm</xsl:attribute>
785                <xsl:attribute name="style:footnote-max-height"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:footer,'dxa')"/></xsl:call-template></xsl:attribute>
786                <xsl:if test="w:pgSz/@w:orient">
787                    <xsl:attribute name="style:print-orientation"><xsl:value-of select="w:pgSz/@w:orient"/></xsl:attribute>
788                </xsl:if>
789                <xsl:if test="w:cols/@w:num">
790                    <!-- create sction property-->
791                    <style:columns>
792                        <xsl:attribute name="fo:column-count"><xsl:value-of select="w:cols/@w:num"/></xsl:attribute>
793                        <xsl:attribute name="fo:column-gap"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:cols/@w:space,'dxa')"/></xsl:call-template>cm</xsl:attribute>
794                    </style:columns>
795                </xsl:if>
796            </style:properties>
797        </style:page-master>
798    </xsl:template>
799    <xsl:template match="w:sectPr" mode="master-page">
800        <!-- style:page-master style:style-->
801        <style:master-page>
802            <xsl:variable name="master-page-name">
803                <xsl:number count="w:sectPr" from="/w:wordDocument/w:body" level="any"/>
804            </xsl:variable>
805            <xsl:attribute name="style:name">Standard<xsl:value-of select="$master-page-name"/></xsl:attribute>
806            <xsl:attribute name="style:page-master-name"><xsl:value-of select="concat('pm', $master-page-name)"/></xsl:attribute>
807            <!-- Headers and footers-->
808            <style:header-style>
809                <style:properties>
810                    <xsl:attribute name="fo:min-height"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:header,'dxa')"/></xsl:call-template>cm</xsl:attribute>
811                    <xsl:attribute name="fo:margin-bottom">0.792cm</xsl:attribute>
812                    <xsl:attribute name="style:dynamic-spacing">true</xsl:attribute>
813                </style:properties>
814            </style:header-style>
815            <style:footer-style>
816                <style:properties>
817                    <xsl:attribute name="fo:min-height"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pgMar/@w:footer,'dxa')"/></xsl:call-template>cm</xsl:attribute>
818                    <xsl:attribute name="fo:margin-top">0.792cm</xsl:attribute>
819                    <xsl:attribute name="style:dynamic-spacing">true</xsl:attribute>
820                </style:properties>
821            </style:footer-style>
822            <xsl:if test="not(w:titlePg)">
823                <xsl:apply-templates select="w:hdr[@w:type='odd']"/>
824                <xsl:apply-templates select="w:hdr[@w:type='even']"/>
825                <xsl:apply-templates select="w:ftr[@w:type='odd']"/>
826                <xsl:apply-templates select="w:ftr[@w:type='even']"/>
827            </xsl:if>
828        </style:master-page>
829    </xsl:template>
830    <xsl:template match="w:hdr">
831        <xsl:choose>
832            <xsl:when test="@w:type = 'odd'">
833                <style:header>
834                    <xsl:apply-templates/>
835                </style:header>
836            </xsl:when>
837            <xsl:when test="@w:type = 'even'">
838                <style:header-left>
839                    <xsl:apply-templates/>
840                </style:header-left>
841            </xsl:when>
842        </xsl:choose>
843    </xsl:template>
844    <xsl:template match="w:ftr">
845        <xsl:choose>
846            <xsl:when test="@w:type = 'odd'">
847                <style:footer>
848                    <xsl:apply-templates/>
849                </style:footer>
850            </xsl:when>
851            <xsl:when test="@w:type = 'even'">
852                <style:footer-left>
853                    <xsl:apply-templates/>
854                </style:footer-left>
855            </xsl:when>
856        </xsl:choose>
857    </xsl:template>
858<!-- End of OOo2.0 import/wordml/wordml2ooo_page.xsl stylesheet  -->
859<!-- Start of OOo2.0 import/wordml/wordml2ooo_settings.xsl stylesheet  -->
860    <xsl:template match="w:docPr">
861        <office:settings>
862            <config:config-item-set config:name="view-settings">
863                <config:config-item config:name="InBrowseMode" config:type="boolean">
864                    <xsl:choose>
865                        <xsl:when test="w:view/@w:val = 'outline'">true</xsl:when>
866                        <xsl:when test="w:view/@w:val = 'print'">false</xsl:when>
867                        <!-- others: web, reading, normal, master-pages, none. glu -->
868                        <xsl:otherwise>true</xsl:otherwise>
869                    </xsl:choose>
870                </config:config-item>
871                <config:config-item-map-indexed config:name="Views">
872                    <config:config-item-map-entry>
873                        <xsl:if test="w:zoom">
874                            <!-- VisibleRight and VisibleBottom are arbitrary positive numbers. ;) glu -->
875                            <config:config-item config:name="VisibleRight" config:type="int">1</config:config-item>
876                            <config:config-item config:name="VisibleBottom" config:type="int">1</config:config-item>
877                            <xsl:choose>
878                                <xsl:when test="w:zoom/@w:val = 'best-fit'">
879                                    <config:config-item config:name="ZoomType" config:type="short">3</config:config-item>
880                                </xsl:when>
881                                <xsl:when test="w:zoom/@w:val = 'full-page'">
882                                    <config:config-item config:name="ZoomType" config:type="short">2</config:config-item>
883                                </xsl:when>
884                                <xsl:when test="w:zoom/@w:val = 'text-fit'">
885                                    <config:config-item config:name="ZoomType" config:type="short">1</config:config-item>
886                                </xsl:when>
887                                <xsl:otherwise>
888                                    <config:config-item config:name="ZoomType" config:type="short">0</config:config-item>
889                                </xsl:otherwise>
890                            </xsl:choose>
891                            <config:config-item config:name="ZoomFactor" config:type="short">
892                                <xsl:value-of select="w:zoom/@w:percent"/>
893                            </config:config-item>
894                        </xsl:if>
895                    </config:config-item-map-entry>
896                </config:config-item-map-indexed>
897            </config:config-item-set>
898        </office:settings>
899    </xsl:template>
900<!-- End of OOo2.0 import/wordml/wordml2ooo_settings.xsl stylesheet  -->
901<!-- Start of OOo2.0 import/wordml/wordml2ooo_table.xsl stylesheet  -->
902    <xsl:template match="w:tblPr" mode="style">
903        <xsl:element name="style:style">
904            <xsl:attribute name="style:name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any"/></xsl:attribute>
905            <xsl:attribute name="style:family">table</xsl:attribute>
906            <xsl:if test="w:tblStyle">
907                <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:tblStyle/@w:val"/></xsl:attribute>
908            </xsl:if>
909            <xsl:element name="style:properties">
910                <xsl:choose>
911                    <xsl:when test="w:jc/@w:val = 'left' or w:jc/@w:val = 'center' or w:jc/@w:val = 'right'">
912                        <xsl:attribute name="table:align"><xsl:value-of select="w:jc/@w:val"/></xsl:attribute>
913                    </xsl:when>
914                    <xsl:otherwise>
915                        <xsl:attribute name="table:align">margins</xsl:attribute>
916                    </xsl:otherwise>
917                </xsl:choose>
918                <!-- adopt the width of table and column corresponding the width of page and margins. . -->
919                <xsl:variable name="sectPr" select="following::w:sectPr[1]"/>
920                <xsl:variable name="total-page-size" select="$sectPr/w:pgSz/@w:w"/>
921                <xsl:variable name="page-left-mar" select="$sectPr/w:pgMar/@w:left"/>
922                <xsl:variable name="page-right-mar" select="$sectPr/w:pgMar/@w:right"/>
923                <xsl:variable name="page-size-value" select="$total-page-size - $page-left-mar - $page-right-mar"/>
924                <xsl:variable name="page-size-inch">
925                    <xsl:call-template name="convert2in">
926                        <xsl:with-param name="value" select="concat($page-size-value, 'dxa') "/>
927                    </xsl:call-template>
928                </xsl:variable>
929                <xsl:variable name="gridcols" select="../w:tblGrid/w:gridCol"/>
930                <xsl:variable name="tblsize" select="sum($gridcols/@w:w)"/>
931                <xsl:variable name="table_indent">
932                    <xsl:choose>
933                        <xsl:when test="w:tblInd and  w:tblInd/@w:w &gt; 0 ">
934                            <xsl:call-template name="convert2in">
935                                <xsl:with-param name="value" select="concat(w:tblInd/@w:w, 'dxa') "/>
936                            </xsl:call-template>
937                        </xsl:when>
938                        <xsl:otherwise>
939                            <xsl:value-of select="number( '0') "/>
940                        </xsl:otherwise>
941                    </xsl:choose>
942                </xsl:variable>
943                <xsl:variable name="rel-tblsize">
944                    <xsl:choose>
945                        <xsl:when test="w:tblW/@w:type = 'pct'">
946                            <xsl:value-of select="(number(w:tblW/@w:w  ) div 5000) * $page-size-inch"/>
947                        </xsl:when>
948                        <xsl:otherwise>
949                            <xsl:call-template name="convert2in">
950                                <xsl:with-param name="value" select="concat($tblsize, 'dxa')"/>
951                            </xsl:call-template>
952                        </xsl:otherwise>
953                    </xsl:choose>
954                </xsl:variable>
955                <xsl:attribute name="style:width"><xsl:value-of select="concat($rel-tblsize, 'inch' )"/></xsl:attribute>
956                <xsl:variable name="tbl_margin_left">
957                    <xsl:choose>
958                        <xsl:when test="not(w:tblpPr ) ">
959                            <xsl:choose>
960                                <xsl:when test="w:bidiVisual">
961                                    <xsl:choose>
962                                        <xsl:when test=" number($page-size-inch - $table_indent - $rel-tblsize) &gt; 0">
963                                            <xsl:value-of select="$page-size-inch - $table_indent - $rel-tblsize"/>
964                                        </xsl:when>
965                                        <xsl:otherwise>
966                                            <xsl:text>0</xsl:text>
967                                        </xsl:otherwise>
968                                    </xsl:choose>
969                                </xsl:when>
970                                <xsl:otherwise>
971                                    <xsl:value-of select="$table_indent"/>
972                                </xsl:otherwise>
973                            </xsl:choose>
974                        </xsl:when>
975                        <xsl:when test="w:tblpPr">
976                            <!-- if the table is  put into a draw:text-box,  fo:margin-left and fo:margin-right should be 0 -->
977                            <xsl:text>0</xsl:text>
978                        </xsl:when>
979                    </xsl:choose>
980                </xsl:variable>
981                <xsl:variable name="tbl_margin_right">
982                    <xsl:choose>
983                        <xsl:when test="not(w:tblpPr ) ">
984                            <xsl:choose>
985                                <xsl:when test="w:bidiVisual">
986                                    <xsl:value-of select="$table_indent"/>
987                                </xsl:when>
988                                <xsl:otherwise>
989                                    <xsl:choose>
990                                        <xsl:when test=" number($page-size-inch - $table_indent - $rel-tblsize) &gt; 0">
991                                            <xsl:value-of select="$page-size-inch - $table_indent - $rel-tblsize"/>
992                                        </xsl:when>
993                                        <xsl:otherwise>
994                                            <xsl:text>0</xsl:text>
995                                        </xsl:otherwise>
996                                    </xsl:choose>
997                                </xsl:otherwise>
998                            </xsl:choose>
999                        </xsl:when>
1000                        <xsl:when test="w:tblpPr">
1001                            <!-- if the table is  put into a draw:text-box,  fo:margin-left and fo:margin-right should be 0 -->
1002                            <xsl:text>0</xsl:text>
1003                        </xsl:when>
1004                    </xsl:choose>
1005                </xsl:variable>
1006                <xsl:attribute name="fo:margin-left"><xsl:value-of select="concat( $tbl_margin_left, 'inch')"/></xsl:attribute>
1007                <xsl:attribute name="fo:margin-right"><xsl:value-of select="concat($tbl_margin_right, 'inch')"/></xsl:attribute>
1008                <!-- If previous w:p has a page break, the table must have the page break attribute applied to it	 May need this for tables starting on new pages -->
1009                <!--	<xsl:if test="parent::w:tbl/preceding-sibling::w:p[1][descendant::w:br/@w:type='page']">
1010							<xsl:attribute name="fo:break-before">page</xsl:attribute></xsl:if>	-->
1011                <!-- initial values for tables-->
1012            </xsl:element>
1013        </xsl:element>
1014        <!-- the following style is for conveting Word table text wrapping to SO Writer. Since SO Writer has no table text wrapping feature, so we use the draw:text-box as a container and put the table in draw:text-box -->
1015        <xsl:if test="w:tblpPr">
1016            <xsl:element name="style:style">
1017                <xsl:attribute name="style:name">TableFrame<xsl:number count="w:tblpPr" from="/w:wordDocument/w:body" level="any"/></xsl:attribute>
1018                <xsl:attribute name="style:family">graphics</xsl:attribute>
1019                <xsl:attribute name="style:parent-style-name"><xsl:value-of select=" 'Frame' "/></xsl:attribute>
1020                <xsl:element name="style:properties">
1021                    <xsl:if test="w:tblpPr/@w:leftFromText">
1022                        <xsl:variable name="left_margin_from_text">
1023                            <xsl:call-template name="convert2in">
1024                                <xsl:with-param name="value" select="concat (w:tblpPr/@w:leftFromText, 'dxa') "/>
1025                            </xsl:call-template>
1026                        </xsl:variable>
1027                        <xsl:attribute name="fo:margin-left"><xsl:value-of select="concat( $left_margin_from_text, 'inch') "/></xsl:attribute>
1028                    </xsl:if>
1029                    <xsl:if test="w:tblpPr/@w:rightFromText">
1030                        <xsl:variable name="right_margin_from_text">
1031                            <xsl:call-template name="convert2in">
1032                                <xsl:with-param name="value" select="concat (w:tblpPr/@w:rightFromText, 'dxa') "/>
1033                            </xsl:call-template>
1034                        </xsl:variable>
1035                        <xsl:attribute name="fo:margin-right"><xsl:value-of select="concat( $right_margin_from_text, 'inch') "/></xsl:attribute>
1036                    </xsl:if>
1037                    <xsl:if test="w:tblpPr/@w:topFromText">
1038                        <xsl:variable name="top_margin_from_text">
1039                            <xsl:call-template name="convert2in">
1040                                <xsl:with-param name="value" select="concat (w:tblpPr/@w:topFromText, 'dxa') "/>
1041                            </xsl:call-template>
1042                        </xsl:variable>
1043                        <xsl:attribute name="fo:margin-top"><xsl:value-of select="concat( $top_margin_from_text, 'inch') "/></xsl:attribute>
1044                    </xsl:if>
1045                    <xsl:if test="w:tblpPr/@w:bottomFromText">
1046                        <xsl:variable name="bottom_margin_from_text">
1047                            <xsl:call-template name="convert2in">
1048                                <xsl:with-param name="value" select="concat (w:tblpPr/@w:bottomFromText, 'dxa') "/>
1049                            </xsl:call-template>
1050                        </xsl:variable>
1051                        <xsl:attribute name="fo:margin-bottom"><xsl:value-of select="concat( $bottom_margin_from_text, 'inch') "/></xsl:attribute>
1052                    </xsl:if>
1053                    <xsl:attribute name="style:number-wrapped-paragraphs"><xsl:text>no-limit</xsl:text></xsl:attribute>
1054                    <!--xsl:if test="w:tblpPr/@w:tblpYSpec" to get the vertical alignment-->
1055                    <xsl:variable name="vertical_alignment">
1056                        <xsl:choose>
1057                            <xsl:when test="w:tblpPr/@w:tblpYSpec = 'top' ">
1058                                <xsl:text>top</xsl:text>
1059                            </xsl:when>
1060                            <xsl:when test="w:tblpPr/@w:tblpYSpec = 'center' ">
1061                                <xsl:text>middle</xsl:text>
1062                            </xsl:when>
1063                            <xsl:when test="w:tblpPr/@w:tblpYSpec= 'bottom' ">
1064                                <xsl:text>bottom</xsl:text>
1065                            </xsl:when>
1066                            <xsl:when test="w:tblpPr/@w:tblpYSpec = 'inside' ">
1067                                <xsl:text>from-top</xsl:text>
1068                            </xsl:when>
1069                            <xsl:when test="w:tblpPr/@w:tblpYSpec= 'outside' ">
1070                                <xsl:text>top</xsl:text>
1071                            </xsl:when>
1072                            <xsl:otherwise>
1073                                <xsl:text>from-top</xsl:text>
1074                            </xsl:otherwise>
1075                        </xsl:choose>
1076                    </xsl:variable>
1077                    <xsl:attribute name="style:vertical-pos"><xsl:value-of select="$vertical_alignment"/></xsl:attribute>
1078                    <!--/xsl:if-->
1079                    <!--xsl:if test="w:tblpPr/@w:vertAnchor" to get the vertical anchor related area type -->
1080                    <xsl:variable name="frame_v_anchor">
1081                        <xsl:choose>
1082                            <xsl:when test="w:tblpPr/@w:vertAnchor = 'text' ">
1083                                <xsl:value-of select=" 'paragraph' "/>
1084                            </xsl:when>
1085                            <xsl:when test="w:tblpPr/@w:vertAnchor = 'margin' ">
1086                                <xsl:value-of select=" 'paragraph-content' "/>
1087                            </xsl:when>
1088                            <xsl:when test="w:tblpPr/@w:vertAnchor = 'page' ">
1089                                <xsl:value-of select="w:tblpPr/@w:vertAnchor"/>
1090                            </xsl:when>
1091                            <xsl:otherwise>
1092                                <xsl:value-of select=" 'page-content' "/>
1093                            </xsl:otherwise>
1094                        </xsl:choose>
1095                    </xsl:variable>
1096                    <xsl:attribute name="style:vertical-rel"><xsl:value-of select="$frame_v_anchor"/></xsl:attribute>
1097                    <!--/xsl:if-->
1098                    <!--xsl:if test="w:tblpPr/@w:tblpXSpec" to get the horizntal alignment-->
1099                    <xsl:variable name="horizental_alignment">
1100                        <xsl:choose>
1101                            <xsl:when test="w:tblpPr/@w:tblpXSpec = 'left' ">
1102                                <xsl:text>left</xsl:text>
1103                            </xsl:when>
1104                            <xsl:when test="w:tblpPr/@w:tblpXSpec = 'center' ">
1105                                <xsl:text>center</xsl:text>
1106                            </xsl:when>
1107                            <xsl:when test="w:tblpPr/@w:tblpXSpec = 'right' ">
1108                                <xsl:text>right</xsl:text>
1109                            </xsl:when>
1110                            <xsl:when test="w:tblpPr/@w:tblpXSpec = 'inside' ">
1111                                <xsl:text>from-left</xsl:text>
1112                            </xsl:when>
1113                            <xsl:when test="w:tblpPr/@w:tblpXSpec = 'outside' ">
1114                                <xsl:text>outside</xsl:text>
1115                            </xsl:when>
1116                            <xsl:otherwise>
1117                                <xsl:text>left</xsl:text>
1118                            </xsl:otherwise>
1119                        </xsl:choose>
1120                    </xsl:variable>
1121                    <xsl:attribute name="style:horizontal-pos"><xsl:value-of select="$horizental_alignment"/></xsl:attribute>
1122                    <!--/xsl:if-->
1123                    <!--xsl:if test="w:tblpPr/@w:horzAnchor" to get the horizental anchor related area type-->
1124                    <xsl:variable name="frame_h_anchor">
1125                        <xsl:choose>
1126                            <xsl:when test="w:tblpPr/@w:horzAnchor = 'text' ">
1127                                <xsl:value-of select=" 'paragraph' "/>
1128                            </xsl:when>
1129                            <xsl:when test="w:tblpPr/@w:horzAnchor = 'margin' ">
1130                                <xsl:value-of select=" 'page-content' "/>
1131                            </xsl:when>
1132                            <xsl:when test="w:tblpPr/@w:horzAnchor = 'page' ">
1133                                <xsl:value-of select="w:tblpPr/@w:horzAnchor"/>
1134                            </xsl:when>
1135                            <xsl:when test="w:tblpPr/@w:horzAnchor= 'inside' ">
1136                                <xsl:value-of select=" 'paragraph-start-margin' "/>
1137                            </xsl:when>
1138                            <xsl:when test="w:tblpPr/@w:horzAnchor= 'outside' ">
1139                                <xsl:value-of select=" 'paragraph-end-margin' "/>
1140                            </xsl:when>
1141                            <xsl:otherwise>
1142                                <xsl:value-of select=" 'paragraph-content' "/>
1143                            </xsl:otherwise>
1144                        </xsl:choose>
1145                    </xsl:variable>
1146                    <xsl:attribute name="style:horizontal-rel"><xsl:value-of select="$frame_h_anchor"/></xsl:attribute>
1147                    <!--/xsl:if-->
1148                    <xsl:attribute name="fo:background-color"><xsl:text>#ffffff</xsl:text></xsl:attribute>
1149                    <xsl:attribute name="style:background-transparency"><xsl:text>100%</xsl:text></xsl:attribute>
1150                    <xsl:attribute name="style:wrap"><xsl:text>parallel</xsl:text></xsl:attribute>
1151                </xsl:element>
1152            </xsl:element>
1153        </xsl:if>
1154    </xsl:template>
1155    <xsl:template match="w:gridCol" mode="style">
1156        <xsl:element name="style:style">
1157            <xsl:attribute name="style:family">table-column</xsl:attribute>
1158            <xsl:attribute name="style:name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any"/>.C<xsl:number count="w:gridCol" from="/w:wordDocument/w:body" level="single"/></xsl:attribute>
1159            <xsl:element name="style:properties">
1160                <xsl:variable name="column_width">
1161                    <xsl:call-template name="convert2in">
1162                        <xsl:with-param name="value" select="concat(@w:w, 'dxa') "/>
1163                    </xsl:call-template>
1164                </xsl:variable>
1165                <xsl:attribute name="style:column-width"><xsl:value-of select="concat($column_width,'inch') "/></xsl:attribute>
1166            </xsl:element>
1167        </xsl:element>
1168    </xsl:template>
1169    <xsl:template match="w:trPr" mode="style">
1170        <!-- to generate style:style of table-row height.  -->
1171        <xsl:element name="style:style">
1172            <xsl:attribute name="style:family">table-row</xsl:attribute>
1173            <xsl:attribute name="style:name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any"/>.R<xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single"/></xsl:attribute>
1174            <xsl:element name="style:properties">
1175                <xsl:choose>
1176                    <xsl:when test="w:trHeight/@w:val">
1177                        <xsl:variable name="tbl_row_height">
1178                            <xsl:call-template name="convert2in">
1179                                <xsl:with-param name="value" select="concat(w:trHeight/@w:val, 'dxa') "/>
1180                            </xsl:call-template>
1181                        </xsl:variable>
1182                        <xsl:attribute name="style:row-height"><xsl:value-of select="concat($tbl_row_height, 'inch' )"/></xsl:attribute>
1183                    </xsl:when>
1184                </xsl:choose>
1185            </xsl:element>
1186        </xsl:element>
1187    </xsl:template>
1188    <xsl:template match="w:tcPr" mode="style">
1189        <style:style>
1190            <xsl:attribute name="style:name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any"/>.R<xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single"/>C<xsl:number count="w:tc" from="/w:wordDocument/w:body" level="single"/></xsl:attribute>
1191            <xsl:attribute name="style:family">table-cell</xsl:attribute>
1192            <xsl:variable name="rootStyle" select="ancestor::w:tbl/w:tblPr/w:tblStyle/@w:val"/>
1193            <xsl:variable name="rootStyleNode" select="/w:wordDocument/w:styles/w:style[@w:styleId = $rootStyle]"/>
1194            <xsl:element name="style:properties">
1195                <!-- cell background color start -->
1196                <xsl:variable name="tbl_cell_background_color">
1197                    <xsl:choose>
1198                        <xsl:when test="w:shd/@w:fill">
1199                            <xsl:value-of select="w:shd/@w:fill"/>
1200                        </xsl:when>
1201                        <xsl:when test="$rootStyleNode/w:tblpr/w:shd/@w:fill">
1202                            <xsl:value-of select="$rootStyleNode/w:tblpr/w:shd/@w:fill"/>
1203                        </xsl:when>
1204                    </xsl:choose>
1205                </xsl:variable>
1206                <xsl:attribute name="fo:background-color"><xsl:value-of select="concat('#',$tbl_cell_background_color)"/></xsl:attribute>
1207                <!--cell background color end -->
1208                <!-- table cell vertical alignment start -->
1209                <xsl:if test="w:vAlign">
1210                    <xsl:variable name="tbl_cell_alignment">
1211                        <xsl:choose>
1212                            <xsl:when test="w:vAlign/@w:val = 'top' ">
1213                                <xsl:text>top</xsl:text>
1214                            </xsl:when>
1215                            <xsl:when test="w:vAlign/@w:val = 'center' ">
1216                                <xsl:text>middle</xsl:text>
1217                            </xsl:when>
1218                            <xsl:when test="w:vAlign/@w:val = 'bottom' ">
1219                                <xsl:text>bottom</xsl:text>
1220                            </xsl:when>
1221                            <xsl:otherwise>
1222                                <xsl:text>automatic</xsl:text>
1223                            </xsl:otherwise>
1224                        </xsl:choose>
1225                    </xsl:variable>
1226                    <xsl:attribute name="fo:vertical-align"><xsl:value-of select="$tbl_cell_alignment"/></xsl:attribute>
1227                </xsl:if>
1228                <!--table cell alignment end -->
1229                <!-- cell margin start -->
1230                <xsl:variable name="tblcell_leftmargin">
1231                    <xsl:choose>
1232                        <xsl:when test="w:tcMar/w:left">
1233                            <xsl:call-template name="convert2in">
1234                                <xsl:with-param name="value" select="concat(w:tcMar/w:left/@w:w , w:tcMar/w:left/@w:type) "/>
1235                            </xsl:call-template>
1236                        </xsl:when>
1237                        <xsl:when test="$rootStyleNode/w:tblPr/w:tblCellMar/w:left">
1238                            <xsl:call-template name="convert2in">
1239                                <xsl:with-param name="value" select="concat($rootStyleNode/w:tblPr/w:tblCellMar/w:left/@w:w , $rootStyleNode/w:tblPr/w:tblCellMar/w:left/@w:type)"/>
1240                            </xsl:call-template>
1241                        </xsl:when>
1242                        <xsl:otherwise>
1243                            <xsl:text>0</xsl:text>
1244                        </xsl:otherwise>
1245                    </xsl:choose>
1246                </xsl:variable>
1247                <xsl:variable name="tblcell_rightmargin">
1248                    <xsl:choose>
1249                        <xsl:when test="w:tcMar/w:right">
1250                            <xsl:call-template name="convert2in">
1251                                <xsl:with-param name="value" select="concat(w:tcMar/w:right/@w:w , w:tcMar/w:right/@w:type) "/>
1252                            </xsl:call-template>
1253                        </xsl:when>
1254                        <xsl:when test="$rootStyleNode/w:tblPr/w:tblCellMar/w:right">
1255                            <xsl:call-template name="convert2in">
1256                                <xsl:with-param name="value" select="concat($rootStyleNode/w:tblPr/w:tblCellMar/w:right/@w:w , $rootStyleNode/w:tblPr/w:tblCellMar/w:right/@w:type)"/>
1257                            </xsl:call-template>
1258                        </xsl:when>
1259                        <xsl:otherwise>
1260                            <xsl:text>0</xsl:text>
1261                        </xsl:otherwise>
1262                    </xsl:choose>
1263                </xsl:variable>
1264                <xsl:variable name="tblcell_topmargin">
1265                    <xsl:choose>
1266                        <xsl:when test="w:tcMar/w:top">
1267                            <xsl:call-template name="convert2in">
1268                                <xsl:with-param name="value" select="concat(w:tcMar/w:top/@w:w , w:tcMar/w:top/@w:type) "/>
1269                            </xsl:call-template>
1270                        </xsl:when>
1271                        <xsl:when test="$rootStyleNode/w:tblPr/w:tblCellMar/w:top">
1272                            <xsl:call-template name="convert2in">
1273                                <xsl:with-param name="value" select="concat($rootStyleNode/w:tblPr/w:tblCellMar/w:top/@w:w , $rootStyleNode/w:tblPr/w:tblCellMar/w:top/@w:type)"/>
1274                            </xsl:call-template>
1275                        </xsl:when>
1276                        <xsl:otherwise>
1277                            <xsl:text>0</xsl:text>
1278                        </xsl:otherwise>
1279                    </xsl:choose>
1280                </xsl:variable>
1281                <xsl:variable name="tblcell_bottommargin">
1282                    <xsl:choose>
1283                        <xsl:when test="w:tcMar/w:bottom">
1284                            <xsl:call-template name="convert2in">
1285                                <xsl:with-param name="value" select="concat(w:tcMar/w:bottom/@w:w , w:tcMar/w:bottom/@w:type) "/>
1286                            </xsl:call-template>
1287                        </xsl:when>
1288                        <xsl:when test="$rootStyleNode/w:tblPr/w:tblCellMar/w:bottom">
1289                            <xsl:call-template name="convert2in">
1290                                <xsl:with-param name="value" select="concat($rootStyleNode/w:tblPr/w:tblCellMar/w:bottom/@w:w , $rootStyleNode/w:tblPr/w:tblCellMar/w:bottom/@w:type)"/>
1291                            </xsl:call-template>
1292                        </xsl:when>
1293                        <xsl:otherwise>
1294                            <xsl:text>0</xsl:text>
1295                        </xsl:otherwise>
1296                    </xsl:choose>
1297                </xsl:variable>
1298                <xsl:attribute name="fo:padding-left"><xsl:value-of select="concat($tblcell_leftmargin, 'inch' )"/></xsl:attribute>
1299                <xsl:attribute name="fo:padding-right"><xsl:value-of select="concat($tblcell_rightmargin, 'inch' )"/></xsl:attribute>
1300                <xsl:attribute name="fo:padding-top"><xsl:value-of select="concat($tblcell_topmargin, 'inch' )"/></xsl:attribute>
1301                <xsl:attribute name="fo:padding-bottom"><xsl:value-of select="concat($tblcell_bottommargin, 'inch' )"/></xsl:attribute>
1302                <!-- cell margin end -->
1303                <xsl:variable name="row-position">
1304                    <xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single"/>
1305                </xsl:variable>
1306                <!-- cell borders should be carefully converted. a little complex. glu :( -->
1307                <xsl:variable name="Borders" select="ancestor::w:tbl/w:tblPr/w:tblBorders"/>
1308                <xsl:choose>
1309                    <xsl:when test="$row-position &gt; 1">
1310                        <xsl:call-template name="get-table-border">
1311                            <xsl:with-param name="style-pos" select="'top'"/>
1312                            <xsl:with-param name="style-position-0" select="w:tcBorders/w:top"/>
1313                            <xsl:with-param name="style-position-1" select="$Borders/w:insideH"/>
1314                            <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:insideH"/>
1315                        </xsl:call-template>
1316                    </xsl:when>
1317                    <xsl:otherwise>
1318                        <xsl:call-template name="get-table-border">
1319                            <xsl:with-param name="style-pos" select="'top'"/>
1320                            <xsl:with-param name="style-position-0" select="w:tcBorders/w:top"/>
1321                            <xsl:with-param name="style-position-1" select="$Borders/w:top"/>
1322                            <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:top"/>
1323                        </xsl:call-template>
1324                    </xsl:otherwise>
1325                </xsl:choose>
1326                <xsl:choose>
1327                    <xsl:when test="count(ancestor::w:tr/following-sibling::w:tr) &gt; 0">
1328                        <xsl:call-template name="get-table-border">
1329                            <xsl:with-param name="style-pos" select="'bottom'"/>
1330                            <xsl:with-param name="style-position-0" select="w:tcBorders/w:bottom"/>
1331                            <xsl:with-param name="style-position-1" select="$Borders/w:insideH"/>
1332                            <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:insideH"/>
1333                        </xsl:call-template>
1334                    </xsl:when>
1335                    <xsl:otherwise>
1336                        <xsl:call-template name="get-table-border">
1337                            <xsl:with-param name="style-pos" select="'bottom'"/>
1338                            <xsl:with-param name="style-position-0" select="w:tcBorders/w:bottom"/>
1339                            <xsl:with-param name="style-position-1" select="$Borders/w:bottom"/>
1340                            <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:bottom"/>
1341                        </xsl:call-template>
1342                    </xsl:otherwise>
1343                </xsl:choose>
1344                <xsl:choose>
1345                    <xsl:when test="count(ancestor::w:tc/preceding-sibling::w:tc) &gt; 0">
1346                        <xsl:call-template name="get-table-border">
1347                            <xsl:with-param name="style-pos" select="'left'"/>
1348                            <xsl:with-param name="style-position-0" select="w:tcBorders/w:left"/>
1349                            <xsl:with-param name="style-position-1" select="$Borders/w:insideV"/>
1350                            <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:insideV"/>
1351                        </xsl:call-template>
1352                    </xsl:when>
1353                    <xsl:otherwise>
1354                        <xsl:call-template name="get-table-border">
1355                            <xsl:with-param name="style-pos" select="'left'"/>
1356                            <xsl:with-param name="style-position-0" select="w:tcBorders/w:left"/>
1357                            <xsl:with-param name="style-position-1" select="$Borders/w:left"/>
1358                            <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:left"/>
1359                        </xsl:call-template>
1360                    </xsl:otherwise>
1361                </xsl:choose>
1362                <xsl:choose>
1363                    <xsl:when test="count(ancestor::w:tc/following-sibling::w:tc) &gt; 0">
1364                        <xsl:call-template name="get-table-border">
1365                            <xsl:with-param name="style-pos" select="'right'"/>
1366                            <xsl:with-param name="style-position-0" select="w:tcBorders/w:right"/>
1367                            <xsl:with-param name="style-position-1" select="$Borders/w:insideV"/>
1368                            <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:insideV"/>
1369                        </xsl:call-template>
1370                    </xsl:when>
1371                    <xsl:otherwise>
1372                        <xsl:call-template name="get-table-border">
1373                            <xsl:with-param name="style-pos" select="'right'"/>
1374                            <xsl:with-param name="style-position-0" select="w:tcBorders/w:right"/>
1375                            <xsl:with-param name="style-position-1" select="$Borders/w:right"/>
1376                            <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:right"/>
1377                        </xsl:call-template>
1378                    </xsl:otherwise>
1379                </xsl:choose>
1380            </xsl:element>
1381        </style:style>
1382    </xsl:template>
1383    <xsl:template name="get-table-border">
1384        <xsl:param name="style-pos"/>
1385        <xsl:param name="style-position-0"/>
1386        <xsl:param name="style-position-1"/>
1387        <xsl:param name="style-position-2"/>
1388        <xsl:variable name="size-style">
1389            <xsl:choose>
1390                <xsl:when test="$style-position-0">
1391                    <xsl:value-of select="$style-position-0/@w:sz"/>
1392                </xsl:when>
1393                <xsl:when test="$style-position-1">
1394                    <xsl:value-of select="$style-position-1/@w:sz"/>
1395                </xsl:when>
1396                <xsl:when test="$style-position-2">
1397                    <xsl:value-of select="$style-position-2/@w:sz"/>
1398                </xsl:when>
1399                <xsl:otherwise>2</xsl:otherwise>
1400            </xsl:choose>
1401        </xsl:variable>
1402        <xsl:variable name="border-style">
1403            <xsl:choose>
1404                <xsl:when test="$style-position-0">
1405                    <xsl:value-of select="$style-position-0/@w:val"/>
1406                </xsl:when>
1407                <xsl:when test="$style-position-1">
1408                    <xsl:value-of select="$style-position-1/@w:val"/>
1409                </xsl:when>
1410                <xsl:when test="$style-position-2">
1411                    <xsl:value-of select="$style-position-2/@w:val"/>
1412                </xsl:when>
1413                <xsl:otherwise>single</xsl:otherwise>
1414            </xsl:choose>
1415        </xsl:variable>
1416        <!-- totally basic Word table border styles: nil, none, single, thick, double, dotted, dashed, dot-dash, dot-dot-dash, triple, thin-thick-small-gap, thick-thin-small-gap, thin-thick-thin-small-gap, thin-thick-medium-gap, thick-thin-medium-gap, thin-thick-thin-medium-gap, thin-thick-large-gap, thick-thin-large-gap, thin-thick-thin-large-gap, wave, double-wave, dash-small-gap, dash-dot-stroked, three-d-emboss, three-d-engrave, outset, inset. Others are advanced graphical table border styles. glu -->
1417        <xsl:variable name="style-border">
1418            <xsl:choose>
1419                <xsl:when test="$border-style = 'nil' or $border-style ='none'">hidden</xsl:when>
1420                <xsl:when test="$border-style = 'single' or $border-style = 'thick' or $border-style = 'dotted' or $border-style = 'dashed' or $border-style = 'dot-dash' or $border-style = 'dot-dot-dash' or $border-style = 'wave' or $border-style = 'dash-small-gap' or $border-style = 'dash-dot-stroked'">solid</xsl:when>
1421                <xsl:otherwise>double</xsl:otherwise>
1422            </xsl:choose>
1423        </xsl:variable>
1424        <xsl:variable name="color-border">
1425            <xsl:choose>
1426                <xsl:when test="$style-position-0 and string-length($style-position-0/@w:color) = 6">
1427                    <xsl:value-of select="$style-position-0/@w:color"/>
1428                </xsl:when>
1429                <xsl:when test="$style-position-0 and $style-position-0/@w:color = 'auto' and contains($border-style, 'set')">
1430                    <xsl:text>c0c0c0</xsl:text>
1431                </xsl:when>
1432                <xsl:when test="$style-position-1 and string-length($style-position-1/@w:color) = 6">
1433                    <xsl:value-of select="$style-position-1/@w:color"/>
1434                </xsl:when>
1435                <xsl:when test="$style-position-1 and $style-position-1/@w:color = 'auto' and contains($border-style, 'set')">
1436                    <xsl:text>c0c0c0</xsl:text>
1437                </xsl:when>
1438                <xsl:when test="$style-position-2 and string-length($style-position-2/@w:color) = 6">
1439                    <xsl:value-of select="$style-position-2/@w:color"/>
1440                </xsl:when>
1441                <xsl:when test="$style-position-2 and $style-position-2/@w:color = 'auto' and contains($border-style, 'set')">
1442                    <xsl:text>c0c0c0</xsl:text>
1443                </xsl:when>
1444                <xsl:otherwise>000000</xsl:otherwise>
1445            </xsl:choose>
1446        </xsl:variable>
1447        <!-- mapping border line widths. glu -->
1448        <xsl:choose>
1449            <xsl:when test="$border-style = 'single'">
1450                <xsl:choose>
1451                    <xsl:when test="$size-style &lt; 7">
1452                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.002cm solid #', $color-border)"/></xsl:attribute>
1453                    </xsl:when>
1454                    <xsl:when test="$size-style &lt; 20">
1455                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.035cm solid #', $color-border)"/></xsl:attribute>
1456                    </xsl:when>
1457                    <xsl:when test="$size-style &lt; 30">
1458                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.088cm solid #', $color-border)"/></xsl:attribute>
1459                    </xsl:when>
1460                    <xsl:when test="$size-style &lt; 40">
1461                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.141cm solid #', $color-border)"/></xsl:attribute>
1462                    </xsl:when>
1463                    <xsl:otherwise>
1464                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.176cm solid #', $color-border)"/></xsl:attribute>
1465                    </xsl:otherwise>
1466                </xsl:choose>
1467            </xsl:when>
1468            <xsl:when test="$border-style = 'double'">
1469                <xsl:choose>
1470                    <xsl:when test="$size-style &lt; 10">
1471                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.039cm double #', $color-border)"/></xsl:attribute>
1472                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.035cm 0.002cm</xsl:attribute>
1473                    </xsl:when>
1474                    <xsl:when test="$size-style &lt; 15">
1475                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.092cm double #', $color-border)"/></xsl:attribute>
1476                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
1477                    </xsl:when>
1478                    <xsl:when test="$size-style &lt; 20">
1479                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.106cm double #', $color-border)"/></xsl:attribute>
1480                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
1481                    </xsl:when>
1482                    <xsl:otherwise>
1483                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.265cm double #', $color-border)"/></xsl:attribute>
1484                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.088cm</xsl:attribute>
1485                    </xsl:otherwise>
1486                </xsl:choose>
1487            </xsl:when>
1488            <xsl:when test="$border-style = 'triple'">
1489                <xsl:choose>
1490                    <xsl:when test="$size-style &lt; 5">
1491                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.039cm double #', $color-border)"/></xsl:attribute>
1492                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.035cm 0.002cm</xsl:attribute>
1493                    </xsl:when>
1494                    <xsl:when test="$size-style &lt; 10">
1495                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.092cm double #', $color-border)"/></xsl:attribute>
1496                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">.002cm 0.088cm 0.002cm</xsl:attribute>
1497                    </xsl:when>
1498                    <xsl:when test="$size-style &lt; 15">
1499                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.106cm double #', $color-border)"/></xsl:attribute>
1500                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
1501                    </xsl:when>
1502                    <xsl:otherwise>
1503                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.265cm double #', $color-border)"/></xsl:attribute>
1504                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.088cm</xsl:attribute>
1505                    </xsl:otherwise>
1506                </xsl:choose>
1507            </xsl:when>
1508            <xsl:when test="$border-style = 'thin-thick-small-gap' or $border-style = 'thick-thin-small-gap'">
1509                <xsl:choose>
1510                    <xsl:when test="($border-style = 'thin-thick-small-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-small-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1511                        <xsl:choose>
1512                            <xsl:when test="$size-style &lt; 20">
1513                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.125cm double #', $color-border)"/></xsl:attribute>
1514                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
1515                            </xsl:when>
1516                            <xsl:when test="$size-style &lt; 30">
1517                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.178cm double #', $color-border)"/></xsl:attribute>
1518                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
1519                            </xsl:when>
1520                            <xsl:otherwise>
1521                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.231cm double #', $color-border)"/></xsl:attribute>
1522                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
1523                            </xsl:otherwise>
1524                        </xsl:choose>
1525                    </xsl:when>
1526                    <xsl:otherwise>
1527                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.159cm double #', $color-border)"/></xsl:attribute>
1528                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
1529                    </xsl:otherwise>
1530                </xsl:choose>
1531            </xsl:when>
1532            <xsl:when test="$border-style = 'thin-thick-thin-small-gap'">
1533                <xsl:choose>
1534                    <xsl:when test="$size-style &lt; 20">
1535                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.178cm double #', $color-border)"/></xsl:attribute>
1536                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
1537                    </xsl:when>
1538                    <xsl:when test="$size-style &lt; 40">
1539                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.231cm double #', $color-border)"/></xsl:attribute>
1540                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
1541                    </xsl:when>
1542                    <xsl:otherwise>
1543                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.318cm double #', $color-border)"/></xsl:attribute>
1544                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
1545                    </xsl:otherwise>
1546                </xsl:choose>
1547            </xsl:when>
1548            <xsl:when test="$border-style = 'thin-thick-medium-gap' or $border-style = 'thick-thin-medium-gap'">
1549                <xsl:choose>
1550                    <xsl:when test="$size-style &lt; 10">
1551                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.039cm double #', $color-border)"/></xsl:attribute>
1552                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.035cm 0.002cm</xsl:attribute>
1553                    </xsl:when>
1554                    <xsl:when test="$size-style &lt; 15">
1555                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.106cm double #', $color-border)"/></xsl:attribute>
1556                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
1557                    </xsl:when>
1558                    <xsl:when test="$size-style &lt; 30">
1559                        <xsl:choose>
1560                            <xsl:when test="($border-style = 'thin-thick-medium-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-medium-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1561                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.212cm double #', $color-border)"/></xsl:attribute>
1562                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.088cm 0.088cm</xsl:attribute>
1563                            </xsl:when>
1564                            <xsl:otherwise>
1565                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.159cm double #', $color-border)"/></xsl:attribute>
1566                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
1567                            </xsl:otherwise>
1568                        </xsl:choose>
1569                    </xsl:when>
1570                    <xsl:otherwise>
1571                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.318cm double #', $color-border)"/></xsl:attribute>
1572                        <xsl:choose>
1573                            <xsl:when test="($border-style = 'thin-thick-medium-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-medium-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1574                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
1575                            </xsl:when>
1576                            <xsl:otherwise>
1577                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.141cm 0.088cm 0.088cm</xsl:attribute>
1578                            </xsl:otherwise>
1579                        </xsl:choose>
1580                    </xsl:otherwise>
1581                </xsl:choose>
1582            </xsl:when>
1583            <xsl:when test="$border-style = 'thin-thick-thin-medium-gap'">
1584                <xsl:choose>
1585                    <xsl:when test="$size-style &lt; 10">
1586                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.039cm double #', $color-border)"/></xsl:attribute>
1587                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.035cm 0.002cm</xsl:attribute>
1588                    </xsl:when>
1589                    <xsl:when test="$size-style &lt; 15">
1590                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.106cm double #', $color-border)"/></xsl:attribute>
1591                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
1592                    </xsl:when>
1593                    <xsl:when test="$size-style &lt; 30">
1594                        <xsl:choose>
1595                            <xsl:when test="$style-pos = 'left' or $style-pos = 'top'">
1596                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.159cm double #', $color-border)"/></xsl:attribute>
1597                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
1598                            </xsl:when>
1599                            <xsl:otherwise>
1600                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.212cm double #', $color-border)"/></xsl:attribute>
1601                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.088cm 0.088cm</xsl:attribute>
1602                            </xsl:otherwise>
1603                        </xsl:choose>
1604                    </xsl:when>
1605                    <xsl:otherwise>
1606                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.318cm double #', $color-border)"/></xsl:attribute>
1607                        <xsl:choose>
1608                            <xsl:when test="$style-pos = 'left' or $style-pos = 'top'">
1609                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.141cm 0.088cm 0.088cm</xsl:attribute>
1610                            </xsl:when>
1611                            <xsl:otherwise>
1612                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
1613                            </xsl:otherwise>
1614                        </xsl:choose>
1615                    </xsl:otherwise>
1616                </xsl:choose>
1617            </xsl:when>
1618            <xsl:when test="$border-style = 'thin-thick-large-gap' or $border-style = 'thick-thin-large-gap'">
1619                <xsl:choose>
1620                    <xsl:when test="$size-style &lt; 7">
1621                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.092cm double #', $color-border)"/></xsl:attribute>
1622                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
1623                    </xsl:when>
1624                    <xsl:when test="$size-style &lt; 10">
1625                        <xsl:choose>
1626                            <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1627                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.125cm double #', $color-border)"/></xsl:attribute>
1628                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
1629                            </xsl:when>
1630                            <xsl:otherwise>
1631                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.092cm double #', $color-border)"/></xsl:attribute>
1632                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
1633                            </xsl:otherwise>
1634                        </xsl:choose>
1635                    </xsl:when>
1636                    <xsl:when test="$size-style &lt; 15">
1637                        <xsl:choose>
1638                            <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1639                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.125cm double #', $color-border)"/></xsl:attribute>
1640                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
1641                            </xsl:when>
1642                            <xsl:otherwise>
1643                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.159cm double #', $color-border)"/></xsl:attribute>
1644                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
1645                            </xsl:otherwise>
1646                        </xsl:choose>
1647                    </xsl:when>
1648                    <xsl:when test="$size-style &lt; 30">
1649                        <xsl:choose>
1650                            <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1651                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.178cm double #', $color-border)"/></xsl:attribute>
1652                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
1653                            </xsl:when>
1654                            <xsl:otherwise>
1655                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.159cm double #', $color-border)"/></xsl:attribute>
1656                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
1657                            </xsl:otherwise>
1658                        </xsl:choose>
1659                    </xsl:when>
1660                    <xsl:when test="$size-style &lt; 40">
1661                        <xsl:choose>
1662                            <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1663                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.231cm double #', $color-border)"/></xsl:attribute>
1664                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
1665                            </xsl:when>
1666                            <xsl:otherwise>
1667                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.159cm double #', $color-border)"/></xsl:attribute>
1668                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
1669                            </xsl:otherwise>
1670                        </xsl:choose>
1671                    </xsl:when>
1672                    <xsl:otherwise>
1673                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.318cm double #', $color-border)"/></xsl:attribute>
1674                        <xsl:choose>
1675                            <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1676                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
1677                            </xsl:when>
1678                            <xsl:otherwise>
1679                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.141cm 0.088cm 0.088cm</xsl:attribute>
1680                            </xsl:otherwise>
1681                        </xsl:choose>
1682                    </xsl:otherwise>
1683                </xsl:choose>
1684            </xsl:when>
1685            <xsl:when test="$border-style = 'thin-thick-thin-large-gap'">
1686                <xsl:choose>
1687                    <xsl:when test="$size-style &lt; 5">
1688                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.125cm double #', $color-border)"/></xsl:attribute>
1689                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
1690                    </xsl:when>
1691                    <xsl:when test="$size-style &lt; 10">
1692                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.178cm double #', $color-border)"/></xsl:attribute>
1693                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
1694                    </xsl:when>
1695                    <xsl:when test="$size-style &lt; 20">
1696                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.231cm double #', $color-border)"/></xsl:attribute>
1697                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
1698                    </xsl:when>
1699                    <xsl:otherwise>
1700                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.318cm double #', $color-border)"/></xsl:attribute>
1701                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
1702                    </xsl:otherwise>
1703                </xsl:choose>
1704            </xsl:when>
1705            <xsl:when test="contains( $border-style, 'wave') or $border-style = 'dash-dot-stroked'">
1706                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.106cm double #', $color-border)"/></xsl:attribute>
1707                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
1708            </xsl:when>
1709            <xsl:when test="contains( $border-style, 'three-d')">
1710                <xsl:choose>
1711                    <xsl:when test="$size-style &lt; 10">
1712                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.035cm solid #', $color-border)"/></xsl:attribute>
1713                    </xsl:when>
1714                    <xsl:when test="$size-style &lt; 20">
1715                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.088cm solid #', $color-border)"/></xsl:attribute>
1716                    </xsl:when>
1717                    <xsl:when test="$size-style &lt; 30">
1718                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.176cm solid #', $color-border)"/></xsl:attribute>
1719                    </xsl:when>
1720                    <xsl:when test="$size-style &lt; 40">
1721                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.265cm double #', $color-border)"/></xsl:attribute>
1722                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.088cm</xsl:attribute>
1723                    </xsl:when>
1724                    <xsl:otherwise>
1725                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.318cm double #', $color-border)"/></xsl:attribute>
1726                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
1727                    </xsl:otherwise>
1728                </xsl:choose>
1729            </xsl:when>
1730            <xsl:when test="contains( $border-style, 'set')">
1731                <xsl:choose>
1732                    <xsl:when test="$size-style &lt; 7">
1733                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.092cm double #', $color-border)"/></xsl:attribute>
1734                        <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
1735                    </xsl:when>
1736                    <xsl:when test="$size-style &lt; 10">
1737                        <xsl:choose>
1738                            <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1739                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.092cm double #', $color-border)"/></xsl:attribute>
1740                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
1741                            </xsl:when>
1742                            <xsl:otherwise>
1743                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.125cm double #', $color-border)"/></xsl:attribute>
1744                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
1745                            </xsl:otherwise>
1746                        </xsl:choose>
1747                    </xsl:when>
1748                    <xsl:when test="$size-style &lt; 15">
1749                        <xsl:choose>
1750                            <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1751                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.159cm double #', $color-border)"/></xsl:attribute>
1752                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
1753                            </xsl:when>
1754                            <xsl:otherwise>
1755                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.125cm double #', $color-border)"/></xsl:attribute>
1756                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
1757                            </xsl:otherwise>
1758                        </xsl:choose>
1759                    </xsl:when>
1760                    <xsl:when test="$size-style &lt; 30">
1761                        <xsl:choose>
1762                            <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1763                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.159cm double #', $color-border)"/></xsl:attribute>
1764                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
1765                            </xsl:when>
1766                            <xsl:otherwise>
1767                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.178cm double #', $color-border)"/></xsl:attribute>
1768                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
1769                            </xsl:otherwise>
1770                        </xsl:choose>
1771                    </xsl:when>
1772                    <xsl:when test="$size-style &lt; 40">
1773                        <xsl:choose>
1774                            <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1775                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.159cm double #', $color-border)"/></xsl:attribute>
1776                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
1777                            </xsl:when>
1778                            <xsl:otherwise>
1779                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.231cm double #', $color-border)"/></xsl:attribute>
1780                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
1781                            </xsl:otherwise>
1782                        </xsl:choose>
1783                    </xsl:when>
1784                    <xsl:otherwise>
1785                        <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.318cm double #', $color-border)"/></xsl:attribute>
1786                        <xsl:choose>
1787                            <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
1788                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.141cm 0.088cm 0.088cm</xsl:attribute>
1789                            </xsl:when>
1790                            <xsl:otherwise>
1791                                <xsl:attribute name="{concat('fo:border-', $style-pos)}"><xsl:value-of select="concat('0.231cm double #', $color-border)"/></xsl:attribute>
1792                                <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
1793                            </xsl:otherwise>
1794                        </xsl:choose>
1795                    </xsl:otherwise>
1796                </xsl:choose>
1797            </xsl:when>
1798            <xsl:otherwise>
1799                <xsl:attribute name="{concat('fo:border-', $style-pos)}">0.002cm solid #000000</xsl:attribute>
1800            </xsl:otherwise>
1801        </xsl:choose>
1802    </xsl:template>
1803    <xsl:template match="w:tbl">
1804        <xsl:choose>
1805            <xsl:when test="w:tblPr/w:tblpPr">
1806                <!-- if the table is surrounded by text then put the table into a draw:text-box -->
1807                <xsl:element name="text:p">
1808                    <xsl:element name="draw:text-box">
1809                        <xsl:attribute name="draw:style-name"><xsl:text>TableFrame</xsl:text><xsl:number count="w:tblpPr" from="/w:wordDocument/w:body" level="any"/></xsl:attribute>
1810                        <xsl:attribute name="draw:name">TableFr<xsl:number count="w:tblpPr" from="/w:wordDocument/w:body" level="any"/></xsl:attribute>
1811                        <xsl:variable name="tbl_anchor_type">
1812                            <xsl:choose>
1813                                <xsl:when test="name(..) = 'w:tc' ">
1814                                    <xsl:text>as-char</xsl:text>
1815                                </xsl:when>
1816                                <xsl:otherwise>
1817                                    <xsl:text>paragraph</xsl:text>
1818                                </xsl:otherwise>
1819                            </xsl:choose>
1820                        </xsl:variable>
1821                        <xsl:attribute name="text:anchor-type"><xsl:value-of select="$tbl_anchor_type"/></xsl:attribute>
1822                        <xsl:variable name="tbl_draw_textbox_width">
1823                            <xsl:call-template name="convert2in">
1824                                <!--  adjust the width of draw:text-box containing a table with 20dxa + table-width -->
1825                                <xsl:with-param name="value" select="concat(string(number(sum(w:tblGrid/w:gridCol/@w:w) +20)), 'dxa' )"/>
1826                            </xsl:call-template>
1827                        </xsl:variable>
1828                        <xsl:attribute name="svg:width"><xsl:value-of select="concat ($tbl_draw_textbox_width, 'inch') "/></xsl:attribute>
1829                        <xsl:if test="w:tblPr/w:tblpPr/@w:tblpX">
1830                            <xsl:variable name="x_distance_from_anchor">
1831                                <xsl:call-template name="convert2in">
1832                                    <xsl:with-param name="value" select="concat(w:tblPr/w:tblpPr/@w:tblpX, 'dxa' ) "/>
1833                                </xsl:call-template>
1834                            </xsl:variable>
1835                            <xsl:attribute name="svg:x"><xsl:value-of select="concat ($x_distance_from_anchor, 'inch' )"/></xsl:attribute>
1836                        </xsl:if>
1837                        <xsl:if test="w:tblPr/w:tblpPr/@w:tblpY">
1838                            <xsl:variable name="y_distance_from_anchor">
1839                                <xsl:call-template name="convert2in">
1840                                    <xsl:with-param name="value" select="concat(w:tblPr/w:tblpPr/@w:tblpY, 'dxa' ) "/>
1841                                </xsl:call-template>
1842                            </xsl:variable>
1843                            <xsl:attribute name="svg:y"><xsl:value-of select="concat ($y_distance_from_anchor, 'inch' )"/></xsl:attribute>
1844                        </xsl:if>
1845                        <!--create table in draw:text-box to produce table wrapping text effect-->
1846                        <xsl:element name="table:table">
1847                            <xsl:if test="w:tblPr">
1848                                <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any"/></xsl:attribute>
1849                            </xsl:if>
1850                            <xsl:apply-templates select="w:tblGrid | w:tr"/>
1851                        </xsl:element>
1852                    </xsl:element>
1853                    <!--draw:text-box end  -->
1854                </xsl:element>
1855                <!-- text:p end -->
1856            </xsl:when>
1857            <xsl:otherwise>
1858                <!-- if the table is not surrounded by text then put the table into a draw:text-box -->
1859                <xsl:element name="table:table">
1860                    <xsl:if test="w:tblPr">
1861                        <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any"/></xsl:attribute>
1862                    </xsl:if>
1863                    <xsl:apply-templates select="w:tblGrid | w:tr"/>
1864                </xsl:element>
1865            </xsl:otherwise>
1866        </xsl:choose>
1867    </xsl:template>
1868    <xsl:template match="w:tblGrid">
1869        <xsl:apply-templates select="w:gridCol"/>
1870    </xsl:template>
1871    <xsl:template match="w:gridCol">
1872        <xsl:element name="table:table-column">
1873            <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any"/>.C<xsl:number count="w:gridCol" from="/w:wordDocument/w:body" level="single"/></xsl:attribute>
1874        </xsl:element>
1875    </xsl:template>
1876    <xsl:template match="w:tr">
1877        <xsl:element name="table:table-row">
1878            <!-- generate row in table and add attribute of table:style-name if the style:style exists. cp tom chen. -->
1879            <xsl:if test="w:trPr/w:trHeight">
1880                <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any"/>.R<xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single"/></xsl:attribute>
1881            </xsl:if>
1882            <xsl:apply-templates select="w:tc"/>
1883        </xsl:element>
1884    </xsl:template>
1885    <xsl:template match="w:tc">
1886        <xsl:element name="table:table-cell">
1887            <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any"/>.R<xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single"/>C<xsl:number count="w:tc" from="/w:wordDocument/w:body" level="single"/></xsl:attribute>
1888            <xsl:if test="w:tcPr/w:gridSpan">
1889                <xsl:attribute name="table:number-columns-spanned"><xsl:value-of select="w:tcPr/w:gridSpan/@w:val"/></xsl:attribute>
1890            </xsl:if>
1891            <xsl:apply-templates select="w:p | w:tbl"/>
1892        </xsl:element>
1893    </xsl:template>
1894<!-- End of OOo2.0 import/wordml/wordml2ooo_table.xsl stylesheet  -->
1895<!-- Start of OOo2.0 import/wordml/wordml2ooo_text.xsl stylesheet  -->
1896    <xsl:template name="create-default-paragraph-styles">
1897        <xsl:variable name="default-paragraph-style" select="w:style[@w:default = 'on' and @w:type = 'paragraph']"/>
1898        <xsl:if test="$default-paragraph-style">
1899            <style:default-style style:family="paragraph">
1900                <style:properties>
1901                    <xsl:choose>
1902                        <xsl:when test="/w:wordDocument/w:fonts/w:defaultFonts">
1903                            <xsl:attribute name="style:font-name"><xsl:value-of select="/w:wordDocument/w:fonts/w:defaultFonts/@w:ascii"/></xsl:attribute>
1904                            <xsl:attribute name="style:font-name-asian"><xsl:value-of select="/w:wordDocument/w:fonts/w:defaultFonts/@w:fareast"/></xsl:attribute>
1905                            <xsl:attribute name="style:font-name-complex"><xsl:value-of select="/w:wordDocument/w:fonts/w:defaultFonts/@w:cs"/></xsl:attribute>
1906                        </xsl:when>
1907                        <xsl:otherwise>
1908                            <xsl:attribute name="style:font-name">Times New Roman</xsl:attribute>
1909                        </xsl:otherwise>
1910                    </xsl:choose>
1911                    <xsl:if test="$default-paragraph-style/w:rPr/w:sz">
1912                        <xsl:attribute name="fo:font-size"><xsl:value-of select="$default-paragraph-style/w:rPr/w:sz/@w:val div 2"/>pt</xsl:attribute>
1913                        <xsl:attribute name="fo:font-size-asian"><xsl:value-of select="$default-paragraph-style/w:rPr/w:sz/@w:val div 2"/>pt</xsl:attribute>
1914                    </xsl:if>
1915                    <xsl:if test="$default-paragraph-style/w:rPr/w:sz-cs">
1916                        <xsl:attribute name="fo:font-size-complex"><xsl:value-of select="$default-paragraph-style/w:rPr/w:sz-cs/@w:val div 2"/>pt</xsl:attribute>
1917                    </xsl:if>
1918                    <!-- if not defined default font size in Word, make it out as 10pt. glu -->
1919                    <xsl:if test="not($default-paragraph-style/w:rPr/w:sz or w:rPr/w:sz-cs)">
1920                        <xsl:attribute name="fo:font-size">10pt</xsl:attribute>
1921                        <xsl:attribute name="fo:font-size-asian">10pt</xsl:attribute>
1922                        <xsl:attribute name="fo:font-size-complex">10pt</xsl:attribute>
1923                    </xsl:if>
1924                    <xsl:if test="$default-paragraph-style/w:rPr/w:lang">
1925                        <xsl:if test="$default-paragraph-style/w:rPr/w:lang/@w:val">
1926                            <xsl:attribute name="fo:language"><xsl:value-of select="substring-before( $default-paragraph-style/w:rPr/w:lang/@w:val, '-')"/></xsl:attribute>
1927                            <xsl:attribute name="fo:country"><xsl:value-of select="substring-after( $default-paragraph-style/w:rPr/w:lang/@w:val, '-')"/></xsl:attribute>
1928                        </xsl:if>
1929                        <xsl:if test="$default-paragraph-style/w:rPr/w:lang/@w:fareast">
1930                            <xsl:attribute name="fo:language-asian"><xsl:value-of select="substring-before( $default-paragraph-style/w:rPr/w:lang/@w:fareast, '-')"/></xsl:attribute>
1931                            <xsl:attribute name="fo:country-asian"><xsl:value-of select="substring-after( $default-paragraph-style/w:rPr/w:lang/@w:fareast, '-')"/></xsl:attribute>
1932                        </xsl:if>
1933                        <xsl:if test="$default-paragraph-style/w:rPr/w:lang/@w:bidi">
1934                            <xsl:attribute name="fo:language-complex"><xsl:value-of select="substring-before( $default-paragraph-style/w:rPr/w:lang/@w:bidi, '-')"/></xsl:attribute>
1935                            <xsl:attribute name="fo:country-complex"><xsl:value-of select="substring-after( $default-paragraph-style/w:rPr/w:lang/@w:bidi, '-')"/></xsl:attribute>
1936                        </xsl:if>
1937                    </xsl:if>
1938                    <xsl:attribute name="style:tab-stop-distance"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(/w:wordDocument/w:docPr/w:defaultTabStop/@w:val,'dxa')"/></xsl:call-template>cm</xsl:attribute>
1939                </style:properties>
1940            </style:default-style>
1941        </xsl:if>
1942    </xsl:template>
1943    <xsl:template name="create-default-text-styles">
1944        <style:style style:name="Numbering Symbols" style:family="text"/>
1945        <style:style style:name="Bullet Symbols" style:family="text">
1946            <style:properties style:font-name="StarSymbol" fo:font-size="12pt" style:font-name-asian="StarSymbol" style:font-size-asian="12pt" style:font-name-complex="StarSymbol" style:font-size-complex="12pt"/>
1947        </style:style>
1948    </xsl:template>
1949    <xsl:template match="w:p" mode="style">
1950        <xsl:variable name="paragraph-number">
1951            <xsl:number from="/w:wordDocument/w:body" level="any" count="w:p"/>
1952        </xsl:variable>
1953        <xsl:variable name="section-property-number" select="count(preceding::w:sectPr)"/>
1954        <xsl:variable name="last-section-property" select="preceding::w:pPr/w:sectPr[1]"/>
1955        <style:style style:family="paragraph" style:name="P{$paragraph-number}">
1956            <xsl:if test="w:pPr/w:pStyle">
1957                <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:pPr/w:pStyle/@w:val"/></xsl:attribute>
1958            </xsl:if>
1959            <xsl:choose>
1960                <xsl:when test="generate-id($last-section-property[last()]/following::w:p[1]) = generate-id(.) and not(ancestor::w:sectPr)">
1961                    <xsl:attribute name="style:master-page-name">Standard<xsl:value-of select="$section-property-number + 1"/></xsl:attribute>
1962                </xsl:when>
1963                <xsl:when test="$paragraph-number = 1">
1964                    <xsl:attribute name="style:master-page-name">Standard1</xsl:attribute>
1965                </xsl:when>
1966            </xsl:choose>
1967            <style:properties>
1968                <xsl:apply-templates select="w:pPr"/>
1969            </style:properties>
1970        </style:style>
1971        <xsl:if test="w:r/w:br/@w:type='page'">
1972            <style:style style:family="paragraph" style:name="P{$paragraph-number}page-break">
1973                <xsl:if test="w:pPr/w:pStyle">
1974                    <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:pPr/w:pStyle/@w:val"/></xsl:attribute>
1975                </xsl:if>
1976                <xsl:choose>
1977                    <xsl:when test="generate-id($last-section-property[last()]/following::w:p[1]) = generate-id(.) and not(ancestor::w:sectPr)">
1978                        <xsl:attribute name="style:master-page-name">Standard<xsl:value-of select="$section-property-number + 1"/></xsl:attribute>
1979                    </xsl:when>
1980                    <xsl:when test="$paragraph-number = 1">
1981                        <xsl:attribute name="style:master-page-name">Standard1</xsl:attribute>
1982                    </xsl:when>
1983                </xsl:choose>
1984                <style:properties fo:break-before="page">
1985                    <xsl:apply-templates select="w:pPr"/>
1986                </style:properties>
1987            </style:style>
1988        </xsl:if>
1989        <xsl:if test="w:r/w:br/@w:type='column'">
1990            <style:style style:family="paragraph" style:name="P{$paragraph-number}column-break">
1991                <xsl:if test="w:pPr/w:pStyle">
1992                    <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:pPr/w:pStyle/@w:val"/></xsl:attribute>
1993                </xsl:if>
1994                <xsl:choose>
1995                    <xsl:when test="generate-id($last-section-property[last()]/following::w:p[1]) = generate-id(.) and not(ancestor::w:sectPr)">
1996                        <xsl:attribute name="style:master-page-name">Standard<xsl:value-of select="$section-property-number + 1"/></xsl:attribute>
1997                    </xsl:when>
1998                    <xsl:when test="$paragraph-number = 1">
1999                        <xsl:attribute name="style:master-page-name">Standard1</xsl:attribute>
2000                    </xsl:when>
2001                </xsl:choose>
2002                <style:properties fo:break-before="column">
2003                    <xsl:apply-templates select="w:pPr"/>
2004                </style:properties>
2005            </style:style>
2006        </xsl:if>
2007    </xsl:template>
2008    <xsl:template match="w:pPr">
2009        <xsl:if test="w:ind/@w:left">
2010            <xsl:attribute name="fo:margin-left"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:ind/@w:left, 'dxa')"/></xsl:call-template>cm</xsl:attribute>
2011        </xsl:if>
2012        <xsl:if test="w:ind/@w:right">
2013            <xsl:attribute name="fo:margin-right"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:ind/@w:right, 'dxa')"/></xsl:call-template>cm</xsl:attribute>
2014        </xsl:if>
2015        <xsl:if test="w:ind/@w:first-line">
2016            <xsl:attribute name="fo:text-indent"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:ind/@w:first-line, 'dxa')"/></xsl:call-template>cm</xsl:attribute>
2017        </xsl:if>
2018        <xsl:if test="w:ind/@w:hanging">
2019            <xsl:attribute name="fo:text-indent"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat('-',w:ind/@w:hanging, 'dxa')"/></xsl:call-template>cm</xsl:attribute>
2020        </xsl:if>
2021        <!-- bi-directional support-->
2022        <xsl:if test="w:bidi">
2023            <xsl:attribute name="style:writing-mode">rl-tb</xsl:attribute>
2024            <xsl:attribute name="fo:text-align">end</xsl:attribute>
2025        </xsl:if>
2026        <xsl:if test="w:jc">
2027            <xsl:choose>
2028                <xsl:when test="w:jc/@w:val = 'center'">
2029                    <xsl:attribute name="fo:text-align">center</xsl:attribute>
2030                </xsl:when>
2031                <xsl:when test="w:jc/@w:val = 'left'">
2032                    <xsl:choose>
2033                        <xsl:when test="w:bidi">
2034                            <xsl:attribute name="fo:text-align">end</xsl:attribute>
2035                        </xsl:when>
2036                        <xsl:otherwise>
2037                            <xsl:attribute name="fo:text-align">start</xsl:attribute>
2038                        </xsl:otherwise>
2039                    </xsl:choose>
2040                </xsl:when>
2041                <xsl:when test="w:jc/@w:val = 'right'">
2042                    <xsl:choose>
2043                        <xsl:when test="w:bidi">
2044                            <xsl:attribute name="fo:text-align">start</xsl:attribute>
2045                        </xsl:when>
2046                        <xsl:otherwise>
2047                            <xsl:attribute name="fo:text-align">end</xsl:attribute>
2048                        </xsl:otherwise>
2049                    </xsl:choose>
2050                </xsl:when>
2051                <xsl:otherwise>
2052                    <xsl:attribute name="fo:text-align">justify</xsl:attribute>
2053                    <xsl:attribute name="style:justify-single-word">false</xsl:attribute>
2054                </xsl:otherwise>
2055            </xsl:choose>
2056        </xsl:if>
2057        <xsl:attribute name="style:auto-text-indent">false</xsl:attribute>
2058        <xsl:if test="w:spacing">
2059            <xsl:choose>
2060                <xsl:when test="w:spacing/@w:line-rule = 'at-least'">
2061                    <xsl:attribute name="style:line-height-at-least"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:spacing/@w:line, 'dxa')"/></xsl:call-template>cm</xsl:attribute>
2062                </xsl:when>
2063                <xsl:when test="w:spacing/@w:line-rule = 'auto'">
2064                    <xsl:attribute name="fo:line-height"><xsl:value-of select="round(w:spacing/@w:line div 240 * 100)"/>%</xsl:attribute>
2065                </xsl:when>
2066                <xsl:when test="w:spacing/@w:line-rule = 'exact'">
2067                    <xsl:attribute name="fo:line-height"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:spacing/@w:line, 'dxa')"/></xsl:call-template>cm</xsl:attribute>
2068                </xsl:when>
2069            </xsl:choose>
2070            <xsl:if test="w:spacing/@w:before">
2071                <xsl:attribute name="fo:margin-top"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:spacing/@w:before, 'dxa')"/></xsl:call-template>cm</xsl:attribute>
2072            </xsl:if>
2073            <xsl:if test="w:spacing/@w:after">
2074                <xsl:attribute name="fo:margin-bottom"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:spacing/@w:after, 'dxa')"/></xsl:call-template>cm</xsl:attribute>
2075            </xsl:if>
2076        </xsl:if>
2077        <xsl:if test="w:shd">
2078            <xsl:variable name="background-color">
2079                <xsl:choose>
2080                    <xsl:when test="string-length(w:shd/@w:fill) = 6">
2081                        <xsl:value-of select="concat('#', w:shd/@w:fill)"/>
2082                    </xsl:when>
2083                    <xsl:otherwise>#000000</xsl:otherwise>
2084                </xsl:choose>
2085            </xsl:variable>
2086            <xsl:choose>
2087                <xsl:when test="w:shd/@w:val = 'solid'">
2088                    <xsl:attribute name="fo:background-color"><xsl:value-of select="$background-color"/></xsl:attribute>
2089                </xsl:when>
2090                <!-- patterns are necessary in the future. glu -->
2091                <xsl:otherwise/>
2092            </xsl:choose>
2093        </xsl:if>
2094        <xsl:if test="w:pageBreakBefore">
2095            <xsl:attribute name="fo:break-before">page</xsl:attribute>
2096        </xsl:if>
2097        <xsl:if test="w:tabs">
2098            <xsl:element name="style:tab-stops">
2099                <xsl:for-each select="w:tabs/w:tab">
2100                    <xsl:element name="style:tab-stop">
2101                        <xsl:attribute name="style:position"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(@w:pos, 'dxa')"/></xsl:call-template>cm</xsl:attribute>
2102                        <xsl:choose>
2103                            <xsl:when test="@w:val = 'decimal'">
2104                                <xsl:attribute name="style:type">char</xsl:attribute>
2105                                <xsl:attribute name="style:char"/>
2106                            </xsl:when>
2107                            <xsl:otherwise>
2108                                <xsl:attribute name="style:type"><xsl:value-of select="@w:val"/></xsl:attribute>
2109                            </xsl:otherwise>
2110                        </xsl:choose>
2111                        <xsl:if test="@w:leader">
2112                            <xsl:attribute name="style:leader-char"><xsl:choose><xsl:when test="hyphen">-</xsl:when><xsl:when test="underscore">_</xsl:when><xsl:when test="dot">.</xsl:when></xsl:choose></xsl:attribute>
2113                        </xsl:if>
2114                        <xsl:if test="@style:leader-char">
2115                            <xsl:choose>
2116                                <xsl:when test="@style:leader-char='-'">
2117                                    <xsl:attribute name="w:leader">hyphen</xsl:attribute>
2118                                </xsl:when>
2119                                <xsl:when test="@style:leader-char='_'">
2120                                    <xsl:attribute name="w:leader">underscore</xsl:attribute>
2121                                </xsl:when>
2122                                <xsl:when test="@style:leader-char='.'">
2123                                    <xsl:attribute name="w:leader">dot</xsl:attribute>
2124                                </xsl:when>
2125                                <xsl:when test="@style:leader-char='��'">
2126                                    <xsl:attribute name="w:leader">middle-dot</xsl:attribute>
2127                                </xsl:when>
2128                            </xsl:choose>
2129                        </xsl:if>
2130                    </xsl:element>
2131                </xsl:for-each>
2132            </xsl:element>
2133        </xsl:if>
2134        <xsl:if test="w:keepNext">
2135            <xsl:attribute name="fo:keep-with-next">true</xsl:attribute>
2136        </xsl:if>
2137        <xsl:if test="w:keepLines">
2138            <xsl:attribute name="style:break-inside">avoid</xsl:attribute>
2139        </xsl:if>
2140        <xsl:if test="w:widowControl='on'">
2141            <xsl:attribute name="fo:widows">2</xsl:attribute>
2142            <xsl:attribute name="fo:orphans">2</xsl:attribute>
2143        </xsl:if>
2144        <xsl:if test="w:suppressAutoHyphens">
2145            <xsl:attribute name="fo:hyphenate">false</xsl:attribute>
2146        </xsl:if>
2147        <xsl:if test="w:kinsoku/@w:val='off'">
2148            <xsl:attribute name="style:line-break">normal</xsl:attribute>
2149        </xsl:if>
2150        <xsl:if test="w:overflowPunct/@w:val='off'">
2151            <xsl:attribute name="style:punctuation-wrap">simple</xsl:attribute>
2152        </xsl:if>
2153        <xsl:if test="w:autoSpaceDE/@w:val='off' or w:autoSpaceDN/@w:val='off'">
2154            <xsl:attribute name="style:text-autospace">none</xsl:attribute>
2155        </xsl:if>
2156        <xsl:if test="w:textAlignment">
2157            <xsl:choose>
2158                <xsl:when test="w:textAlignment/@w:val='center'">
2159                    <xsl:attribute name="style:vertical-align">middle</xsl:attribute>
2160                </xsl:when>
2161                <xsl:otherwise>
2162                    <xsl:attribute name="style:vertical-align"><xsl:value-of select="w:textAlignment/@w:val"/></xsl:attribute>
2163                </xsl:otherwise>
2164            </xsl:choose>
2165        </xsl:if>
2166        <xsl:if test="w:pBdr">
2167            <xsl:if test="w:pBdr/w:top">
2168                <xsl:call-template name="get-table-border">
2169                    <xsl:with-param name="style-pos" select="'top'"/>
2170                    <xsl:with-param name="style-position-0" select="w:pBdr/w:top"/>
2171                </xsl:call-template>
2172                <xsl:attribute name="fo:padding-top"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pBdr/w:top/@w:space,'pt')"/></xsl:call-template>cm</xsl:attribute>
2173            </xsl:if>
2174            <xsl:if test="w:pBdr/w:left">
2175                <xsl:call-template name="get-table-border">
2176                    <xsl:with-param name="style-pos" select="'left'"/>
2177                    <xsl:with-param name="style-position-0" select="w:pBdr/w:left"/>
2178                </xsl:call-template>
2179                <xsl:attribute name="fo:padding-left"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pBdr/w:left/@w:space,'pt')"/></xsl:call-template>cm</xsl:attribute>
2180            </xsl:if>
2181            <xsl:if test="w:pBdr/w:right">
2182                <xsl:call-template name="get-table-border">
2183                    <xsl:with-param name="style-pos" select="'right'"/>
2184                    <xsl:with-param name="style-position-0" select="w:pBdr/w:right"/>
2185                </xsl:call-template>
2186                <xsl:attribute name="fo:padding-right"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pBdr/w:right/@w:space,'pt')"/></xsl:call-template>cm</xsl:attribute>
2187            </xsl:if>
2188            <xsl:if test="w:pBdr/w:bottom">
2189                <xsl:call-template name="get-table-border">
2190                    <xsl:with-param name="style-pos" select="'bottom'"/>
2191                    <xsl:with-param name="style-position-0" select="w:pBdr/w:bottom"/>
2192                </xsl:call-template>
2193                <xsl:attribute name="fo:padding-bottom"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:pBdr/w:bottom/@w:space,'pt')"/></xsl:call-template>cm</xsl:attribute>
2194            </xsl:if>
2195            <xsl:if test="w:pBdr/*/@w:shadow='on'">
2196                <xsl:attribute name="style:shadow">#000000 0.15cm 0.15cm</xsl:attribute>
2197            </xsl:if>
2198        </xsl:if>
2199         <xsl:if test="w:snapToGrid/@w:val='off'">
2200            <xsl:attribute name="style:snap-to-layout-grid">false</xsl:attribute>
2201        </xsl:if>
2202        <xsl:apply-templates select="w:rPr"/>
2203    </xsl:template>
2204    <xsl:template match="w:rPr" mode="style">
2205        <xsl:element name="style:style">
2206            <xsl:attribute name="style:name">T<xsl:number from="/w:wordDocument/w:body" level="any" count="w:rPr"/></xsl:attribute>
2207            <xsl:attribute name="style:family">text</xsl:attribute>
2208            <xsl:if test="w:rStyle">
2209                <xsl:attribute name="style:parent-style-name"><xsl:value-of select="w:rStyle/@w:val"/></xsl:attribute>
2210            </xsl:if>
2211            <xsl:element name="style:properties">
2212                <xsl:apply-templates select="current()"/>
2213            </xsl:element>
2214        </xsl:element>
2215    </xsl:template>
2216    <xsl:template match="w:rPr">
2217        <xsl:if test="w:rFonts">
2218            <xsl:if test="w:rFonts/@w:ascii">
2219                <xsl:attribute name="style:font-name"><xsl:value-of select="w:rFonts/@w:ascii"/></xsl:attribute>
2220                <xsl:if test="ancestor::w:body">
2221                    <xsl:attribute name="style:font-name-asian"><xsl:value-of select="w:rFonts/@w:ascii"/></xsl:attribute>
2222                    <xsl:attribute name="style:font-name-complex"><xsl:value-of select="w:rFonts/@w:ascii"/></xsl:attribute>
2223                </xsl:if>
2224            </xsl:if>
2225            <xsl:if test="ancestor::w:styles">
2226                <xsl:if test="w:rFonts/@w:fareast">
2227                    <xsl:attribute name="style:font-name-asian"><xsl:value-of select="w:rFonts/@w:fareast"/></xsl:attribute>
2228                </xsl:if>
2229                <xsl:if test="w:rFonts/@w:cs">
2230                    <xsl:attribute name="style:font-name-complex"><xsl:value-of select="w:rFonts/@w:cs"/></xsl:attribute>
2231                </xsl:if>
2232            </xsl:if>
2233        </xsl:if>
2234        <xsl:if test="w:b">
2235            <xsl:attribute name="fo:font-weight">bold</xsl:attribute>
2236            <xsl:attribute name="fo:font-weight-asian">bold</xsl:attribute>
2237        </xsl:if>
2238        <xsl:if test="w:b-cs">
2239            <xsl:attribute name="fo:font-weight-complex">bold</xsl:attribute>
2240        </xsl:if>
2241        <xsl:if test="w:i">
2242            <xsl:attribute name="fo:font-style">italic</xsl:attribute>
2243            <xsl:attribute name="fo:font-style-asian">italic</xsl:attribute>
2244        </xsl:if>
2245        <xsl:if test="w:i-cs">
2246            <xsl:attribute name="fo:font-style-complex">italic</xsl:attribute>
2247        </xsl:if>
2248        <xsl:if test="w:caps">
2249            <xsl:attribute name="fo:text-transform">uppercase</xsl:attribute>
2250        </xsl:if>
2251        <xsl:if test="w:smallCaps">
2252            <xsl:attribute name="fo:font-variant">small-caps</xsl:attribute>
2253        </xsl:if>
2254        <xsl:if test="w:strike">
2255            <xsl:attribute name="style:text-crossing-out">single-line</xsl:attribute>
2256        </xsl:if>
2257        <xsl:if test="w:dstrike">
2258            <xsl:attribute name="style:text-crossing-out">double-line</xsl:attribute>
2259        </xsl:if>
2260        <xsl:if test="w:outline">
2261            <xsl:attribute name="style:text-outline">true</xsl:attribute>
2262        </xsl:if>
2263        <xsl:if test="w:shadow">
2264            <xsl:attribute name="style:text-shadow">1pt 1pt</xsl:attribute>
2265            <xsl:attribute name="fo:text-shadow">1pt 1pt</xsl:attribute>
2266        </xsl:if>
2267        <xsl:if test="w:imprint">
2268            <xsl:attribute name="style:font-relief">engraved</xsl:attribute>
2269        </xsl:if>
2270        <xsl:if test="w:emboss">
2271            <xsl:attribute name="style:font-relief">embossed</xsl:attribute>
2272        </xsl:if>
2273        <xsl:if test="w:vanish">
2274            <xsl:attribute name="text:display">true</xsl:attribute>
2275        </xsl:if>
2276        <xsl:if test="w:color[not(@w:val = 'auto')]">
2277            <xsl:attribute name="fo:color">#<xsl:value-of select="w:color/@w:val"/></xsl:attribute>
2278        </xsl:if>
2279        <xsl:if test="w:spacing">
2280            <xsl:attribute name="fo:letter-spacing"><xsl:call-template name="convert2cm"><xsl:with-param name="value" select="concat(w:spacing/@w:val,'dxa')"/></xsl:call-template>cm</xsl:attribute>
2281        </xsl:if>
2282        <xsl:if test="w:w/@w:val">
2283            <xsl:attribute name="style:text-scale"><xsl:value-of select="w:w/@w:val"/></xsl:attribute>
2284        </xsl:if>
2285        <xsl:if test="w:vertAlign or w:position">
2286            <xsl:variable name="height">
2287                <xsl:choose>
2288                    <xsl:when test="w:vertAlign[@w:val = 'superscript' or @w:val = 'subscript']">58%</xsl:when>
2289                    <xsl:otherwise>100%</xsl:otherwise>
2290                </xsl:choose>
2291            </xsl:variable>
2292            <xsl:variable name="position">
2293                <xsl:choose>
2294                    <xsl:when test="w:position">
2295                        <!-- con't get font height easily, so just set w:val as percentage. glu -->
2296                        <xsl:value-of select="concat( w:position/@w:val, '%')"/>
2297                    </xsl:when>
2298                    <xsl:when test="w:vertAlign[@w:val = 'superscript']">super</xsl:when>
2299                    <xsl:when test="w:vertAlign[@w:val = 'subscript']">sub</xsl:when>
2300                </xsl:choose>
2301            </xsl:variable>
2302            <xsl:attribute name="style:text-position"><xsl:value-of select="concat($position, ' ', $height)"/></xsl:attribute>
2303        </xsl:if>
2304        <xsl:if test="w:sz">
2305            <xsl:attribute name="fo:font-size"><xsl:value-of select="w:sz/@w:val div 2"/>pt</xsl:attribute>
2306            <xsl:attribute name="fo:font-size-asian"><xsl:value-of select="w:sz/@w:val div 2"/>pt</xsl:attribute>
2307        </xsl:if>
2308        <xsl:if test="w:sz-cs">
2309            <xsl:attribute name="fo:font-size-complex"><xsl:value-of select="w:sz-cs/@w:val div 2"/>pt</xsl:attribute>
2310        </xsl:if>
2311        <xsl:if test="w:highlight">
2312            <xsl:choose>
2313                <xsl:when test="w:highlight/@w:val='black'">
2314                    <xsl:attribute name="style:text-background-color">#000000</xsl:attribute>
2315                </xsl:when>
2316                <xsl:when test="w:highlight/@w:val='yellow'">
2317                    <xsl:attribute name="style:text-background-color">#ffff00</xsl:attribute>
2318                </xsl:when>
2319                <xsl:when test="w:highlight/@w:val='green'">
2320                    <xsl:attribute name="style:text-background-color">#00ff00</xsl:attribute>
2321                </xsl:when>
2322                <xsl:when test="w:highlight/@w:val='cyan'">
2323                    <xsl:attribute name="style:text-background-color">#00ffff</xsl:attribute>
2324                </xsl:when>
2325                <xsl:when test="w:highlight/@w:val='magenta'">
2326                    <xsl:attribute name="style:text-background-color">#ff00ff</xsl:attribute>
2327                </xsl:when>
2328                <xsl:when test="w:highlight/@w:val='blue'">
2329                    <xsl:attribute name="style:text-background-color">#0000ff</xsl:attribute>
2330                </xsl:when>
2331                <xsl:when test="w:highlight/@w:val='red'">
2332                    <xsl:attribute name="style:text-background-color">#ff0000</xsl:attribute>
2333                </xsl:when>
2334                <xsl:when test="w:highlight/@w:val='dark-blue'">
2335                    <xsl:attribute name="style:text-background-color">#000080</xsl:attribute>
2336                </xsl:when>
2337                <xsl:when test="w:highlight/@w:val='dark-cyan'">
2338                    <xsl:attribute name="style:text-background-color">#008080</xsl:attribute>
2339                </xsl:when>
2340                <xsl:when test="w:highlight/@w:val='dark-green'">
2341                    <xsl:attribute name="style:text-background-color">#008000</xsl:attribute>
2342                </xsl:when>
2343                <xsl:when test="w:highlight/@w:val='dark-magenta'">
2344                    <xsl:attribute name="style:text-background-color">#800080</xsl:attribute>
2345                </xsl:when>
2346                <xsl:when test="w:highlight/@w:val='dark-red'">
2347                    <xsl:attribute name="style:text-background-color">#800000</xsl:attribute>
2348                </xsl:when>
2349                <xsl:when test="w:highlight/@w:val='dark-yellow'">
2350                    <xsl:attribute name="style:text-background-color">#808000</xsl:attribute>
2351                </xsl:when>
2352                <xsl:when test="w:highlight/@w:val='dark-gray'">
2353                    <xsl:attribute name="style:text-background-color">#808080</xsl:attribute>
2354                </xsl:when>
2355                <xsl:when test="w:highlight/@w:val='light-gray'">
2356                    <xsl:attribute name="style:text-background-color">#c0c0c0</xsl:attribute>
2357                </xsl:when>
2358            </xsl:choose>
2359        </xsl:if>
2360        <xsl:if test="w:u">
2361            <xsl:choose>
2362                <xsl:when test="w:u/@w:val = 'words'">
2363                    <xsl:attribute name="style:text-underline">single</xsl:attribute>
2364                    <xsl:attribute name="fo:score-spaces">false</xsl:attribute>
2365                </xsl:when>
2366                <xsl:when test="w:u/@w:val = 'thick'">
2367                    <xsl:attribute name="style:text-underline">bold</xsl:attribute>
2368                </xsl:when>
2369                <xsl:when test="w:u/@w:val = 'dotted-heavy'">
2370                    <xsl:attribute name="style:text-underline">bold-dotted</xsl:attribute>
2371                </xsl:when>
2372                <xsl:when test="w:u/@w:val = 'dashed-heavy'">
2373                    <xsl:attribute name="style:text-underline">bold-dash</xsl:attribute>
2374                </xsl:when>
2375                <xsl:when test="w:u/@w:val = 'dash-long'">
2376                    <xsl:attribute name="style:text-underline">long-dash</xsl:attribute>
2377                </xsl:when>
2378                <xsl:when test="w:u/@w:val = 'dash-long-heavy'">
2379                    <xsl:attribute name="style:text-underline">bold-long-dash</xsl:attribute>
2380                </xsl:when>
2381                <xsl:when test="w:u/@w:val = 'dash-dot-heavy'">
2382                    <xsl:attribute name="style:text-underline">bold-dot-dash</xsl:attribute>
2383                </xsl:when>
2384                <xsl:when test="w:u/@w:val = 'dash-dot-dot-heavy'">
2385                    <xsl:attribute name="style:text-underline">bold-dot-dot-dash</xsl:attribute>
2386                </xsl:when>
2387                <xsl:when test="w:u/@w:val = 'wavy-heavy'">
2388                    <xsl:attribute name="style:text-underline">bold-wave</xsl:attribute>
2389                </xsl:when>
2390                <xsl:when test="w:u/@w:val = 'wavy-double'">
2391                    <xsl:attribute name="style:text-underline">double-wave</xsl:attribute>
2392                </xsl:when>
2393                <xsl:otherwise>
2394                    <xsl:attribute name="style:text-underline"><xsl:value-of select="w:u/@w:val"/></xsl:attribute>
2395                </xsl:otherwise>
2396            </xsl:choose>
2397            <xsl:if test="w:u/@w:color and not(w:u/@w:color = 'auto')">
2398                <xsl:attribute name="style:text-underline-color">#<xsl:value-of select="w:u/@w:color"/></xsl:attribute>
2399            </xsl:if>
2400        </xsl:if>
2401        <xsl:if test="w:effect[@w:val = 'blink-background']">
2402            <xsl:attribute name="style:text-blinking">true</xsl:attribute>
2403            <xsl:attribute name="style:text-background-color">#000000</xsl:attribute>
2404        </xsl:if>
2405        <xsl:if test="w:shd and not(w:highlight)">
2406            <xsl:if test="string-length(w:shd/@w:fill) = 6">
2407                <xsl:attribute name="style:text-background-color">#<xsl:value-of select="w:shd/@w:fill"/></xsl:attribute>
2408            </xsl:if>
2409        </xsl:if>
2410        <xsl:if test="w:em">
2411            <xsl:choose>
2412                <xsl:when test="w:em/@w:val = 'comma'">
2413                    <xsl:attribute name="style:text-emphasize">accent below</xsl:attribute>
2414                </xsl:when>
2415                <xsl:when test="w:em/@w:val = 'under-dot'">
2416                    <xsl:attribute name="style:text-emphasize">disc below</xsl:attribute>
2417                </xsl:when>
2418                <xsl:otherwise>
2419                    <xsl:attribute name="style:text-emphasize"><xsl:value-of select="concat( w:em/@w:val, ' below')"/></xsl:attribute>
2420                </xsl:otherwise>
2421            </xsl:choose>
2422        </xsl:if>
2423        <xsl:if test="w:lang">
2424            <xsl:if test="w:lang/@w:val">
2425                <xsl:attribute name="fo:language"><xsl:value-of select="substring-before( w:lang/@w:val, '-')"/></xsl:attribute>
2426                <xsl:attribute name="fo:country"><xsl:value-of select="substring-after( w:lang/@w:val, '-')"/></xsl:attribute>
2427            </xsl:if>
2428            <xsl:if test="w:lang/@w:fareast">
2429                <xsl:attribute name="fo:language-asian"><xsl:value-of select="substring-before( w:lang/@w:fareast, '-')"/></xsl:attribute>
2430                <xsl:attribute name="fo:country-asian"><xsl:value-of select="substring-after( w:lang/@w:fareast, '-')"/></xsl:attribute>
2431            </xsl:if>
2432            <xsl:if test="w:lang/@w:bidi">
2433                <xsl:attribute name="fo:language-complex"><xsl:value-of select="substring-before( w:lang/@w:bidi, '-')"/></xsl:attribute>
2434                <xsl:attribute name="fo:country-complex"><xsl:value-of select="substring-after( w:lang/@w:bidi, '-')"/></xsl:attribute>
2435            </xsl:if>
2436        </xsl:if>
2437    </xsl:template>
2438    <xsl:template match="w:p">
2439        <xsl:choose>
2440            <!-- because word treats page breaks as separate tags, we must split some paragraphs up so that we can 
2441			give the sub para a fo:break-before ="page" or column attribute. -->
2442            <xsl:when test="w:r[w:br/@w:type='page' or w:br/@w:type='column']">
2443                <xsl:call-template name="process-breaks-in-paragraph"/>
2444            </xsl:when>
2445            <xsl:otherwise>
2446                <xsl:call-template name="process-common-paragraph"/>
2447            </xsl:otherwise>
2448        </xsl:choose>
2449    </xsl:template>
2450    <xsl:template name="process-breaks-in-paragraph">
2451        <xsl:variable name="textruns-with-break" select="w:r[w:br/@w:type='page' or w:br/@w:type='column']"/>
2452        <xsl:call-template name="create-sub-paragraph">
2453            <xsl:with-param name="textruns" select="$textruns-with-break[1]/preceding-sibling::w:r"/>
2454        </xsl:call-template>
2455        <xsl:for-each select="$textruns-with-break">
2456            <xsl:variable name="break-position" select="position()"/>
2457            <xsl:call-template name="create-sub-paragraph">
2458                <xsl:with-param name="textruns" select="following-sibling::w:r[not(w:br/@w:type='page' or w:br/@w:type='column') and (count(preceding::w:r[w:br/@w:type='page' or w:br/@w:type='column']) = $break-position)]"/>
2459                <xsl:with-param name="textruns-with-break" select="current()"/>
2460            </xsl:call-template>
2461        </xsl:for-each>
2462    </xsl:template>
2463    <xsl:template name="create-sub-paragraph">
2464        <xsl:param name="textruns"/>
2465        <xsl:param name="textruns-with-break"/>
2466        <xsl:if test="$textruns or $textruns-with-break">
2467            <xsl:variable name="curr-num">
2468                <xsl:number from="/w:wordDocument/w:body" level="any" count="w:p"/>
2469            </xsl:variable>
2470            <text:p>
2471                <xsl:choose>
2472                    <xsl:when test="$textruns-with-break">
2473                        <xsl:attribute name="text:style-name"><xsl:value-of select="concat('P',$curr-num,w:br/@w:type, '-break')"/></xsl:attribute>
2474                        <xsl:apply-templates select="$textruns-with-break"/>
2475                    </xsl:when>
2476                    <xsl:otherwise>
2477                        <xsl:attribute name="text:style-name"><xsl:value-of select="concat( 'P', $curr-num)"/></xsl:attribute>
2478                    </xsl:otherwise>
2479                </xsl:choose>
2480                <xsl:if test="$textruns">
2481                    <xsl:apply-templates select="$textruns"/>
2482                </xsl:if>
2483            </text:p>
2484        </xsl:if>
2485    </xsl:template>
2486    <xsl:template name="process-common-paragraph">
2487        <xsl:variable name="heading-or-paragraph">
2488            <xsl:choose>
2489                <xsl:when test="key('heading-style', w:pPr/w:pStyle/@w:val)">text:h</xsl:when>
2490                <xsl:otherwise>text:p</xsl:otherwise>
2491            </xsl:choose>
2492        </xsl:variable>
2493        <xsl:element name="{$heading-or-paragraph}">
2494            <xsl:if test="$heading-or-paragraph = 'text:h'">
2495                <xsl:attribute name="text:level"><xsl:value-of select="key('heading-style',w:pPr/w:pStyle/@w:val)/w:pPr/w:outlineLvl/@w:val + 1"/></xsl:attribute>
2496            </xsl:if>
2497            <xsl:variable name="curr-num">
2498                <xsl:number from="/w:wordDocument/w:body" level="any" count="w:p"/>
2499            </xsl:variable>
2500            <xsl:attribute name="text:style-name"><xsl:value-of select="concat( 'P', $curr-num)"/></xsl:attribute>
2501            <!-- call the template to generate bookmark-start matching nodes before current. cp tom chen. -->
2502            <xsl:variable name="bm-node" select="preceding::aml:annotation[@w:type = 'Word.Bookmark.Start']"/>
2503            <xsl:variable name="wp-node" select="preceding::w:p[1]"/>
2504            <xsl:call-template name="start-end-bookmark">
2505                <xsl:with-param name="type" select="'start'"/>
2506                <xsl:with-param name="bm-node" select="$bm-node"/>
2507                <xsl:with-param name="wp-node" select="$wp-node"/>
2508            </xsl:call-template>
2509            <xsl:apply-templates select=".//w:r | w:fldSimple | w:hlink"/>
2510            <xsl:variable name="bm-node2" select="following::aml:annotation[@w:type = 'Word.Bookmark.End']"/>
2511            <xsl:variable name="wp-node2" select="following::w:p[position() = 1]"/>
2512            <xsl:call-template name="start-end-bookmark">
2513                <xsl:with-param name="type" select="'end'"/>
2514                <xsl:with-param name="bm-node" select="$bm-node2"/>
2515                <xsl:with-param name="wp-node" select="$wp-node2"/>
2516            </xsl:call-template>
2517        </xsl:element>
2518    </xsl:template>
2519    <!-- WordML contains multiple w:t within one w:r, so in Star Writer text:span should correspond to w:t glu -->
2520    <xsl:template match="w:r">
2521        <!-- handling another type of Hyperlink address in w:body.cp tom chen. 
2522            Acutally they're from Field features, a complex one. glu 
2523            <xsl:when test="w:r/w:instrText and contains(w:r/w:instrText , 'HYPERLINK')">
2524                <xsl:variable name="hyper-str" select="normalize-space(w:r/w:instrText)"/>
2525                <xsl:variable name="hyper-dest" select="substring-before( substring($hyper-str, 12), '&quot;')"/>
2526                <xsl:variable name="hyper-bookmark">
2527                    <xsl:choose>
2528                        <xsl:when test="contains( $hyper-str, ' \l ')">
2529                            <xsl:value-of select="concat( '#', substring-before( substring-after( substring-after( $hyper-str, ' \l '), '&quot;'), '&quot;') )"/>
2530                        </xsl:when>
2531                        <xsl:otherwise/>
2532                    </xsl:choose>
2533                </xsl:variable>
2534                <text:p>
2535                    <text:a>
2536                        <xsl:attribute name="xlink:type">simple</xsl:attribute>
2537                        <xsl:attribute name="xlink:href"><xsl:value-of select="concat( $hyper-dest, $hyper-bookmark)"/></xsl:attribute>
2538                        <xsl:apply-templates/>
2539                    </text:a>
2540                </text:p>
2541            </xsl:when>
2542            -->
2543        <xsl:if test="w:br[@w:type='text-wrapping' or not(@w:type)]">
2544            <text:line-break/>
2545        </xsl:if>
2546        <xsl:choose>
2547            <xsl:when test="aml:annotation/@w:type = 'Word.Comment'">
2548                <office:annotation office:author="{aml:annotation/@aml:author}" office:create-date="{substring(aml:annotation/@aml:createdate,1,10)}" office:display="true">
2549                    <xsl:apply-templates/>
2550                </office:annotation>
2551            </xsl:when>
2552            <xsl:when test="(preceding-sibling::w:r) or (w:rPr)">
2553                <xsl:element name="text:span">
2554                    <xsl:choose>
2555                        <xsl:when test="w:rPr/w:rStyle">
2556                            <xsl:attribute name="text:style-name"><xsl:value-of select="w:rPr/w:rStyle/@w:val"/></xsl:attribute>
2557                        </xsl:when>
2558                        <xsl:when test="w:rPr">
2559                            <xsl:variable name="position">
2560                                <xsl:number from="/w:wordDocument/w:body" level="any" count="w:rPr"/>
2561                            </xsl:variable>
2562                            <xsl:attribute name="text:style-name">T<xsl:value-of select="$position + 1"/></xsl:attribute>
2563                        </xsl:when>
2564                    </xsl:choose>
2565                    <xsl:apply-templates/>
2566                </xsl:element>
2567            </xsl:when>
2568            <xsl:otherwise>
2569                <xsl:apply-templates/>
2570            </xsl:otherwise>
2571        </xsl:choose>
2572    </xsl:template>
2573    <!-- strange enough, WordML allows bookmarks out of w:p, but this isn't supported by StarWriter. To be patched. :( glu -->
2574    <xsl:template match="aml:annotation[@w:type = 'Word.Bookmark.Start']">
2575        <xsl:variable name="id" select="@aml:id"/>
2576        <text:bookmark-start text:name="{@w:name}"/>
2577    </xsl:template>
2578    <xsl:template match="aml:annotation[@w:type = 'Word.Bookmark.End']">
2579        <xsl:variable name="id" select="@aml:id"/>
2580        <text:bookmark-end text:name="{preceding::aml:annotation[@aml:id = $id]/@w:name}"/>
2581    </xsl:template>
2582    <xsl:template match="w:hlink">
2583        <xsl:element name="text:a">
2584            <xsl:attribute name="xlink:type">simple</xsl:attribute>
2585            <xsl:choose>
2586                <xsl:when test="@w:dest and @w:bookmark">
2587                    <xsl:attribute name="xlink:href"><xsl:value-of select="concat( @w:dest, concat('#', @w:bookmark) )"/></xsl:attribute>
2588                </xsl:when>
2589                <xsl:when test="@w:dest">
2590                    <xsl:attribute name="xlink:href"><xsl:value-of select="@w:dest"/></xsl:attribute>
2591                </xsl:when>
2592                <xsl:when test="@w:bookmark">
2593                    <xsl:attribute name="xlink:href"><xsl:value-of select="concat('#', @w:bookmark)"/></xsl:attribute>
2594                </xsl:when>
2595            </xsl:choose>
2596            <xsl:if test="@w:target">
2597                <xsl:attribute name="office:target-frame-name"><xsl:value-of select="@w:target"/></xsl:attribute>
2598            </xsl:if>
2599            <xsl:apply-templates/>
2600        </xsl:element>
2601    </xsl:template>
2602    <xsl:template name="start-end-bookmark">
2603        <!--?? generate bookmark before/after the tag w:p by recursion untill another type of aml:annotation. type: start/end. cp tom chen. -->
2604        <xsl:param name="type"/>
2605        <xsl:param name="bm-node"/>
2606        <xsl:param name="wp-node"/>
2607        <xsl:for-each select="$bm-node">
2608            <xsl:variable name="curr" select="."/>
2609            <xsl:for-each select="$wp-node[1]">
2610                <xsl:if test="not(preceding::aml:annotation/@aml:id = $curr/@aml:id) and not(./aml:annotation[@aml:id = $curr/@aml:id]) and ($type = 'start')">
2611                    <text:bookmark-start text:name="{$bm-node[@aml:id = $curr/@aml:id]/@w:name}"/>
2612                </xsl:if>
2613                <xsl:if test="not(following::aml:annotation/@aml:id = $curr/@aml:id) and not(./aml:annotation[@aml:id = $curr/@aml:id]) and ($type = 'end')">
2614                    <text:bookmark-end text:name="{preceding::aml:annotation[@aml:id = $curr/@aml:id]/@w:name}"/>
2615                </xsl:if>
2616            </xsl:for-each>
2617        </xsl:for-each>
2618    </xsl:template>
2619    <xsl:template match="w:t">
2620        <xsl:choose>
2621            <xsl:when test="string(.) = ' ' ">
2622                <xsl:element name="text:s"/>
2623            </xsl:when>
2624            <xsl:when test="contains(.,'  ')">
2625                <xsl:call-template name="replace-spaces">
2626                    <xsl:with-param name="curr-string" select="."/>
2627                </xsl:call-template>
2628            </xsl:when>
2629            <xsl:otherwise>
2630                <xsl:apply-templates/>
2631            </xsl:otherwise>
2632        </xsl:choose>
2633    </xsl:template>
2634    <xsl:template name="replace-spaces">
2635        <xsl:param name="curr-string"/>
2636        <xsl:if test="contains($curr-string,'  ')">
2637            <xsl:value-of select="substring-before($curr-string,'  ')"/>
2638            <text:s text:c="2"/>
2639            <xsl:variable name="next-string" select="substring-after($curr-string,'  ')"/>
2640            <xsl:choose>
2641                <xsl:when test="contains($next-string, '  ')">
2642                    <xsl:call-template name="replace-spaces">
2643                        <xsl:with-param name="curr-string" select="$next-string"/>
2644                    </xsl:call-template>
2645                </xsl:when>
2646                <xsl:otherwise>
2647                    <xsl:value-of select="$next-string"/>
2648                </xsl:otherwise>
2649            </xsl:choose>
2650        </xsl:if>
2651    </xsl:template>
2652    <xsl:template match="w:tab">
2653        <xsl:element name="text:tab-stop"/>
2654    </xsl:template>
2655    <xsl:template match="w:instrText"/>
2656    <xsl:template match="w:fldChar"/>
2657<!-- End of OOo2.0 import/wordml/wordml2ooo_text.xsl stylesheet  -->
2658<!-- Start of OOo2.0 import/common/ms2ooo_docpr.xsl stylesheet  -->
2659    <xsl:template match="o:DocumentProperties">
2660        <office:meta>
2661            <meta:generator>Microsoft Word 2003</meta:generator>
2662            <dc:title>
2663                <xsl:value-of select="o:Title"/>
2664            </dc:title>
2665            <dc:description>
2666                <xsl:value-of select="o:Description"/>
2667            </dc:description>
2668            <dc:subject>
2669                <xsl:value-of select="o:Subject"/>
2670            </dc:subject>
2671            <meta:initial-creator>
2672                <xsl:value-of select="o:Author"/>
2673            </meta:initial-creator>
2674            <meta:creation-date>
2675                <xsl:value-of select="substring-before( o:Created, 'Z')"/>
2676            </meta:creation-date>
2677            <dc:creator>
2678                <xsl:value-of select="o:LastAuthor"/>
2679            </dc:creator>
2680            <dc:date>
2681                <xsl:value-of select="substring-before( o:LastSaved, 'Z')"/>
2682            </dc:date>
2683            <meta:printed-by/>
2684            <meta:print-date>
2685                <xsl:value-of select="substring-before( o:LastPrinted, 'Z')"/>
2686            </meta:print-date>
2687            <meta:keywords>
2688                <meta:keyword>
2689                    <xsl:value-of select="o:Keywords"/>
2690                </meta:keyword>
2691            </meta:keywords>
2692            <dc:language/>
2693            <meta:editing-cycles>
2694                <xsl:value-of select="o:Revision"/>
2695            </meta:editing-cycles>
2696            <meta:editing-duration>
2697                <xsl:if test="o:TotalTime">
2698                    <xsl:value-of select="concat('PT', floor(o:TotalTime div 60), 'H', o:TotalTime mod 60, 'M0S')"/>
2699                </xsl:if>
2700            </meta:editing-duration>
2701            <meta:user-defined meta:name="Category">
2702                <xsl:value-of select="o:Category"/>
2703            </meta:user-defined>
2704            <meta:user-defined meta:name="Manager">
2705                <xsl:value-of select="o:Manager"/>
2706            </meta:user-defined>
2707            <meta:user-defined meta:name="Company">
2708                <xsl:value-of select="o:Company"/>
2709            </meta:user-defined>
2710            <meta:user-defined meta:name="Version">
2711                <xsl:value-of select="o:Version"/>
2712            </meta:user-defined>
2713            <meta:user-defined meta:name="HyperlinkBase">
2714                <xsl:value-of select="o:HyperlinkBase"/>
2715            </meta:user-defined>
2716            <xsl:apply-templates select="../o:CustomDocumentProperties"/>
2717            <meta:document-statistic meta:page-count="{o:Pages}" meta:paragraph-count="{o:Paragraphs}" meta:word-count="{o:Words}" meta:character-count="{o:Characters}"/>
2718        </office:meta>
2719    </xsl:template>
2720    <xsl:template match="o:CustomDocumentProperties">
2721        <xsl:for-each select="node()[@dt:dt]">
2722            <meta:user-defined meta:name="{local-name()}">
2723                <xsl:value-of select="."/>
2724            </meta:user-defined>
2725        </xsl:for-each>
2726    </xsl:template>
2727<!-- End of OOo2.0 import/common/ms2ooo_docpr.xsl stylesheet  -->
2728<!-- Start of OOo2.0 common/measure_conversion.xsl stylesheet  -->
2729    <!-- DPI (dots per inch) the standard resolution of given pictures (necessary for the conversion of 'cm' into 'pixel')
2730         Although many pictures have a 96 dpi resolution, a higher resoltion give better results for common browsers -->
2731    <xsl:param name="dpi" select="111"/>
2732    <xsl:param name="centimeter-in-mm" select="10"/>
2733    <xsl:param name="inch-in-mm" select="25.4"/>
2734    <xsl:param name="didot-point-in-mm" select="0.376065"/>
2735    <xsl:param name="pica-in-mm" select="4.2333333"/>
2736    <xsl:param name="point-in-mm" select="0.3527778"/>
2737    <xsl:param name="twip-in-mm" select="0.017636684"/>
2738    <xsl:param name="pixel-in-mm" select="$inch-in-mm div $dpi"/>
2739    <!-- ***** MEASUREMENT CONVERSIONS *****
2740      PARAM 'value'
2741        The measure to be converted.
2742        The current measure is judged by a substring (e.g. 'mm', 'cm', 'in', 'pica'...)
2743        directly added to the number.
2744
2745      PARAM 'rounding-factor'
2746        Is used for the rounding of decimal places.
2747        The parameter number is the product of 1 and some '10', where
2748        every zero represents a decimal place.
2749
2750        For example, providing as parameter:
2751            <xsl:param name="rounding-factor" select="10000" />
2752        Gives by default four decimal places.
2753
2754        To round two decimal places, basically the following is done:
2755            <xsl:value-of select="round(100 * value) div 100"/>
2756
2757      RETURN    The converted number, by default rounded to four decimal places.
2758                In case the input measure could not be matched the same value is
2759                returned and a warning message is written out.
2760
2761
2762
2763     MEASURE LIST:
2764     * 1 milimeter (mm), the basic measure
2765
2766     * 1 centimeter (cm) = 10 mm
2767
2768     * 1 inch (in) = 25.4 mm
2769        While the English have already seen the light (read: the metric system), the US
2770        remains loyal to this medieval system.
2771
2772     * 1 point (pt) = 0.35277777.. mm
2773        Sometimes called PostScript point (ppt), as when Adobe created PostScript, they added their own system of points.
2774        There are exactly 72 PostScript points in 1 inch.
2775
2776     * 1 twip = twentieth of a (PostScript) point
2777        A twip (twentieth of a point) is a 1/20th of a PostScript point, a traditional measure in printing.
2778
2779     * 1 didot point (dpt) = 0.376065 mm
2780        Didot point after the French typographer Firmin Didot (1764-1836).
2781
2782        More details under
2783        http://www.unc.edu/~rowlett/units/dictP.html:
2784        "A unit of length used by typographers and printers. When printing was done
2785        from hand-set metal type, one point represented the smallest element of type
2786        that could be handled, roughly 1/64 inch. Eventually, the point was standardized
2787        in Britain and America as exactly 1/72.27 = 0.013 837 inch, which is
2788        about 0.35 mm (351.46 micrometers). In continental Europe, typographers
2789        traditionally used a slightly larger point of 0.014 83 inch (about
2790        1/72 pouce, 0.377 mm, or roughly 1/67 English inch), called a Didot point
2791        after the French typographer Firmin Didot (1764-1836). In the U.S.,
2792        Adobe software defines the point to be exactly 1/72 inch (0.013 888 9 inch
2793        or 0.352 777 8 millimeters) and TeX software uses a slightly smaller point
2794        of 0.351 459 8035 mm. The German standards agency DIN has proposed that
2795        all these units be replaced by multiples of 0.25 millimeters (1/101.6 inch).
2796
2797     * 1 pica = 4.233333 mm
2798        1/6 inch or 12 points
2799
2800     * 1 pixel (px) = 0.26458333.. mm   (relative to 'DPI', here: 96 dpi)
2801        Most pictures have the 96 dpi resolution, but the dpi variable may vary by stylesheet parameter
2802
2803
2804    -->
2805    <!-- changing measure to mm -->
2806    <xsl:template name="convert2mm">
2807        <xsl:param name="value"/>
2808        <xsl:param name="rounding-factor" select="10000"/>
2809        <xsl:choose>
2810            <xsl:when test="contains($value, 'mm')">
2811                <xsl:value-of select="substring-before($value, 'mm')"/>
2812            </xsl:when>
2813            <xsl:when test="contains($value, 'cm')">
2814                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm' ) * $centimeter-in-mm)) div $rounding-factor"/>
2815            </xsl:when>
2816            <xsl:when test="contains($value, 'in')">
2817                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in' ) * $inch-in-mm)) div $rounding-factor"/>
2818            </xsl:when>
2819            <xsl:when test="contains($value, 'pt')">
2820                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') * $point-in-mm)) div $rounding-factor"/>
2821            </xsl:when>
2822            <xsl:when test="contains($value, 'twip')">
2823                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') * $twip-in-mm)) div $rounding-factor"/>
2824            </xsl:when>
2825            <xsl:when test="contains($value, 'dxa')">
2826                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dxa') * $twip-in-mm)) div $rounding-factor"/>
2827            </xsl:when>
2828
2829            <xsl:when test="contains($value, 'dpt')">
2830                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') * $didot-point-in-mm)) div $rounding-factor"/>
2831            </xsl:when>
2832            <xsl:when test="contains($value, 'pica')">
2833                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') * $pica-in-mm)) div $rounding-factor"/>
2834            </xsl:when>
2835            <xsl:when test="contains($value, 'px')">
2836                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') * $pixel-in-mm)) div $rounding-factor"/>
2837            </xsl:when>
2838            <xsl:otherwise>
2839                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'mm'!</xsl:message>
2840                <xsl:value-of select="$value"/>
2841            </xsl:otherwise>
2842        </xsl:choose>
2843    </xsl:template>
2844    <!-- changing measure to cm -->
2845    <xsl:template name="convert2cm">
2846        <xsl:param name="value"/>
2847        <xsl:param name="rounding-factor" select="10000"/>
2848        <xsl:choose>
2849            <xsl:when test="contains($value, 'mm')">
2850                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $centimeter-in-mm)) div $rounding-factor"/>
2851            </xsl:when>
2852            <xsl:when test="contains($value, 'cm')">
2853                <xsl:value-of select="substring-before($value, 'cm')"/>
2854            </xsl:when>
2855            <xsl:when test="contains($value, 'in')">
2856                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $centimeter-in-mm * $inch-in-mm)) div $rounding-factor"/>
2857            </xsl:when>
2858            <xsl:when test="contains($value, 'pt')">
2859                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $centimeter-in-mm * $point-in-mm)) div $rounding-factor"/>
2860            </xsl:when>
2861            <xsl:when test="contains($value, 'dpt')">
2862                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $centimeter-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
2863            </xsl:when>
2864            <xsl:when test="contains($value, 'pica')">
2865                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $centimeter-in-mm * $pica-in-mm)) div $rounding-factor"/>
2866            </xsl:when>
2867            <xsl:when test="contains($value, 'twip')">
2868                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $centimeter-in-mm * $twip-in-mm)) div $rounding-factor"/>
2869            </xsl:when>
2870             <xsl:when test="contains($value, 'dxa')">
2871                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dxa') div $centimeter-in-mm * $twip-in-mm)) div $rounding-factor"/>
2872            </xsl:when>
2873
2874            <xsl:when test="contains($value, 'px')">
2875                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $centimeter-in-mm * $pixel-in-mm)) div $rounding-factor"/>
2876            </xsl:when>
2877            <xsl:otherwise>
2878                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'cm'!</xsl:message>
2879                <xsl:value-of select="$value"/>
2880            </xsl:otherwise>
2881        </xsl:choose>
2882    </xsl:template>
2883    <!-- changing measure to inch (cp. section comment) -->
2884    <xsl:template name="convert2in">
2885        <xsl:param name="value"/>
2886        <xsl:param name="rounding-factor" select="10000"/>
2887        <xsl:choose>
2888            <xsl:when test="contains($value, 'mm')">
2889                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $inch-in-mm)) div $rounding-factor"/>
2890            </xsl:when>
2891            <xsl:when test="contains($value, 'cm')">
2892                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $inch-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
2893            </xsl:when>
2894            <xsl:when test="contains($value, 'in')">
2895                <xsl:value-of select="substring-before($value, 'in')"/>
2896            </xsl:when>
2897            <xsl:when test="contains($value, 'pt')">
2898                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $inch-in-mm * $point-in-mm)) div $rounding-factor"/>
2899            </xsl:when>
2900            <xsl:when test="contains($value, 'dpt')">
2901                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $inch-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
2902            </xsl:when>
2903            <xsl:when test="contains($value, 'pica')">
2904                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $inch-in-mm * $pica-in-mm)) div $rounding-factor"/>
2905            </xsl:when>
2906            <xsl:when test="contains($value, 'twip')">
2907                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $inch-in-mm * $twip-in-mm)) div $rounding-factor"/>
2908            </xsl:when>
2909             <xsl:when test="contains($value, 'dxa')">
2910                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dxa') div $inch-in-mm * $twip-in-mm)) div $rounding-factor"/>
2911            </xsl:when>
2912
2913            <xsl:when test="contains($value, 'px')">
2914                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $inch-in-mm * $pixel-in-mm)) div $rounding-factor"/>
2915            </xsl:when>
2916            <xsl:otherwise>
2917                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'in'!</xsl:message>
2918                <xsl:value-of select="$value"/>
2919            </xsl:otherwise>
2920        </xsl:choose>
2921    </xsl:template>
2922    <!-- changing measure to dpt (cp. section comment) -->
2923    <xsl:template name="convert2dpt">
2924        <xsl:param name="value"/>
2925        <xsl:param name="rounding-factor" select="10000"/>
2926        <xsl:choose>
2927            <xsl:when test="contains($value, 'mm')">
2928                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $didot-point-in-mm)) div $rounding-factor"/>
2929            </xsl:when>
2930            <xsl:when test="contains($value, 'cm')">
2931                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $didot-point-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
2932            </xsl:when>
2933            <xsl:when test="contains($value, 'in')">
2934                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $didot-point-in-mm * $inch-in-mm)) div $rounding-factor"/>
2935            </xsl:when>
2936            <xsl:when test="contains($value, 'pt')">
2937                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $didot-point-in-mm * $point-in-mm)) div $rounding-factor"/>
2938            </xsl:when>
2939            <xsl:when test="contains($value, 'dpt')">
2940                <xsl:value-of select="substring-before($value, 'dpt')"/>
2941            </xsl:when>
2942            <xsl:when test="contains($value, 'pica')">
2943                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $didot-point-in-mm * $pica-in-mm)) div $rounding-factor"/>
2944            </xsl:when>
2945            <xsl:when test="contains($value, 'twip')">
2946                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $didot-point-in-mm * $twip-in-mm)) div $rounding-factor"/>
2947            </xsl:when>
2948             <xsl:when test="contains($value, 'dxa')">
2949                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dxa') div $didot-point-in-mm * $twip-in-mm)) div $rounding-factor"/>
2950            </xsl:when>
2951
2952            <xsl:when test="contains($value, 'px')">
2953                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $didot-point-in-mm * $pixel-in-mm)) div $rounding-factor"/>
2954            </xsl:when>
2955            <xsl:otherwise>
2956                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'dpt'!</xsl:message>
2957                <xsl:value-of select="$value"/>
2958            </xsl:otherwise>
2959        </xsl:choose>
2960    </xsl:template>
2961    <!-- changing measure to pica (cp. section comment) -->
2962    <xsl:template name="convert2pica">
2963        <xsl:param name="value"/>
2964        <xsl:param name="rounding-factor" select="10000"/>
2965        <xsl:choose>
2966            <xsl:when test="contains($value, 'mm')">
2967                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $pica-in-mm)) div $rounding-factor"/>
2968            </xsl:when>
2969            <xsl:when test="contains($value, 'cm')">
2970                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $pica-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
2971            </xsl:when>
2972            <xsl:when test="contains($value, 'in')">
2973                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $pica-in-mm * $inch-in-mm)) div $rounding-factor"/>
2974            </xsl:when>
2975            <xsl:when test="contains($value, 'pt')">
2976                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $pica-in-mm * $point-in-mm)) div $rounding-factor"/>
2977            </xsl:when>
2978            <xsl:when test="contains($value, 'dpt')">
2979                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $pica-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
2980            </xsl:when>
2981            <xsl:when test="contains($value, 'pica')">
2982                <xsl:value-of select="substring-before($value, 'pica')"/>
2983            </xsl:when>
2984            <xsl:when test="contains($value, 'twip')">
2985                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $pica-in-mm * $twip-in-mm)) div $rounding-factor"/>
2986            </xsl:when>
2987             <xsl:when test="contains($value, 'dxa')">
2988                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dxa') div $pica-in-mm * $twip-in-mm)) div $rounding-factor"/>
2989            </xsl:when>
2990
2991            <xsl:when test="contains($value, 'px')">
2992                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $pica-in-mm * $pixel-in-mm)) div $rounding-factor"/>
2993            </xsl:when>
2994            <xsl:otherwise>
2995                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'pica'!</xsl:message>
2996                <xsl:value-of select="$value"/>
2997            </xsl:otherwise>
2998        </xsl:choose>
2999    </xsl:template>
3000    <!-- changing measure to pt (cp. section comment) -->
3001    <xsl:template name="convert2pt">
3002        <xsl:param name="value"/>
3003        <xsl:param name="rounding-factor" select="10000"/>
3004        <xsl:choose>
3005            <xsl:when test="contains($value, 'mm')">
3006                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $point-in-mm)) div $rounding-factor"/>
3007            </xsl:when>
3008            <xsl:when test="contains($value, 'cm')">
3009                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $point-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
3010            </xsl:when>
3011            <xsl:when test="contains($value, 'in')">
3012                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $point-in-mm * $inch-in-mm)) div $rounding-factor"/>
3013            </xsl:when>
3014            <xsl:when test="contains($value, 'pt')">
3015                <xsl:value-of select="substring-before($value, 'pt')"/>
3016            </xsl:when>
3017            <xsl:when test="contains($value, 'dpt')">
3018                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $point-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
3019            </xsl:when>
3020            <xsl:when test="contains($value, 'pica')">
3021                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $point-in-mm * $pica-in-mm)) div $rounding-factor"/>
3022            </xsl:when>
3023            <xsl:when test="contains($value, 'twip')">
3024                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $point-in-mm * $twip-in-mm)) div $rounding-factor"/>
3025            </xsl:when>
3026             <xsl:when test="contains($value, 'dxa')">
3027                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dxa') div $point-in-mm * $twip-in-mm)) div $rounding-factor"/>
3028            </xsl:when>
3029
3030            <xsl:when test="contains($value, 'px')">
3031                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $point-in-mm * $pixel-in-mm)) div $rounding-factor"/>
3032            </xsl:when>
3033            <xsl:otherwise>
3034                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'pt'!</xsl:message>
3035                <xsl:value-of select="$value"/>
3036            </xsl:otherwise>
3037        </xsl:choose>
3038    </xsl:template>
3039    <!-- changing measure to pt (cp. section comment) -->
3040    <xsl:template name="convert2twip">
3041        <xsl:param name="value"/>
3042        <xsl:param name="rounding-factor" select="10000"/>
3043        <xsl:choose>
3044            <xsl:when test="contains($value, 'mm')">
3045                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $twip-in-mm)) div $rounding-factor"/>
3046            </xsl:when>
3047            <xsl:when test="contains($value, 'cm')">
3048                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $twip-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
3049            </xsl:when>
3050            <xsl:when test="contains($value, 'in')">
3051                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $twip-in-mm * $inch-in-mm)) div $rounding-factor"/>
3052            </xsl:when>
3053            <xsl:when test="contains($value, 'pt')">
3054                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $twip-in-mm * $point-in-mm)) div $rounding-factor"/>
3055            </xsl:when>
3056            <xsl:when test="contains($value, 'dpt')">
3057                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $twip-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
3058            </xsl:when>
3059            <xsl:when test="contains($value, 'pica')">
3060                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $twip-in-mm * $pica-in-mm)) div $rounding-factor"/>
3061            </xsl:when>
3062            <xsl:when test="contains($value, 'twip')">
3063                <xsl:value-of select="substring-before($value, 'twip')"/>
3064            </xsl:when>
3065            <xsl:when test="contains($value, 'dxa')">
3066                <xsl:value-of select="substring-before($value, 'dxa')"/>
3067            </xsl:when>
3068
3069            <xsl:when test="contains($value, 'px')">
3070                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $twip-in-mm * $pixel-in-mm)) div $rounding-factor"/>
3071            </xsl:when>
3072            <xsl:otherwise>
3073                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'twip'!</xsl:message>
3074                <xsl:value-of select="$value"/>
3075            </xsl:otherwise>
3076        </xsl:choose>
3077    </xsl:template>
3078    <!-- changing measure to pixel by via parameter provided dpi (dots per inch) standard factor (cp. section comment) -->
3079    <xsl:template name="convert2px">
3080        <xsl:param name="value"/>
3081        <xsl:choose>
3082            <xsl:when test="contains($value, 'mm')">
3083                <xsl:value-of select="round(number(substring-before($value, 'mm')) div $pixel-in-mm)"/>
3084            </xsl:when>
3085            <xsl:when test="contains($value, 'cm')">
3086                <xsl:value-of select="round(number(substring-before($value, 'cm')) div $pixel-in-mm * $centimeter-in-mm)"/>
3087            </xsl:when>
3088            <xsl:when test="contains($value, 'in')">
3089                <xsl:value-of select="round(number(substring-before($value, 'in')) div $pixel-in-mm * $inch-in-mm)"/>
3090            </xsl:when>
3091            <xsl:when test="contains($value, 'pt')">
3092                <xsl:value-of select="round(number(substring-before($value, 'pt')) div $pixel-in-mm * $point-in-mm)"/>
3093            </xsl:when>
3094            <xsl:when test="contains($value, 'dpt')">
3095                <xsl:value-of select="round(number(substring-before($value, 'dpt')) div $pixel-in-mm * $didot-point-in-mm)"/>
3096            </xsl:when>
3097            <xsl:when test="contains($value, 'pica')">
3098                <xsl:value-of select="round(number(substring-before($value, 'pica')) div $pixel-in-mm * $pica-in-mm)"/>
3099            </xsl:when>
3100            <xsl:when test="contains($value, 'twip')">
3101                <xsl:value-of select="round(number(substring-before($value, 'twip')) div $pixel-in-mm * $twip-in-mm)"/>
3102            </xsl:when>
3103            <xsl:when test="contains($value, 'dxa')">
3104                <xsl:value-of select="round(number(substring-before($value, 'dxa')) div $pixel-in-mm * $twip-in-mm)"/>
3105            </xsl:when>
3106
3107            <xsl:when test="contains($value, 'px')">
3108                <xsl:value-of select="$value"/>
3109            </xsl:when>
3110            <xsl:otherwise>
3111                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'px'!</xsl:message>
3112                <xsl:value-of select="$value"/>
3113            </xsl:otherwise>
3114        </xsl:choose>
3115    </xsl:template>
3116        <xsl:template name="convert2dxa">
3117        <!-- this template is the same as the template of convert2twip because M$ word uses the dxa to represent twip-->
3118        <xsl:param name="value"/>
3119        <xsl:param name="rounding-factor" select="10000"/>
3120        <xsl:choose>
3121            <xsl:when test="contains($value, 'mm')">
3122                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $twip-in-mm)) div $rounding-factor"/>
3123            </xsl:when>
3124            <xsl:when test="contains($value, 'cm')">
3125                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $twip-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
3126            </xsl:when>
3127            <xsl:when test="contains($value, 'in')">
3128                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $twip-in-mm * $inch-in-mm)) div $rounding-factor"/>
3129            </xsl:when>
3130            <xsl:when test="contains($value, 'pt')">
3131                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $twip-in-mm * $point-in-mm)) div $rounding-factor"/>
3132            </xsl:when>
3133            <xsl:when test="contains($value, 'dpt')">
3134                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $twip-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
3135            </xsl:when>
3136            <xsl:when test="contains($value, 'pica')">
3137                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $twip-in-mm * $pica-in-mm)) div $rounding-factor"/>
3138            </xsl:when>
3139            <xsl:when test="contains($value, 'twip')">
3140                <xsl:value-of select="substring-before($value, 'twip')"/>
3141            </xsl:when>
3142            <xsl:when test="contains($value, 'dxa')">
3143                <xsl:value-of select="substring-before($value, 'dxa')"/>
3144            </xsl:when>
3145
3146            <xsl:when test="contains($value, 'px')">
3147                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $twip-in-mm * $pixel-in-mm)) div $rounding-factor"/>
3148            </xsl:when>
3149            <xsl:otherwise>
3150                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'twip'!</xsl:message>
3151                <xsl:value-of select="$value"/>
3152            </xsl:otherwise>
3153        </xsl:choose>
3154    </xsl:template>
3155<!-- End of OOo2.0 common/measure_conversion.xsl stylesheet  -->
3156</xsl:stylesheet>
3157