/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to xml.files/odt/export/common/table_of_content.xsl

  • Committer: Suren A. Chilingaryan
  • Date: 2009-02-16 09:27:17 UTC
  • Revision ID: csa@dside.dyndns.org-20090216092717-wipyvaaw2srxhgns
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
<!--
 
3
 
 
4
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
5
  
 
6
  Copyright 2008 by Sun Microsystems, Inc.
 
7
 
 
8
  OpenOffice.org - a multi-platform office productivity suite
 
9
 
 
10
  $RCSfile: table_of_content.xsl,v $
 
11
 
 
12
  $Revision: 1.2.62.1 $
 
13
 
 
14
  This file is part of OpenOffice.org.
 
15
 
 
16
  OpenOffice.org is free software: you can redistribute it and/or modify
 
17
  it under the terms of the GNU Lesser General Public License version 3
 
18
  only, as published by the Free Software Foundation.
 
19
 
 
20
  OpenOffice.org is distributed in the hope that it will be useful,
 
21
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
  GNU Lesser General Public License version 3 for more details
 
24
  (a copy is included in the LICENSE file that accompanied this code).
 
25
 
 
26
  You should have received a copy of the GNU Lesser General Public License
 
27
  version 3 along with OpenOffice.org.  If not, see
 
28
  <http://www.openoffice.org/license.html>
 
29
  for a copy of the LGPLv3 License.
 
30
 
 
31
-->
 
32
<!--
 
33
        For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
 
34
-->
 
35
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://xml.apache.org/xslt/java" xmlns:sxg="http://www.jclark.com/xt/java/org.openoffice.xslt.OOoMasterDocument" xmlns:common="http://exslt.org/common" xmlns:xt="http://www.jclark.com/xt" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xforms xlink xsd xsi java sxg xt common xalan">
 
36
 
 
37
        <!-- ****************************** -->
 
38
        <!-- ***    Table of Content    *** -->
 
39
        <!-- ****************************** -->
 
40
 
 
41
        <xsl:param name="currentChildContentRef" />
 
42
        <xsl:param name="contentTableHeadings" />
 
43
        <xsl:param name="contentTableURL" />
 
44
        <xsl:template match="text:table-of-content">
 
45
                <xsl:param name="globalData"/>
 
46
 
 
47
                <xsl:apply-templates>
 
48
                        <xsl:with-param name="globalData" select="$globalData"/>
 
49
                </xsl:apply-templates>
 
50
        </xsl:template>
 
51
 
 
52
 
 
53
        <xsl:template match="text:index-body">
 
54
                <xsl:param name="globalData"/>
 
55
 
 
56
                <xsl:choose>
 
57
                        <xsl:when test="*/text:tab">
 
58
                                <xsl:call-template name="createIndexBodyTable">
 
59
                                        <xsl:with-param name="globalData" select="$globalData"/>
 
60
                                </xsl:call-template>
 
61
                        </xsl:when>
 
62
                        <xsl:otherwise>
 
63
                                <xsl:apply-templates>
 
64
                                        <xsl:with-param name="globalData" select="$globalData"/>
 
65
                                </xsl:apply-templates>
 
66
                        </xsl:otherwise>
 
67
                </xsl:choose>
 
68
        </xsl:template>
 
69
 
 
70
        <xsl:template match="text:index-title" mode="content-table">
 
71
                <xsl:param name="globalData"/>
 
72
 
 
73
                <xsl:apply-templates>
 
74
                        <xsl:with-param name="globalData" select="$globalData"/>
 
75
                </xsl:apply-templates>
 
76
        </xsl:template>
 
77
 
 
78
        <xsl:template name="createIndexBodyTable">
 
79
                <xsl:param name="globalData"/>
 
80
                <xsl:variable name="allStyleTabStops-RTF">
 
81
                        <xsl:element name="style:tab-stops">
 
82
                                <xsl:call-template name="get-tab-stops">
 
83
                                        <xsl:with-param name="globalData" select="$globalData"/>
 
84
                                        <xsl:with-param name="styleName" select="current()/@text:style-name"/>
 
85
 
 
86
                                        <!--
 
87
                                        Currently only the style of text:index-body is recognized, but not of a paragraph child containing the text:tab element!
 
88
                                        <xsl:with-param name="styleName" select="descendant-or-self::*/@text:style-name"/>
 
89
 
 
90
                                        The column width needs to be tabstop plus fo:margin-left paragraph-properties
 
91
                                         -->
 
92
                                </xsl:call-template>
 
93
                        </xsl:element>
 
94
                </xsl:variable>
 
95
                <xsl:element namespace="{$namespace}" name="table">
 
96
 
 
97
                        <xsl:attribute name="border">0</xsl:attribute>
 
98
                        <xsl:attribute name="cellspacing">0</xsl:attribute>
 
99
                        <xsl:attribute name="cellpadding">0</xsl:attribute>
 
100
                        <xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:rel-width"/>
 
101
                        <xsl:if test="$value">
 
102
                                <xsl:attribute name="width">
 
103
                                        <xsl:value-of select="$value"/>
 
104
                                </xsl:attribute>
 
105
                        </xsl:if>
 
106
                        <xsl:attribute name="class">
 
107
                                <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
 
108
                        </xsl:attribute>
 
109
 
 
110
                        <xsl:element namespace="{$namespace}" name="colgroup">
 
111
                                <xsl:choose>
 
112
                                        <xsl:when test="function-available('common:node-set')">
 
113
                                                <xsl:call-template name="create-col-element">
 
114
                                                        <xsl:with-param name="lastNodePosition" select="count(common:node-set($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/>
 
115
                                                        <xsl:with-param name="allStyleTabStops" select="common:node-set($allStyleTabStops-RTF)"/>
 
116
                                                </xsl:call-template>
 
117
                                        </xsl:when>
 
118
                                        <xsl:when test="function-available('xalan:nodeset')">
 
119
                                                <xsl:call-template name="create-col-element">
 
120
                                                        <xsl:with-param name="lastNodePosition" select="count(xalan:nodeset($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/>
 
121
                                                        <xsl:with-param name="allStyleTabStops" select="xalan:nodeset($allStyleTabStops-RTF)"/>
 
122
                                                </xsl:call-template>
 
123
                                        </xsl:when>
 
124
                                        <xsl:when test="function-available('xt:node-set')">
 
125
                                                <xsl:call-template name="create-col-element">
 
126
                                                        <xsl:with-param name="lastNodePosition" select="count(xt:node-set($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/>
 
127
                                                        <xsl:with-param name="allStyleTabStops" select="xt:node-set($allStyleTabStops-RTF)"/>
 
128
                                                </xsl:call-template>
 
129
                                        </xsl:when>
 
130
                                        <xsl:otherwise>
 
131
                                                <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
 
132
                                        </xsl:otherwise>
 
133
                                </xsl:choose>
 
134
                        </xsl:element>
 
135
 
 
136
                        <!-- add table data -->
 
137
                        <xsl:choose>
 
138
                                <xsl:when test="function-available('common:node-set')">
 
139
                                        <xsl:apply-templates mode="content-table">
 
140
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
141
                                                <xsl:with-param name="allStyleTabStops" select="common:node-set($allStyleTabStops-RTF)"/>
 
142
                                        </xsl:apply-templates>
 
143
                                </xsl:when>
 
144
                                <xsl:when test="function-available('xalan:nodeset')">
 
145
                                        <xsl:apply-templates mode="content-table">
 
146
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
147
                                                <xsl:with-param name="allStyleTabStops" select="xalan:nodeset($allStyleTabStops-RTF)"/>
 
148
                                        </xsl:apply-templates>
 
149
                                </xsl:when>
 
150
                                <xsl:when test="function-available('xt:node-set')">
 
151
                                        <xsl:apply-templates mode="content-table">
 
152
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
153
                                                <xsl:with-param name="allStyleTabStops" select="xt:node-set($allStyleTabStops-RTF)"/>
 
154
                                        </xsl:apply-templates>
 
155
                                </xsl:when>
 
156
                                <xsl:otherwise>
 
157
                                        <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
 
158
                                </xsl:otherwise>
 
159
                        </xsl:choose>
 
160
 
 
161
                </xsl:element>
 
162
        </xsl:template>
 
163
 
 
164
 
 
165
        <!-- ************************************************ -->
 
166
        <!-- *** Create Table for Content Table Paragraph *** -->
 
167
        <!-- ************************************************ -->
 
168
 
 
169
        <!-- Usually the paragraph in a content-table are ordered by tab-stops, which can not be displayed correctly by XHTML/CSS
 
170
         Therefore they will be simulated by a table -->
 
171
        <xsl:template match="text:p" mode="content-table">
 
172
                <xsl:param name="globalData"/>
 
173
                <xsl:param name="allStyleTabStops"/>
 
174
 
 
175
                        <!-- all elements before the first tabStop -->
 
176
                <xsl:variable name="testNo-RTF">
 
177
                        <xsl:apply-templates select="node()" mode="cell-content"/>
 
178
                </xsl:variable>
 
179
 
 
180
                <xsl:choose>
 
181
                        <xsl:when test="function-available('common:node-set')">
 
182
                                <xsl:variable name="tabNodePositions" select="common:node-set($testNo-RTF)"/>
 
183
                                <xsl:element namespace="{$namespace}" name="tr">
 
184
                                        <xsl:call-template name="create-td-elements">
 
185
                                                <xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/>
 
186
                                                <xsl:with-param name="position" select="1"/>
 
187
                                                <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
 
188
                                                <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
 
189
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
190
                                        </xsl:call-template>
 
191
                                </xsl:element>
 
192
                        </xsl:when>
 
193
                        <xsl:when test="function-available('xalan:nodeset')">
 
194
                                <xsl:variable name="tabNodePositions" select="xalan:nodeset($testNo-RTF)"/>
 
195
                                <xsl:element namespace="{$namespace}" name="tr">
 
196
                                        <xsl:call-template name="create-td-elements">
 
197
                                                <xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/>
 
198
                                                <xsl:with-param name="position" select="1"/>
 
199
                                                <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
 
200
                                                <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
 
201
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
202
                                        </xsl:call-template>
 
203
                                </xsl:element>
 
204
                        </xsl:when>
 
205
                        <xsl:when test="function-available('xt:node-set')">
 
206
                                <xsl:variable name="tabNodePositions" select="xt:node-set($testNo-RTF)"/>
 
207
                                <xsl:element namespace="{$namespace}" name="tr">
 
208
                                        <xsl:call-template name="create-td-elements">
 
209
                                                <xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/>
 
210
                                                <xsl:with-param name="position" select="1"/>
 
211
                                                <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
 
212
                                                <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
 
213
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
214
                                        </xsl:call-template>
 
215
                                </xsl:element>
 
216
                        </xsl:when>
 
217
                        <xsl:otherwise>
 
218
                                <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
 
219
                        </xsl:otherwise>
 
220
                </xsl:choose>
 
221
        </xsl:template>
 
222
 
 
223
        <!-- Gathering all style:tab-stops from a style-hierarchy as siblings -->
 
224
        <xsl:template name="get-tab-stops">
 
225
                <xsl:param name="globalData"/>
 
226
                <xsl:param name="styleName"/>
 
227
                <xsl:variable name="tabStyle" select="key('styles', $styleName)"/>
 
228
 
 
229
                <xsl:if test="$tabStyle/*/style:tab-stops/style:tab-stop/@style:position">
 
230
                        <xsl:for-each select="$tabStyle/*/style:tab-stops/style:tab-stop">
 
231
                                <xsl:copy-of select="."/>
 
232
                        </xsl:for-each>
 
233
                </xsl:if>
 
234
 
 
235
                <xsl:if test="$tabStyle/@style:parent-style-name">
 
236
                        <xsl:call-template name="get-tab-stops">
 
237
                                <xsl:with-param name="globalData" select="$globalData"/>
 
238
                                <xsl:with-param name="styleName" select="$tabStyle/@style:parent-style-name"/>
 
239
                        </xsl:call-template>
 
240
                </xsl:if>
 
241
        </xsl:template>
 
242
 
 
243
        <xsl:template name="create-col-element">
 
244
                <xsl:param name="lastNodePosition"/>
 
245
                <xsl:param name="allStyleTabStops"/>
 
246
 
 
247
                <xsl:for-each select="$allStyleTabStops/style:tab-stops/style:tab-stop">
 
248
                        <xsl:element namespace="{$namespace}" name="col">
 
249
                                <xsl:attribute name="style">
 
250
                                        <xsl:text>width: </xsl:text>
 
251
                                        <xsl:choose>
 
252
                                                <xsl:when test="contains(@style:position, 'cm')">
 
253
                                                        <xsl:call-template name="create-cell-width">
 
254
                                                                <xsl:with-param name="width" select="number(substring-before(@style:position,'cm'))"/>
 
255
                                                                <xsl:with-param name="unit" select="'cm'"/>
 
256
                                                                <xsl:with-param name="position" select="position() - 1"/>
 
257
                                                                <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
 
258
                                                        </xsl:call-template>
 
259
                                                </xsl:when>
 
260
                                                <xsl:when test="contains(@style:position, 'in')">
 
261
                                                        <xsl:call-template name="create-cell-width">
 
262
                                                                <xsl:with-param name="width" select="number(substring-before(@style:position,'in'))"/>
 
263
                                                                <xsl:with-param name="unit" select="'in'"/>
 
264
                                                                <xsl:with-param name="position" select="position() - 1"/>
 
265
                                                                <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
 
266
                                                        </xsl:call-template>
 
267
                                                </xsl:when>
 
268
                                                <xsl:when test="contains(@style:position, 'ch')">
 
269
                                                        <xsl:call-template name="create-cell-width">
 
270
                                                                <xsl:with-param name="width" select="number(substring-before(@style:position,'ch'))"/>
 
271
                                                                <xsl:with-param name="unit" select="'ch'"/>
 
272
                                                                <xsl:with-param name="position" select="position() - 1"/>
 
273
                                                                <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
 
274
                                                        </xsl:call-template>
 
275
                                                </xsl:when>
 
276
                                                <xsl:when test="contains(@style:position, 'pt')">
 
277
                                                        <xsl:call-template name="create-cell-width">
 
278
                                                                <xsl:with-param name="width" select="number(substring-before(@style:position,'pt'))"/>
 
279
                                                                <xsl:with-param name="unit" select="'pt'"/>
 
280
                                                                <xsl:with-param name="position" select="position() - 1"/>
 
281
                                                                <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
 
282
                                                        </xsl:call-template>
 
283
                                                </xsl:when>
 
284
                                        </xsl:choose>
 
285
 
 
286
                                </xsl:attribute>
 
287
                        </xsl:element>
 
288
                </xsl:for-each>
 
289
 
 
290
        </xsl:template>
 
291
<!--
 
292
Scenarios tabstops
 
293
 
 
294
1) style:type of style:tab-stop is 'right' and earlier tabStop is not right
 
295
 -> Earlier text-nodes and following text-nodes, will be put into an inner table, with two TD first aligned left, with proceding textnodes, the latter aligned right.
 
296
 
 
297
2) style:type is 'right' and earlier tabStop is right
 
298
 -> following text-nodes, will be put into a right aligned TD
 
299
 
 
300
3) style:type is 'non-right' and earlier tabStop 'non-right' as well
 
301
 -> put the preceding tab stops into a TD (left aligned is default)
 
302
 
 
303
4) first style:type would have no right preceding tabStop
 
304
 -> works well with first sceanrios 1 and 3
 
305
 
 
306
5) last style:type would be a special case, if it would be left aligned, but this won't happen in our case.. :D
 
307
 
 
308
Scenarios unmatched:
 
309
- text:styleposition 'center' will not be matched in our case (effort for nothing), there will be only 'right' and not 'right'
 
310
- If the last tabStop is not from text:stylepostion 'right', the length of the last cell is undefined and a document length must be found.
 
311
  Not happens in our master document case. Also the algorithm below would have to be expanded (cp. scenario 5).
 
312
 
 
313
-->
 
314
        <xsl:template name="create-td-elements">
 
315
                <xsl:param name="globalData"/>
 
316
                <xsl:param name="lastNodePosition"/>
 
317
                <xsl:param name="position"/>
 
318
                <xsl:param name="allStyleTabStops"/>
 
319
                <xsl:param name="tabNodePositions"/>
 
320
 
 
321
                <xsl:variable name="currentTabStop" select="$allStyleTabStops/style:tab-stops/style:tab-stop[$position]"/>
 
322
                <xsl:variable name="earlierTabStop" select="$allStyleTabStops/style:tab-stops/style:tab-stop[$position - 1]"/>
 
323
                <xsl:choose>
 
324
                        <xsl:when test="not($currentTabStop/@style:position) and not($earlierTabStop/@style:position)">
 
325
                                <!-- in case no TAB STOP is being set -->
 
326
                                <xsl:element namespace="{$namespace}" name="td">
 
327
                                        <xsl:element namespace="{$namespace}" name="p">
 
328
                                                <xsl:if test="$position = 1">
 
329
                                                        <xsl:attribute name="class">
 
330
                                                                <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
 
331
                                                        </xsl:attribute>
 
332
                                                </xsl:if>
 
333
                                                <xsl:apply-templates mode="content-table">
 
334
                                                        <xsl:with-param name="globalData" select="$globalData"/>
 
335
                                                </xsl:apply-templates>
 
336
                                        </xsl:element>
 
337
                                </xsl:element>
 
338
                        </xsl:when>
 
339
                        <xsl:otherwise>
 
340
                                <xsl:choose>
 
341
                                        <xsl:when test="$currentTabStop/@style:type = 'right'">
 
342
                                                <xsl:choose>
 
343
                                                        <xsl:when test="$earlierTabStop/@style:type = 'right'">
 
344
                                                                <!--
 
345
                                                                2) style:type is 'right' and earlier tabStop is right
 
346
                                                                        -> following text-nodes, will be put into a right aligned TD -->
 
347
                                                                <xsl:element namespace="{$namespace}" name="td">
 
348
                                                                        <xsl:attribute name="style">
 
349
                                                                                <xsl:text>align: right</xsl:text>
 
350
                                                                        </xsl:attribute>
 
351
                                                                        <xsl:element namespace="{$namespace}" name="p">
 
352
                                                                                <xsl:if test="$position = 1">
 
353
                                                                                        <xsl:attribute name="class">
 
354
                                                                                                <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
 
355
                                                                                        </xsl:attribute>
 
356
                                                                                </xsl:if>
 
357
                                                                                <xsl:call-template name="grab-cell-content-before-tab-stop">
 
358
                                                                                        <xsl:with-param name="globalData" select="$globalData"/>
 
359
                                                                                        <xsl:with-param name="endingTabStopPosition" select="$position + 1"/>
 
360
                                                                                        <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
 
361
                                                                                        <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
 
362
                                                                                </xsl:call-template>
 
363
                                                                        </xsl:element>
 
364
                                                                </xsl:element>
 
365
                                                        </xsl:when>
 
366
                                                        <xsl:otherwise>
 
367
                                                                <xsl:element namespace="{$namespace}" name="td">
 
368
                                                                        <xsl:element namespace="{$namespace}" name="p">
 
369
                                                                                <xsl:if test="$position = 1">
 
370
                                                                                        <xsl:attribute name="class">
 
371
                                                                                                <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
 
372
                                                                                        </xsl:attribute>
 
373
                                                                                </xsl:if>
 
374
                                                                                <xsl:call-template name="grab-cell-content-before-tab-stop">
 
375
                                                                                        <xsl:with-param name="globalData" select="$globalData"/>
 
376
                                                                                        <xsl:with-param name="endingTabStopPosition" select="$position"/>
 
377
                                                                                        <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
 
378
                                                                                        <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
 
379
                                                                                </xsl:call-template>
 
380
                                                                        </xsl:element>
 
381
                                                                </xsl:element>
 
382
                                                        </xsl:otherwise>
 
383
                                                </xsl:choose>
 
384
                                        </xsl:when>
 
385
                                        <xsl:otherwise>
 
386
                                                <xsl:choose>
 
387
                                                        <xsl:when test="$earlierTabStop/@style:type = 'right'"></xsl:when>
 
388
                                                        <xsl:otherwise>
 
389
                                                        <!--
 
390
                                                           3) style:type is 'non-right' and earlier tabStop 'non-right' as well
 
391
                                                                        -> put the preceding tab stops into a TD (left aligned is default) -->
 
392
                                                                <xsl:element namespace="{$namespace}" name="p">
 
393
                                                                        <xsl:if test="$position = 1">
 
394
                                                                                <xsl:attribute name="class">
 
395
                                                                                        <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
 
396
                                                                                </xsl:attribute>
 
397
                                                                        </xsl:if>
 
398
                                                                        <xsl:element namespace="{$namespace}" name="td">
 
399
                                                                                <xsl:call-template name="grab-cell-content-before-tab-stop">
 
400
                                                                                        <xsl:with-param name="globalData" select="$globalData"/>
 
401
                                                                                        <xsl:with-param name="endingTabStopPosition" select="$position"/>
 
402
                                                                                        <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
 
403
                                                                                        <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
 
404
                                                                                </xsl:call-template>
 
405
                                                                        </xsl:element>
 
406
                                                                </xsl:element>
 
407
                                                        </xsl:otherwise>
 
408
                                                </xsl:choose>
 
409
                                        </xsl:otherwise>
 
410
                                </xsl:choose>
 
411
 
 
412
                                <xsl:if test="$position != $lastNodePosition">
 
413
                                        <xsl:call-template name="create-td-elements">
 
414
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
415
                                                <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
 
416
                                                <xsl:with-param name="position" select="$position + 1"/>
 
417
                                                <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
 
418
                                                <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
 
419
                                        </xsl:call-template>
 
420
                                </xsl:if>
 
421
                        </xsl:otherwise>
 
422
                </xsl:choose>
 
423
        </xsl:template>
 
424
 
 
425
        <xsl:template name="grab-cell-content-before-tab-stop">
 
426
                <xsl:param name="globalData"/>
 
427
                <xsl:param name="endingTabStopPosition"/>
 
428
                <xsl:param name="tabNodePositions"/>
 
429
                <xsl:param name="lastNodePosition"/>
 
430
 
 
431
                <xsl:choose>
 
432
                        <xsl:when test="$endingTabStopPosition = 1">
 
433
                                <xsl:apply-templates mode="content-table" select="node()[position() &lt; $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]]">
 
434
                                        <xsl:with-param name="globalData" select="$globalData"/>
 
435
                                </xsl:apply-templates>
 
436
                        </xsl:when>
 
437
                        <xsl:when test="$endingTabStopPosition > $lastNodePosition">
 
438
                                <xsl:apply-templates mode="content-table" select="node()[position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]">
 
439
                                        <xsl:with-param name="globalData" select="$globalData"/>
 
440
                                </xsl:apply-templates>
 
441
                        </xsl:when>
 
442
                        <xsl:otherwise>
 
443
                                <xsl:variable name="nodesOfNextColumn" select="node()[position() &lt; $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]][position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]"/>
 
444
                                <xsl:choose>
 
445
                                        <xsl:when test="$nodesOfNextColumn != ''">
 
446
                                                <xsl:apply-templates mode="content-table" select="$nodesOfNextColumn">
 
447
                                                        <xsl:with-param name="globalData" select="$globalData"/>
 
448
                                                </xsl:apply-templates>
 
449
                                        </xsl:when>
 
450
                                        <xsl:otherwise>
 
451
                                                <xsl:apply-templates mode="content-table">
 
452
                                                        <xsl:with-param name="globalData" select="$globalData"/>
 
453
                                                </xsl:apply-templates>
 
454
                                        </xsl:otherwise>
 
455
                                </xsl:choose>
 
456
                        </xsl:otherwise>
 
457
                </xsl:choose>
 
458
        </xsl:template>
 
459
 
 
460
        <!-- As the span width will be mapped to column width, the preceding span widths have to be substracted -->
 
461
        <xsl:template name="create-cell-width">
 
462
                <xsl:param name="width"/>
 
463
                <xsl:param name="unit"/>
 
464
                <xsl:param name="position"/>
 
465
                <xsl:param name="allStyleTabStops"/>
 
466
 
 
467
                <xsl:choose>
 
468
                        <!-- beyond second width -->
 
469
                        <xsl:when test="$position > 1">
 
470
                                <xsl:call-template name="create-cell-width">
 
471
                                        <xsl:with-param name="width" select="$width - number(substring-before($allStyleTabStops/style:tab-stops/style:tab-stop[$position]/@style:position,$unit))"/>
 
472
                                        <xsl:with-param name="unit" select="$unit"/>
 
473
                                        <xsl:with-param name="position" select="$position - 1"/>
 
474
                                        <xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
 
475
                                </xsl:call-template>
 
476
                        </xsl:when>
 
477
                        <!-- second width -->
 
478
                        <xsl:when test="$position = 1">
 
479
                                <xsl:value-of select="concat($width - number(substring-before($allStyleTabStops/style:tab-stops/style:tab-stop[$position]/@style:position,$unit)), $unit)"/>
 
480
                        </xsl:when>
 
481
                        <!-- first width -->
 
482
                        <xsl:otherwise>
 
483
                                <xsl:value-of select="concat($width, $unit)"/>
 
484
                        </xsl:otherwise>
 
485
                </xsl:choose>
 
486
        </xsl:template>
 
487
 
 
488
 
 
489
        <!-- ************************************** -->
 
490
        <!--    CREATION OF A CONTENT TABLE LINK    -->
 
491
        <!-- ************************************** -->
 
492
 
 
493
 
 
494
         <!-- content table link  -->
 
495
        <xsl:template match="text:a" mode="content-table">
 
496
                <xsl:param name="globalData"/>
 
497
 
 
498
                <xsl:choose>
 
499
                        <!-- heuristic assumption that first in a content table row, there is numbering (if at all) and than the text, furthermore that a tab will separate the to be neglected page number -->
 
500
                        <xsl:when test="text:tab">
 
501
                                <xsl:element namespace="{$namespace}" name="a">
 
502
                                        <xsl:attribute name="href">
 
503
                                                <xsl:text>#</xsl:text>
 
504
                                                <xsl:value-of select="translate(text()[1], '.,;: %()[]/\+', '_____________')"/>
 
505
                                        </xsl:attribute>
 
506
                                        <xsl:value-of select="text()[1]"/>
 
507
                                </xsl:element>
 
508
                        </xsl:when>
 
509
                        <xsl:otherwise>
 
510
                        </xsl:otherwise>
 
511
                </xsl:choose>
 
512
        </xsl:template>
 
513
 
 
514
        <xsl:template match="text:s" mode="content-table">
 
515
                <xsl:call-template name="write-breakable-whitespace">
 
516
                        <xsl:with-param name="whitespaces" select="@text:c"/>
 
517
                </xsl:call-template>
 
518
        </xsl:template>
 
519
 
 
520
 
 
521
        <!-- ******************** -->
 
522
        <!-- *** Common Rules *** -->
 
523
        <!-- ******************** -->
 
524
 
 
525
        <xsl:template match="*" mode="content-table">
 
526
                <xsl:param name="globalData"/>
 
527
 
 
528
                <xsl:apply-templates select=".">
 
529
                        <xsl:with-param name="globalData" select="$globalData"/>
 
530
                </xsl:apply-templates>
 
531
        </xsl:template>
 
532
 
 
533
        <xsl:template match="*" mode="cell-content">
 
534
                <xsl:if test="name() = 'text:tab' or *[name() = 'text:tab']">
 
535
                        <xsl:element name="tab-stop-node-position" namespace="">
 
536
                                <xsl:value-of select="position()"/>
 
537
                        </xsl:element>
 
538
                </xsl:if>
 
539
        </xsl:template>
 
540
 
 
541
</xsl:stylesheet>