root/OOo/ooo2dbk/trunk/ooo2dbk.odf.xsl

Revision 50505, 161.1 kB (checked in by lgodard, 3 years ago)

- add ommitted tags <phrase>

Line 
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY nbsp "&#160;">
4 ]>
5 <!--
6 Copyright (c) 2004-2006 Nuxeo SARL <http://nuxeo.com>
7 Copyright (c) 2003 Stefan Rinke <stefan@stefan-rinke.de>
8 Copyright (c) 2002 Eric Bellot <ebellot@netcourrier.com>
9
10 Authors:
11 M.-A. Darche (Nuxeo)
12 Stefan Rinke <stefan@stefan-rinke.de>
13 Eric Bellot <ebellot@netcourrier.com>
14 Laurent Godard <lgodard@indesko.com>
15 Maurice TARDELLI - CERTU/SYS/ITS <Maurice.Tardelli@equipement.gouv.fr> for ODF
16
17 This script is free software; you can redistribute it and/or
18 modify it under the terms of the GNU Lesser General Public
19 License as published by the Free Software Foundation; either
20 version 2.1 of the License, or (at your option) any later version.
21
22 This script is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25 Lesser General Public License for more details.
26
27 You should have received a copy of the GNU Lesser General Public
28 License along with this library; if not, write to the Free Software
29 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
30
31 See ``COPYING`` for more information.
32
33 $Id: ooo2dbk.xsl 28486 2005-10-21 13:10:18Z madarche $
34 -->
35 <xsl:stylesheet version="1.0"
36   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
37     xmlns:office= "urn:oasis:names:tc:opendocument:xmlns:office:1.0"
38     xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
39     xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
40     xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
41     xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
42     xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
43     xmlns:xlink="http://www.w3.org/1999/xlink"
44     xmlns:dc="http://purl.org/dc/elements/1.1/"
45     xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
46     xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
47     xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
48     xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
49     xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
50     xmlns:math="http://www.w3.org/1998/Math/MathML"
51     xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
52     xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
53     xmlns:ooo="http://openoffice.org/2004/office"
54     xmlns:ooow="http://openoffice.org/2004/writer"
55     xmlns:oooc="http://openoffice.org/2004/calc"
56     xmlns:dom="http://www.w3.org/2001/xml-events"
57     xmlns:xforms="http://www.w3.org/2002/xforms"
58     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
59     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
60   exclude-result-prefixes="office style text table draw
61   fo xlink number svg chart dr3d math form script dc meta ooo ooow oooc dom xforms xsd xsi">
62
63   <xsl:output method="xml" indent="yes" omit-xml-declaration="no"
64     doctype-public="-//OASIS//DTD DocBook XML V4.4//EN"
65     doctype-system="http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"/>
66    
67   <!--
68   Parameter used to determine which top element the resulting tree will have.
69   This parameter can be overridden by passing a parameter to the XSLT processor.
70   Supported DocBook top elements are: article, book.
71   It defaults to "article".
72   -->
73 <xsl:param name="topElementName">book</xsl:param>
74 <xsl:param name="topElementMetainfoName">
75     <xsl:value-of select="concat($topElementName, 'info')"/>
76 </xsl:param>
77
78 <!-- Which unit to use -->
79 <xsl:param name="measureUnit">
80     <xsl:choose>
81         <xsl:when test="//table:table">
82             <xsl:call-template name="measureUnit"/>
83         </xsl:when>
84         <xsl:otherwise>
85             <xsl:value-of select="'unknown'"/>
86         </xsl:otherwise>
87     </xsl:choose>
88 </xsl:param>
89  
90 <xsl:variable name="oooGenerator" select="/office:document/office:meta/meta:generator"/>
91 <xsl:variable name="oooVersion">
92     <xsl:value-of select="substring-before(substring-after($oooGenerator, 'org/'), ' ')"/>
93 </xsl:variable>
94
95 <xsl:template name="measureUnit">
96     <xsl:param name="firstValue" select="//style:page-layout-properties[1]/@fo:page-width"/>
97     <xsl:if test="contains(string($firstValue), 'mm')">
98       <xsl:value-of select="'mm'"/>
99     </xsl:if>
100     <xsl:if test="contains(string($firstValue), 'cm')">
101       <xsl:value-of select="'cm'"/>
102     </xsl:if>
103     <xsl:if test="contains(string($firstValue), 'inch')">
104       <xsl:value-of select="'inch'"/>
105     </xsl:if>
106     <xsl:if test="contains(string($firstValue), 'pi')">
107       <xsl:value-of select="'pi'"/>
108     </xsl:if>
109     <xsl:if test="contains(string($firstValue), 'pt')">
110       <xsl:value-of select="'pt'"/>
111     </xsl:if>
112     <xsl:if test="contains(string($firstValue), '%')">
113       <xsl:value-of select="'%'"/>
114     </xsl:if>
115   </xsl:template>
116
117   <!--
118   When called with the right parameters this template ouputs a
119   processing-instruction specifying the print-orientation for the element that
120   has the given style.
121
122   Examples:
123   <?print-orientation portrait?>
124   <?print-orientation landscape?>
125
126   Details given in the getPrintOrientation template.
127   -->
128   <xsl:template name="outputPrintOrientation">
129     <!-- Mandatory param -->
130     <xsl:param name="styleName"/>
131     <!-- Optional param -->
132     <xsl:param name="parentStyleName" select="''"/>
133
134     <xsl:variable name="printOrientation">
135       <xsl:call-template name="getPrintOrientation">
136     <xsl:with-param name="styleName" select="$styleName"/>
137     <xsl:with-param name="parentStyleName" select="$parentStyleName"/>
138       </xsl:call-template>
139     </xsl:variable>
140     <xsl:if test="string($printOrientation)">
141       <xsl:processing-instruction name="print-orientation">
142     <xsl:value-of select="$printOrientation"/>
143       </xsl:processing-instruction>
144     </xsl:if>
145   </xsl:template>
146
147
148   <!--
149   Return a string of styles having page orientation information.
150   Example of output of this template:
151   P1,portrait;P9,portrait;P14,portrait;P19,landscape;P20,landscape;P21,portrait;
152   -->
153   <xsl:variable name="styleNamesPrintOrientations">
154     <xsl:for-each select="/office:document/office:automatic-styles/style:page-layout">
155       <xsl:variable name="printOrientation" select="style:page-layout-properties/@style:print-orientation"/>
156       <xsl:variable name="pageMasterName" select="@style:name"/>
157
158         <!--<DEBUG><xsl:value-of select="$printOrientation"/></DEBUG>
159         <DEBUG><xsl:value-of select="$pageMasterName"/></DEBUG> -->
160
161       <xsl:for-each select="//style:master-page[@style:page-layout-name = $pageMasterName]">
162             <xsl:variable name="masterPageName" select="@style:name"/>
163             <!--<DEBUG><xsl:value-of select="$masterPageName"/></DEBUG>-->
164
165             <xsl:for-each select="//style:style[@style:master-page-name = $masterPageName]">
166                 <xsl:value-of select="concat(@style:name, ',')"/>
167                 <xsl:value-of select="concat($printOrientation, ';')"/>
168             </xsl:for-each>
169       </xsl:for-each>
170     </xsl:for-each>
171   </xsl:variable>
172
173   <!--
174   When called with the right parameters this template returns the
175   print-orientation for the element that has the given style.
176
177   Details:
178   The style given to this template should be used the style of a text:h element
179   used for defining a part (not in the DocBook or OOo sense) of the OOo
180   document. So for example the style could be the one of the title (text:h) of
181   the main content or an appendix.
182
183   How it works:
184   1. It looks for the page corresponding to the style:master-page-name of the
185      given style (contained in the styles.xml file).
186   2. It looks for the print-orientation of the page.
187   -->
188   <xsl:template name="getPrintOrientation">
189     <!-- Mandatory param -->
190     <xsl:param name="styleName"/>
191     <!-- Optional param -->
192     <xsl:param name="parentStyleName" select="''"/>
193    
194     <!-- Implementation finding print-orientation from precomputed list -->
195     <xsl:value-of select="substring-before(
196       substring-after($styleNamesPrintOrientations, concat($styleName, ',')),
197       ';')"/>
198     <xsl:if test="string($parentStyleName)">
199       <xsl:value-of select="substring-before(
200     substring-after($styleNamesPrintOrientations, concat($parentStyleName, ',')),
201     ';')"/>
202     </xsl:if>
203
204     <!-- Implementation finding print-orientation dynamically -->
205     <!--
206     <xsl:for-each select="//style:style[@style:name = $styleName]">
207       <xsl:variable name="masterPageName" select="@style:master-page-name"/>
208       <xsl:for-each select="//style:master-page[@style:name = $masterPageName]">
209     <xsl:variable name="pageMasterName" select="@style:page-master-name"/>
210     <xsl:for-each select="//style:page-master[@style:name = $pageMasterName]">
211       <xsl:value-of select="style:properties/@style:print-orientation"/>
212     </xsl:for-each>
213       </xsl:for-each>
214     </xsl:for-each>
215     -->
216   </xsl:template>
217
218   <!--
219   =============
220   DOCUMENT ROOT
221   =============
222   -->
223   <xsl:template match="/">
224     <xsl:element name="{$topElementName}">
225       <xsl:attribute name="lang">
226     <xsl:value-of select="/office:document/office:meta/dc:language"/>
227       </xsl:attribute>
228
229       <xsl:processing-instruction name="ooogenerator">
230     <xsl:value-of select="$oooGenerator"/>
231       </xsl:processing-instruction>
232       <xsl:processing-instruction name="oooversion">
233     <xsl:value-of select="$oooVersion"/>
234       </xsl:processing-instruction>
235
236 <!--
237     <DEBUG><xsl:value-of select="$measureUnit"/></DEBUG>
238     <DEBUG><xsl:value-of select="$styleNamesPrintOrientations"/></DEBUG>
239 -->
240     <xsl:call-template name="metaInfo"/>
241
242       <!--
243       Only books can have preface elements.
244       A book might have both a Foreword and an Introduction.
245       Both should be tagged as preface.
246       -->
247     <xsl:if test="$topElementName='book'">
248         <xsl:call-template name="preface"/>
249     </xsl:if>
250
251       <!-- We start with the first title of level 1 -->
252       <xsl:choose>
253         <xsl:when test="/office:document/office:body/office:text/text:h[@text:outline-level='1']">
254             <xsl:apply-templates
255             select="/office:document/office:body/office:text/text:h[@text:outline-level='1'][1]"
256             mode="hierarchy">
257             <xsl:with-param name="source" select="$topElementName"/>
258             </xsl:apply-templates>
259         </xsl:when>
260         <xsl:otherwise>
261             <xsl:apply-templates select="/office:document/office:body/office:text"
262             mode="noHierarchy"/>
263         </xsl:otherwise>
264       </xsl:choose>
265
266       <xsl:call-template name="appendix"/>
267       <xsl:call-template name="bibliography"/>
268       <xsl:call-template name="glossary"/>
269       <xsl:call-template name="index"/>
270     </xsl:element>
271   </xsl:template>
272
273
274   <!--
275   =============================
276   CHAPTER AND SECTION HIERARCHY
277   =============================
278   -->
279
280   <xsl:template match="*|@*" name="hierarchy" mode="hierarchy">
281     <!-- Specify which element calls this template (optional) -->
282     <xsl:param name="source"/>
283     <!-- Store the current depth level (1, 2, etc.) (optional) -->
284     <xsl:param name="level" select="'0'"/>
285     <!--
286     Specify the id of the node you don't want to have in the result set
287     (optional)
288     -->
289     <xsl:param name="excludeNodeId"/>
290
291     <xsl:choose>
292
293       <!-- If the matched element is not a title (text:h) -->
294       <xsl:when test="name(.) != 'text:h'">
295             <xsl:call-template name="allTags">
296               <xsl:with-param name="source" select="'hierarchy'"/>
297             </xsl:call-template>
298             <xsl:apply-templates select="following-sibling::*[1]" mode="hierarchy">
299               <xsl:with-param name="level" select="$level"/>
300             </xsl:apply-templates>
301       </xsl:when>
302
303       <!-- If the matched element is a title (text:h)
304       and is deeper (level) than the preceding title -->
305       <xsl:when test="@text:outline-level > $level">
306
307     <!--
308     If we want to produce an article it is possible to have paras
309     preceding the 1st title at level 1. We want to have those paras too
310     when a preface or an appendix is encountered.
311     So those instructions are used to display paras that could occur
312     before any title is encountered.
313     The only case when we don't want to have preceding paras is when the
314     source is a book element, the source being the element calling the
315     template, which means that a preface in a book can have paras before its
316     first title, but chapters in a book cannot have paras before their
317     first title.
318     -->
319     <xsl:if test="$source != 'book'
320       and count(preceding-sibling::text:h[@text:outline-level='1']) = 0">
321       <xsl:apply-templates select="preceding-sibling::*[
322         generate-id(.) != $excludeNodeId]" mode="noHierarchy"/>
323     </xsl:if>
324
325     <!--
326     We construct a new section (sectn) and the content of the "h" source
327     element is placed into the "title" output element.
328     -->
329         <!-- Debug
330         <level><xsl:value-of select="$level"/></level>
331         <source><xsl:value-of select="$source"/></source>-->
332
333     <xsl:if test="$level >= 0">
334       <xsl:variable name="structuringElementName">
335         <xsl:choose>
336           <xsl:when test="$level=0 and $source='book'">
337         <xsl:value-of select="'chapter'"/>
338           </xsl:when>
339           <xsl:otherwise>
340         <xsl:value-of select="'section'"/>
341           </xsl:otherwise>
342         </xsl:choose>
343       </xsl:variable>
344       <xsl:element name="{$structuringElementName}">
345
346         <!-- rajout MT recherche si bookmark pour les titres et sections
347                      si oui on met un id -->
348         <xsl:call-template name="GenereIdSection" select="/text:bookmark-start"/>
349         <!-- fin rajout MT-->
350
351         <xsl:call-template name="outputPrintOrientation">
352           <xsl:with-param name="styleName" select="@text:style-name"/>
353         </xsl:call-template>
354         <title><xsl:apply-templates/></title>
355         <xsl:apply-templates select="following-sibling::*[1]" mode="hierarchy">
356           <xsl:with-param name="level" select="@text:outline-level"/>
357           <xsl:with-param name="source" select="$source"/>
358         </xsl:apply-templates>
359       </xsl:element>
360     </xsl:if>
361
362     <xsl:apply-templates select="following-sibling::*[1]" mode="scanLevel">
363       <xsl:with-param name="level" select="@text:outline-level"/>
364       <xsl:with-param name="source" select="$source"/>
365     </xsl:apply-templates>
366
367       </xsl:when>
368
369     </xsl:choose>
370   </xsl:template>
371
372   <xsl:template match="*" mode="scanLevel">
373     <xsl:param name="level" select="'0'"/>
374     <xsl:param name="source"/>
375     <xsl:choose>
376       <xsl:when test="@text:outline-level &lt; $level"/>
377       <xsl:when test="@text:outline-level = $level">
378     <xsl:call-template name="hierarchy">
379       <xsl:with-param name="level" select="$level - 1"/>
380       <xsl:with-param name="source" select="$source"/>
381     </xsl:call-template>
382       </xsl:when>
383       <xsl:otherwise>
384     <xsl:apply-templates select="following-sibling::*[1]" mode="scanLevel">
385       <xsl:with-param name="level" select="$level"/>
386       <xsl:with-param name="source" select="$source"/>
387     </xsl:apply-templates>
388       </xsl:otherwise>
389     </xsl:choose>
390   </xsl:template>
391
392   <xsl:template match="/office:document/office:body/office:text" mode="noHierarchy">
393     <xsl:apply-templates mode="noHierarchy"/>
394   </xsl:template>
395
396   <xsl:template match="*|@*" mode="noHierarchy">
397     <xsl:call-template name="allTags"/>
398   </xsl:template>
399
400 <xsl:template name="allTags">
401     <xsl:param name="source"/>
402
403     <xsl:choose>
404
405         <xsl:when test="name(current())='text:h'">
406             <xsl:choose>
407                 <xsl:when test="$source='hierarchy'"/>
408             <xsl:otherwise>
409                 <para>ERROR: Title hierarchy is wrong, section title is in bad position.</para>
410             </xsl:otherwise>
411             </xsl:choose>
412         </xsl:when>
413
414         <xsl:when test="name(current())='text:p'">
415             <xsl:call-template name="para">
416                 <xsl:with-param name="source" select="$source"/>
417             </xsl:call-template>
418         </xsl:when>
419
420     <!-- Traitement des liste avec la version 2-->
421
422         <xsl:when test="name(current())='text:list'">
423             <xsl:call-template name="ListesV2"/>
424         </xsl:when>
425
426
427         <xsl:when test="name(current())='table:table'">
428             <xsl:choose>
429                 <xsl:when test="$source='cellTable'">
430                     <para>ERROR: Section title should not be in a cell.</para>
431                 </xsl:when>
432                 <xsl:otherwise>
433                     <xsl:call-template name="table"/>
434                 </xsl:otherwise>
435             </xsl:choose>
436         </xsl:when>
437
438     </xsl:choose>
439 </xsl:template>
440
441
442   <!--
443   ========
444   METAINFO
445   ========
446   -->
447
448   <xsl:template match="/office:document/office:meta"/>
449   <xsl:template match="text:p"/>
450
451   <xsl:template name="metaInfo">
452     <xsl:param name="bodyRootPara" select="/office:document/office:body/office:text/text:p"/>
453     <xsl:element name="{$topElementMetainfoName}">
454       <xsl:apply-templates select="$bodyRootPara" mode="metaInfo"/>
455       <xsl:apply-templates select="/office:document/office:meta/dc:title"/>
456       <xsl:apply-templates select="/office:document/office:meta/dc:date"/>
457       <xsl:apply-templates select="/office:document/office:meta/dc:subject"/>
458       <xsl:element name="keywordset">
459         <xsl:apply-templates select="/office:document/office:meta/meta:keyword"/>
460       </xsl:element>
461       <xsl:call-template name="abstract"/>
462       <xsl:call-template name="userFields"/>
463     </xsl:element>
464   </xsl:template>
465
466
467   <xsl:template name="userFields">
468     <xsl:call-template name="metainfoUserFields"/>
469     <xsl:call-template name="authorUserFields"/>
470     <xsl:call-template name="publisherUserFields"/>
471     <xsl:call-template name="contractsponsorUserFields"/>
472     <xsl:call-template name="conferenceUserFields"/>
473   </xsl:template>
474
475
476   <xsl:template name="metainfoUserFields">
477     <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
478       text:user-field-decl[@office:string-value!=''
479       and starts-with(@text:name, 'metainfo_')]">
480       <xsl:if test="@text:name='metainfo_subtitle'">
481             <subtitle>
482               <xsl:value-of select="@office:string-value"/>
483             </subtitle>
484       </xsl:if>
485       <xsl:if test="@text:name='metainfo_date'">
486             <date>
487               <xsl:value-of select="@office:string-value"/>
488             </date>
489       </xsl:if>
490
491       <xsl:if test="@text:name='metainfo_abstract'">
492             <abstract>
493               <para>
494                 <xsl:value-of select="@office:string-value"/>
495               </para>
496             </abstract>
497       </xsl:if>
498
499       <xsl:if test="@text:name='metainfo_bibliomisc'">
500             <bibliomisc>
501               <xsl:value-of select="@office:string-value"/>
502             </bibliomisc>
503       </xsl:if>
504
505       <xsl:if test="@text:name='metainfo_volumenum'">
506             <volumenum>
507               <xsl:value-of select="@office:string-value"/>
508             </volumenum>
509       </xsl:if>
510
511       <xsl:if test="@text:name='metainfo_seriesvolnums'">
512             <seriesvolnums>
513               <xsl:value-of select="@office:string-value"/>
514             </seriesvolnums>
515       </xsl:if>
516
517       <xsl:if test="@text:name='metainfo_contractnum'">
518             <contractnum>
519               <xsl:value-of select="@office:string-value"/>
520             </contractnum>
521       </xsl:if>
522
523       <xsl:if test="@text:name='metainfo_isbn'">
524             <biblioid class="isbn">
525               <xsl:value-of select="@office:string-value"/>
526             </biblioid>
527       </xsl:if>
528
529       <xsl:if test="@text:name='metainfo_issn'">
530             <biblioid class="issn">
531               <xsl:value-of select="@office:string-value"/>
532             </biblioid>
533       </xsl:if>
534
535       <xsl:if test="@text:name='metainfo_isrn'">
536             <biblioid class="isrn">
537               <xsl:value-of select="@office:string-value"/>
538             </biblioid>
539       </xsl:if>
540     </xsl:for-each>
541   </xsl:template>
542
543   <xsl:template name="conferenceUserFields">
544     <confgroup>
545     <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
546       text:user-field-decl[@office:string-value!=''
547       and starts-with(@text:name, 'metainfo_confgroup')]">
548       <xsl:if test="@text:name='metainfo_confgroup_address'">
549     <address>
550       <xsl:value-of select="@office:string-value"/>
551     </address>
552       </xsl:if>
553
554       <xsl:if test="@text:name='metainfo_confgroup_confdates'">
555     <confdates>
556       <xsl:value-of select="@office:string-value"/>
557     </confdates>
558       </xsl:if>
559
560       <xsl:if test="@text:name='metainfo_confgroup_confnum'">
561     <confnum>
562       <xsl:value-of select="@office:string-value"/>
563     </confnum>
564       </xsl:if>
565
566       <xsl:if test="@text:name='metainfo_confgroup_confsponsor'">
567     <confsponsor>
568       <xsl:value-of select="@office:string-value"/>
569     </confsponsor>
570       </xsl:if>
571
572       <xsl:if test="@text:name='metainfo_confgroup_conftitle'">
573     <conftitle>
574       <xsl:value-of select="@office:string-value"/>
575     </conftitle>
576       </xsl:if>
577
578     </xsl:for-each>
579     </confgroup>
580   </xsl:template>
581
582   <xsl:template name="authorUserFields">
583     <!--
584     Testing if there are authors to put in the authorgroup element because
585     this element cannot be empty.
586     XXX: Maybe there is way to optimize the treatments below where we test if
587     there are some nodes (text:user-field-decl) and then look for those same
588     nodes over again.
589     -->
590     <!-- tests if any author metadata exists -->
591       <xsl:variable name="hasAuthor">
592         <xsl:for-each select="/office:document/office:body/office:user-field-decls/text:user-field-decl[@text:string-value!=''
593         and starts-with(@text:name, 'metainfo_author')]">
594           <xsl:value-of select="@text:string-value"/>
595         </xsl:for-each>
596       </xsl:variable>
597
598     <xsl:if test="string($hasAuthor)">
599     <authorgroup>
600       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
601     text:user-field-decl[@office:string-value!=''
602     and starts-with(@text:name, 'metainfo_author')
603     and contains(@text:name, '_surname')]">
604     <!-- Getting the "namexxx_" string -->
605     <xsl:variable name="authorBase"
606       select="concat(substring-before(@text:name, '_'), '_',
607                      substring-before(substring-after(@text:name, '_'), '_'), '_')"/>
608     <author>
609       <xsl:variable name="firstname">
610         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
611           text:user-field-decl[@text:name=concat($authorBase, 'firstname')]">
612           <xsl:value-of select="@office:string-value"/>
613         </xsl:for-each>
614       </xsl:variable>
615       <xsl:if test="string($firstname)">
616         <firstname><xsl:value-of select="$firstname"/></firstname>
617       </xsl:if>
618
619       <xsl:variable name="surname">
620         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
621           text:user-field-decl[@text:name=concat($authorBase, 'surname')]">
622           <xsl:value-of select="@office:string-value"/>
623         </xsl:for-each>
624       </xsl:variable>
625       <xsl:if test="string($surname)">
626         <surname><xsl:value-of select="$surname"/></surname>
627       </xsl:if>
628
629       <xsl:variable name="honorific">
630         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
631           text:user-field-decl[@text:name=concat($authorBase, 'honorific')]">
632           <xsl:value-of select="@office:string-value"/>
633         </xsl:for-each>
634       </xsl:variable>
635       <xsl:if test="string($honorific)">
636         <honorific><xsl:value-of select="$honorific"/></honorific>
637       </xsl:if>
638
639         <xsl:variable name="email">
640             <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
641             text:user-field-decl[@text:name=concat($authorBase, 'email')]">
642             <xsl:value-of select="@office:string-value"/>
643             </xsl:for-each>
644         </xsl:variable>
645         <xsl:if test="string($email)">
646             <email><xsl:value-of select="$email"/></email>
647         </xsl:if>
648
649       <xsl:variable name="orgabbrev">
650         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
651           text:user-field-decl[@text:name=concat($authorBase, 'orgname_acronym')]">
652           <xsl:value-of select="@office:string-value"/>
653         </xsl:for-each>
654       </xsl:variable>
655
656       <xsl:variable name="jobtitle">
657         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
658           text:user-field-decl[@text:name=concat($authorBase, 'jobtitle')]">
659           <xsl:value-of select="@office:string-value"/>
660         </xsl:for-each>
661       </xsl:variable>
662
663       <xsl:variable name="orgname">
664         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
665           text:user-field-decl[@text:name=concat($authorBase, 'orgname')]">
666           <xsl:value-of select="@office:string-value"/>
667         </xsl:for-each>
668       </xsl:variable>
669       <xsl:variable name="orgdiv">
670         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
671           text:user-field-decl[@text:name=concat($authorBase, 'orgdiv')]">
672           <xsl:value-of select="@office:string-value"/>
673         </xsl:for-each>
674       </xsl:variable>
675       <xsl:variable name="address">
676         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
677           text:user-field-decl[@text:name=concat($authorBase, 'address')]">
678           <xsl:value-of select="@office:string-value"/>
679         </xsl:for-each>
680       </xsl:variable>
681       <xsl:if test="string($jobtitle)
682         or string($orgname) or string($orgdiv) or string($orgabbrev) or string($address)">
683         <affiliation>
684           <xsl:if test="string($orgabbrev)">
685         <shortaffil role="orgabbrev"><xsl:value-of select="$orgabbrev"/></shortaffil>
686           </xsl:if>
687           <xsl:if test="string($jobtitle)">
688         <jobtitle><xsl:value-of select="$jobtitle"/></jobtitle>
689           </xsl:if>
690           <xsl:if test="string($orgname)">
691         <orgname><xsl:value-of select="$orgname"/></orgname>
692           </xsl:if>
693           <xsl:if test="string($orgdiv)">
694         <orgdiv><xsl:value-of select="$orgdiv"/></orgdiv>
695           </xsl:if>
696           <xsl:if test="string($address)">
697         <address><xsl:value-of select="$address"/></address>
698           </xsl:if>
699         </affiliation>
700       </xsl:if>
701     </author>
702       </xsl:for-each>
703     </authorgroup>
704    </xsl:if>
705   </xsl:template>
706
707
708   <xsl:template name="publisherUserFields">
709     <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
710       text:user-field-decl[
711       @office:string-value != ''
712       and starts-with(@text:name, 'metainfo_corpauthor')
713       and contains(@text:name, '_orgname')
714       and substring-after(@text:name, '_orgname') = ''
715       ]">
716       <!-- Getting the "corpauthorxxx_" string -->
717       <xsl:variable name="authorBase"
718       select="concat(substring-before(@text:name, '_'), '_',
719                      substring-before(substring-after(@text:name, '_'), '_'), '_')"/>
720       <publisher>
721     <xsl:variable name="name">
722       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
723         text:user-field-decl[@text:name=concat($authorBase, 'orgname')]">
724         <xsl:value-of select="@office:string-value"/>
725       </xsl:for-each>
726     </xsl:variable>
727     <xsl:if test="string($name)">
728       <publishername><xsl:value-of select="$name"/></publishername>
729     </xsl:if>
730
731     <!--
732     Unused variable because there is no markup for this information
733     in DocBook yet.
734     -->
735     <xsl:variable name="orgabbrev">
736       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
737         text:user-field-decl[@text:name=concat($authorBase, 'orgname_acronym')]">
738         <xsl:value-of select="@office:string-value"/>
739       </xsl:for-each>
740     </xsl:variable>
741     <!--
742     Unused variable because there is no markup for this information
743     in DocBook yet.
744     -->
745     <xsl:variable name="orgdiv">
746       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
747         text:user-field-decl[@text:name=concat($authorBase, 'orgdiv')]">
748         <xsl:value-of select="@office:string-value"/>
749       </xsl:for-each>
750     </xsl:variable>
751
752     <xsl:variable name="street">
753       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
754         text:user-field-decl[@text:name=concat($authorBase, 'address')]">
755         <xsl:value-of select="@office:string-value"/>
756       </xsl:for-each>
757     </xsl:variable>
758     <xsl:variable name="pob">
759       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
760         text:user-field-decl[@text:name=concat($authorBase, 'pob')]">
761         <xsl:value-of select="@office:string-value"/>
762       </xsl:for-each>
763     </xsl:variable>
764     <xsl:variable name="postcode">
765       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
766         text:user-field-decl[@text:name=concat($authorBase, 'postcode')]">
767         <xsl:value-of select="@office:string-value"/>
768       </xsl:for-each>
769     </xsl:variable>
770     <xsl:variable name="city">
771       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
772         text:user-field-decl[@text:name=concat($authorBase, 'city')]">
773         <xsl:value-of select="@office:string-value"/>
774       </xsl:for-each>
775     </xsl:variable>
776     <xsl:variable name="state">
777       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
778         text:user-field-decl[@text:name=concat($authorBase, 'state')]">
779         <xsl:value-of select="@office:string-value"/>
780       </xsl:for-each>
781     </xsl:variable>
782     <xsl:variable name="phone">
783       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
784         text:user-field-decl[@text:name=concat($authorBase, 'phone')]">
785         <xsl:value-of select="@office:string-value"/>
786       </xsl:for-each>
787     </xsl:variable>
788     <xsl:variable name="fax">
789       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
790         text:user-field-decl[@text:name=concat($authorBase, 'fax')]">
791         <xsl:value-of select="@office:string-value"/>
792       </xsl:for-each>
793     </xsl:variable>
794     <xsl:variable name="email">
795       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
796         text:user-field-decl[@text:name=concat($authorBase, 'email')]">
797         <xsl:value-of select="@office:string-value"/>
798       </xsl:for-each>
799     </xsl:variable>
800     <xsl:variable name="ulink">
801       <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
802         text:user-field-decl[@text:name=concat($authorBase, 'ulink')]">
803         <xsl:value-of select="@office:string-value"/>
804       </xsl:for-each>
805     </xsl:variable>
806
807     <xsl:if test="string($street) or string($pob) or string($postcode)
808       or string($city) or string($state)
809       or string($phone) or string($fax) or string($email) or string($ulink)">
810       <address>
811         <xsl:if test="string($street)">
812           <street><xsl:value-of select="$street"/></street>
813         </xsl:if>
814         <xsl:if test="string($pob)">
815           <pob><xsl:value-of select="$pob"/></pob>
816         </xsl:if>
817         <xsl:if test="string($postcode)">
818           <postcode><xsl:value-of select="$postcode"/></postcode>
819         </xsl:if>
820         <xsl:if test="string($city)">
821           <city><xsl:value-of select="$city"/></city>
822         </xsl:if>
823         <xsl:if test="string($state)">
824           <state><xsl:value-of select="$state"/></state>
825         </xsl:if>
826         <xsl:if test="string($phone)">
827           <phone><xsl:value-of select="$phone"/></phone>
828         </xsl:if>
829         <xsl:if test="string($fax)">
830           <fax><xsl:value-of select="$fax"/></fax>
831         </xsl:if>
832         <xsl:if test="string($email)">
833           <email><xsl:value-of select="$email"/></email>
834         </xsl:if>
835         <xsl:if test="string($ulink)">
836           <otheraddr>
837         <ulink>
838           <xsl:attribute name="url">
839             <xsl:value-of select="$ulink"/>
840           </xsl:attribute>
841           <xsl:value-of select="$ulink"/>
842         </ulink>
843           </otheraddr>
844         </xsl:if>
845       </address>
846     </xsl:if>
847       </publisher>
848     </xsl:for-each>
849   </xsl:template>
850
851
852   <xsl:template name="contractsponsorUserFields">
853     <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
854       text:user-field-decl[
855       @office:string-value!=''
856       and starts-with(@text:name, 'metainfo_contractsponsor')
857       and contains(@text:name, '_orgname')
858       and substring-after(@text:name, '_orgname') = ''
859       ]">
860       <!-- Getting the "contractsponsorxxx_" string -->
861       <xsl:variable name="authorBase"
862       select="concat(substring-before(@text:name, '_'), '_',
863                      substring-before(substring-after(@text:name, '_'), '_'), '_')"/>
864       <xsl:variable name="name">
865     <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
866       text:user-field-decl[@text:name=concat($authorBase, 'orgname')]">
867       <xsl:value-of select="@office:string-value"/>
868     </xsl:for-each>
869       </xsl:variable>
870       <xsl:variable name="street">
871         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
872           text:user-field-decl[@text:name=concat($authorBase, 'address')]">
873           <xsl:value-of select="@office:string-value"/>
874         </xsl:for-each>
875       </xsl:variable>
876       <xsl:variable name="pob">
877         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
878           text:user-field-decl[@text:name=concat($authorBase, 'pob')]">
879           <xsl:value-of select="@office:string-value"/>
880         </xsl:for-each>
881       </xsl:variable>
882       <xsl:variable name="postcode">
883         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
884           text:user-field-decl[@text:name=concat($authorBase, 'postcode')]">
885           <xsl:value-of select="@office:string-value"/>
886         </xsl:for-each>
887       </xsl:variable>
888       <xsl:variable name="city">
889         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
890           text:user-field-decl[@text:name=concat($authorBase, 'city')]">
891           <xsl:value-of select="@office:string-value"/>
892         </xsl:for-each>
893       </xsl:variable>
894       <xsl:variable name="state">
895         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
896           text:user-field-decl[@text:name=concat($authorBase, 'state')]">
897           <xsl:value-of select="@office:string-value"/>
898         </xsl:for-each>
899       </xsl:variable>
900       <xsl:variable name="phone">
901         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
902           text:user-field-decl[@text:name=concat($authorBase, 'phone')]">
903           <xsl:value-of select="@office:string-value"/>
904         </xsl:for-each>
905       </xsl:variable>
906       <xsl:variable name="fax">
907         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
908           text:user-field-decl[@text:name=concat($authorBase, 'fax')]">
909           <xsl:value-of select="@office:string-value"/>
910         </xsl:for-each>
911       </xsl:variable>
912       <xsl:variable name="email">
913         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
914           text:user-field-decl[@text:name=concat($authorBase, 'email')]">
915           <xsl:value-of select="@office:string-value"/>
916         </xsl:for-each>
917       </xsl:variable>
918       <xsl:variable name="ulink">
919         <xsl:for-each select="/office:document/office:body/office:text/text:user-field-decls/
920           text:user-field-decl[@text:name=concat($authorBase, 'ulink')]">
921           <xsl:value-of select="@office:string-value"/>
922         </xsl:for-each>
923       </xsl:variable>
924
925       <contractsponsor>
926         <xsl:value-of select="$name"/>
927         <xsl:if test="string($street) or string($pob) or string($postcode)
928           or string($city) or string($state)
929           or string($phone) or string($fax) or string($email) or string($ulink)">
930           <xsl:comment>Address</xsl:comment>
931         </xsl:if>
932         <xsl:if test="string($street)">
933           <xsl:processing-instruction name="street">
934             <xsl:value-of select="$street"/>
935           </xsl:processing-instruction>
936         </xsl:if>
937         <xsl:if test="string($pob)">
938           <xsl:processing-instruction name="pob">
939             <xsl:value-of select="$pob"/>
940           </xsl:processing-instruction>
941         </xsl:if>
942         <xsl:if test="string($postcode)">
943           <xsl:processing-instruction name="postcode">
944             <xsl:value-of select="$postcode"/>
945           </xsl:processing-instruction>
946         </xsl:if>
947         <xsl:if test="string($city)">
948           <xsl:processing-instruction name="city">
949             <xsl:value-of select="$city"/>
950           </xsl:processing-instruction>
951         </xsl:if>
952         <xsl:if test="string($state)">
953           <xsl:processing-instruction name="state">
954             <xsl:value-of select="$state"/>
955           </xsl:processing-instruction>
956         </xsl:if>
957         <xsl:if test="string($phone)">
958           <xsl:processing-instruction name="phone">
959             <xsl:value-of select="$phone"/>
960           </xsl:processing-instruction>
961         </xsl:if>
962         <xsl:if test="string($fax)">
963           <xsl:processing-instruction name="fax">
964             <xsl:value-of select="$fax"/>
965           </xsl:processing-instruction>
966         </xsl:if>
967         <xsl:if test="string($email)">
968           <xsl:processing-instruction name="email">
969             <xsl:value-of select="$email"/>
970           </xsl:processing-instruction>
971         </xsl:if>
972         <xsl:if test="string($ulink)">
973           <xsl:processing-instruction name="ulink">
974             <xsl:value-of select="$ulink"/>
975           </xsl:processing-instruction>
976         </xsl:if>
977       </contractsponsor>
978     </xsl:for-each>
979   </xsl:template>
980
981
982   <xsl:template name="keywordsetContent">
983     <!--
984     keywordsString is a string of coma separated keywords
985     Spaces can appear before or after the comas.
986     A so called keyword can contain spaces.
987     Examples:
988     keywordsString = "aaa, bbb, ccc"
989     keywordsString = "aaa  ,  bbb  ,ccc"
990     keywordsString = "a aa, b bb, ccc"
991     keywordsString = "a aa  ,  b bb  ,ccc"
992     -->
993     <xsl:param name="keywordsString"/>
994     <xsl:if test="$keywordsString">
995       <xsl:choose>
996     <xsl:when test="contains($keywordsString, ',')">
997       <keyword><xsl:value-of select="normalize-space(substring-before($keywordsString, ','))"/></keyword>
998       <xsl:call-template name="keywordsetContent">
999         <xsl:with-param name="keywordsString" select="substring-after($keywordsString, ',')"/>
1000       </xsl:call-template>
1001     </xsl:when>
1002     <xsl:otherwise>
1003       <keyword><xsl:value-of select="normalize-space($keywordsString)"/></keyword>
1004     </xsl:otherwise>
1005       </xsl:choose>
1006     </xsl:if>
1007   </xsl:template>
1008
1009
1010   <xsl:template name="authorGroupContent">
1011     <!--
1012     authorsString is a string of semi-colon separated authors
1013     Spaces can appear before or after the semi-colons.
1014     A so called author can contain spaces and a coma.
1015     If there is a coma for an author, the surname is first and then comes the
1016     surname. This could have been the other way but this is how it is defined
1017     in OOo.
1018     Examples:
1019     authorsString = "aaa; bbb; ccc"
1020     authorsString = "aaa  ;  bbb  ;ccc"
1021     authorsString = "a aa; b bb; ccc"
1022     authorsString = "a aa  ;  b bb  ;ccc"
1023     authorsString = " DOE, John  ;  Monroe, Marilyn  ;Buzz"
1024     -->
1025     <xsl:param name="authorsString"/>
1026     <xsl:if test="$authorsString">
1027       <xsl:choose>
1028     <xsl:when test="contains($authorsString, ';')">
1029       <xsl:call-template name="authorGroupContent">
1030         <xsl:with-param name="authorsString" select="substring-after($authorsString, ';')"/>
1031       </xsl:call-template>
1032     </xsl:when>
1033     <xsl:otherwise>
1034       <author>
1035         <personname>
1036           <xsl:choose>
1037         <xsl:when test="contains($authorsString , ',')">
1038           <xsl:variable name="surname"
1039             select="normalize-space(substring-before($authorsString, ','))"/>
1040           <xsl:variable name="firstname"
1041             select="normalize-space(substring-after($authorsString, ','))"/>
1042           <surname>
1043             <xsl:value-of select="$surname"/>
1044           </surname>
1045           <xsl:if test="string($firstname)">
1046             <firstname>
1047               <xsl:value-of select="$firstname"/>
1048             </firstname>
1049           </xsl:if>
1050         </xsl:when>
1051         <xsl:otherwise>
1052           <surname>
1053             <xsl:value-of select="$authorsString"/>
1054           </surname>
1055         </xsl:otherwise>
1056           </xsl:choose>
1057         </personname>
1058       </author>
1059     </xsl:otherwise>
1060       </xsl:choose>
1061     </xsl:if>
1062   </xsl:template>
1063
1064
1065   <xsl:template match="text:p" mode="metaInfo">
1066     <xsl:param name="inAuthor" select="'false'"/>
1067
1068     <xsl:variable name="parentStyleName"
1069       select="/office:document/office:automatic-styles/
1070       style:style[@style:name=(current()/@text:style-name)]/@style:parent-style-name"/>
1071
1072     <xsl:if test="@text:style-name='Title' or
1073       $parentStyleName='Title'">
1074       <title><xsl:apply-templates/></title>
1075     </xsl:if>
1076     <xsl:if test="@text:style-name='Subtitle' or
1077       $parentStyleName='Subtitle'">
1078       <subtitle><xsl:apply-templates/></subtitle>
1079     </xsl:if>
1080     <xsl:if test="@text:style-name='Pubdate' or
1081       $parentStyleName='Pubdate'">
1082       <pubdate><xsl:apply-templates/></pubdate>
1083     </xsl:if>
1084     <xsl:if test="@text:style-name='Pubsnumber' or
1085       $parentStyleName='Pubsnumber'">
1086       <releaseinfo><xsl:apply-templates/></releaseinfo>
1087     </xsl:if>
1088     <xsl:if test="@text:style-name='Author' or
1089       $parentStyleName='Author'">
1090       <author><xsl:call-template name="authorContent"/></author>
1091     </xsl:if>
1092     <xsl:if test="@text:style-name='Editor' or
1093       $parentStyleName='Editor'">
1094       <editor><xsl:call-template name="authorContent"/></editor>
1095     </xsl:if>
1096     <xsl:if test="@text:style-name='Authorblurb' or
1097       $parentStyleName='Authorblurb'">
1098       <xsl:if test="$inAuthor='true'">
1099     <authorblurb><xsl:apply-templates/></authorblurb>
1100       </xsl:if>
1101     </xsl:if>
1102     <xsl:if test="@text:style-name='Othercredit' or
1103       $parentStyleName='Othercredit'">
1104       <othercredit><xsl:call-template name="authorContent"/></othercredit>
1105     </xsl:if>
1106     <xsl:if test="@text:style-name='Corpauthor' or
1107       $parentStyleName='Corpauthor'">
1108       <corpauthor><xsl:apply-templates/></corpauthor>
1109     </xsl:if>
1110     <xsl:if test="@text:style-name='Copyright' or
1111       $parentStyleName='Copyright'">
1112       <copyright><xsl:apply-templates select="text:span"/></copyright>
1113     </xsl:if>
1114     <xsl:if test="@text:style-name='Bibliomisc' or
1115       $parentStyleName='Bibliomisc'">
1116       <bibliomisc><xsl:apply-templates/></bibliomisc>
1117     </xsl:if>
1118     <xsl:if test="@text:style-name='Legalnotice' or
1119       $parentStyleName='Legalnotice'">
1120       <legalnotice>
1121         <xsl:call-template name="paraWithBreakLine"/>
1122       </legalnotice>
1123     </xsl:if>
1124     <xsl:if test="@text:style-name='Bibliocoverage' or
1125       $parentStyleName='Bibliocoverage'">
1126       <bibliocoverage><xsl:apply-templates/></bibliocoverage>
1127     </xsl:if>
1128     <xsl:if test="@text:style-name='Bibliosource' or
1129       $parentStyleName='Bibliosource'">
1130       <bibliosource><xsl:apply-templates/></bibliosource>
1131     </xsl:if>
1132     <xsl:if test="@text:style-name='Bibliorelation' or
1133       $parentStyleName='Bibliorelation'">
1134       <xsl:variable name="url" select="."/>
1135       <bibliorelation>
1136     <ulink>
1137       <xsl:attribute name="url"><xsl:value-of select="$url"/></xsl:attribute>
1138       <xsl:value-of select="$url"/>
1139     </ulink>
1140       </bibliorelation>
1141     </xsl:if>
1142
1143     <!-- Suppress those styles -->
1144     <xsl:if test="@text:style-name='Remark' or $parentStyleName='Remark'"/>
1145
1146     <!--
1147     If this call is uncommented one gets mediaobjects inside the metainfo
1148     which is not what one wants.
1149     -->
1150     <!-- <xsl:call-template name="multimedia.bottom"/> -->
1151   </xsl:template>
1152
1153   <xsl:template name="abstract">
1154     <!-- Testing if there is at least a non-empty Abstract para -->
1155     <xsl:if test="string(//text:p[@text:style-name='Abstract'])">
1156       <abstract>
1157     <!-- Selects all matching elements anywhere in the document -->
1158     <xsl:for-each select="//text:p[@text:style-name='Abstract']">
1159       <para>
1160         <xsl:apply-templates/>
1161       </para>
1162     </xsl:for-each>
1163       </abstract>
1164     </xsl:if>
1165   </xsl:template>
1166
1167   <xsl:template name="authorContent">
1168     <xsl:param name="inAuthor"/>
1169
1170     <xsl:variable name="parentStyleName"
1171       select="/office:document/office:automatic-styles/
1172       style:style[@style:name=(current()/@text:style-name)]/
1173       @style:parent-style-name"/>
1174     <xsl:variable name="parentStyleNameOfFollowing" select="/office:document/office:automatic-styles/
1175       style:style[@style:name=current()/following-sibling::*[1]/@text:style-name]/
1176       @style:parent-style-name"/>
1177     <xsl:variable name="parentStyleNameOfChild" select="/office:document/office:automatic-styles/
1178       style:style[@style:name=current()/*/@text:style-name]/
1179       @style:parent-style-name"/>
1180
1181     <xsl:apply-templates
1182       select="text:span[@text:style-name='Honorific' or
1183       $parentStyleNameOfChild='Honorific']|
1184       text:span[@text:style-name='Firstname' or
1185       $parentStyleNameOfChild='Firstname']|
1186       text:span[@text:style-name='Othername' or
1187       $parentStyleNameOfChild='Othername']|
1188       text:span[@text:style-name='Surname' or
1189       $parentStyleNameOfChild='Surname']|
1190       text:span[@text:style-name='Lineage' or
1191       $parentStyleNameOfChild='Lineage']"/>
1192     <xsl:if test="text:span[@text:style-name='Jobtitle' or
1193       $parentStyleNameOfChild='Jobtitle']|
1194       text:span[@text:style-name='Orgname' or
1195       $parentStyleNameOfChild='Orgname']">
1196       <affiliation>
1197     <xsl:apply-templates
1198       select="text:span[@text:style-name='Jobtitle' or
1199       $parentStyleNameOfChild='Jobtitle']|
1200       text:span[@text:style-name='Orgname' or
1201       $parentStyleNameOfChild='Orgname']"/>
1202       </affiliation>
1203     </xsl:if>
1204     <xsl:if test="following-sibling::*[1]
1205       [@text:style-name='Authorblurb' or
1206       $parentStyleNameOfFollowing='Authorblurb']">
1207       <xsl:apply-templates select="following-sibling::*[1]" mode="metaInfo">
1208     <xsl:with-param name="inAuthor" select="'true'"/>
1209       </xsl:apply-templates>
1210     </xsl:if>
1211   </xsl:template>
1212
1213   <xsl:template match="dc:title">
1214     <title><xsl:apply-templates/></title>
1215   </xsl:template>
1216
1217   <xsl:template match="dc:date">
1218     <date><xsl:apply-templates/></date>
1219   </xsl:template>
1220
1221   <xsl:template match="dc:subject">
1222     <xsl:param name="content" select="text()"/>
1223     <subjectset>
1224       <xsl:if test="normalize-space(substring-before($content,':'))">
1225     <xsl:attribute name="scheme">
1226       <xsl:value-of
1227         select="normalize-space(substring-before($content,':'))"/>
1228     </xsl:attribute>
1229       </xsl:if>
1230       <subject>
1231     <xsl:call-template name="subjectElements">
1232       <xsl:with-param name="content" select="substring-after($content,':')"/>
1233     </xsl:call-template>
1234       </subject>
1235     </subjectset>
1236   </xsl:template>
1237
1238   <xsl:template name="subjectElements">
1239     <xsl:param name="content"/>
1240     <xsl:choose>
1241       <xsl:when test="contains($content,',')">
1242     <subjectterm>
1243       <xsl:value-of
1244         select="normalize-space(substring-before($content,','))"/>
1245     </subjectterm>
1246     <xsl:call-template name="subjectElements">
1247       <xsl:with-param name="content" select="substring-after($content,',')"/>
1248     </xsl:call-template>
1249       </xsl:when>
1250       <xsl:otherwise>
1251     <subjectterm><xsl:value-of select="normalize-space($content)"/></subjectterm>
1252       </xsl:otherwise>
1253     </xsl:choose>
1254   </xsl:template>
1255
1256   <xsl:template match="meta:keyword">
1257     <keyword><xsl:apply-templates/></keyword>
1258   </xsl:template>
1259
1260
1261   <!--
1262   =======
1263   PREFACE
1264   =======
1265
1266   Prefaces are found when an OOo section has an Preface Title in it.
1267   IMPORTANT:
1268   Preface must have a "Preface Title" at its top.
1269   Preface may have no other title than the Preface Title.
1270   Preface may have other titles than the Preface Title, in this case
1271   the Title hierarchy must be strictly followed (Title 1, Title 2, etc.)
1272   otherwise one get the "ERROR: Title hierarchy is wrong" error message.
1273   -->
1274   <xsl:template name="preface">
1275     <!--
1276     Using string(@text:display)!='none' is important here because some sections
1277     may not have the text:display attribute (actually all the visible
1278     sections ;-) ) and thus the test will fail on them.
1279     -->
1280     <xsl:for-each select="/office:document/office:body/office:text/text:section[string(@text:display)!='none']">
1281
1282       <xsl:variable name="prefaceTitleNodeId">
1283         <!--
1284         <xsl:value-of select="generate-id()"/>
1285                     -->
1286         <xsl:call-template name="prefaceTitleNodeId">
1287             <xsl:with-param name="fromNode" select="current()"/>
1288         </xsl:call-template>
1289       </xsl:variable>
1290
1291       <xsl:if test="string($prefaceTitleNodeId)">
1292     <!-- Retrieve the prefaceTitle node through its id -->
1293         <!--<DEBUG><xsl:value-of select="$prefaceTitleNodeId"/></DEBUG>-->
1294
1295     <xsl:variable name="prefaceTitle"
1296       select="//node()[generate-id() = $prefaceTitleNodeId]"/>
1297     <preface>
1298
1299       <!-- rajout MT recherche bookmark si oui rajout attribut id -->
1300       <xsl:if test="$prefaceTitle/text:bookmark-start/@text:name">
1301         <xsl:attribute name="id">
1302             <xsl:value-of select="$prefaceTitle/text:bookmark-start/@text:name"/>
1303         </xsl:attribute>
1304       </xsl:if>
1305       <!-- fin rajout MT recherche bookmark si oui rajout attribut id -->
1306
1307       <xsl:call-template name="outputPrintOrientation">
1308         <xsl:with-param name="styleName" select="$prefaceTitle/@text:style-name"/>
1309       </xsl:call-template>
1310      
1311       <title><xsl:value-of select="$prefaceTitle"/></title>
1312      
1313       <xsl:choose>
1314         <xsl:when test="text:h[@text:outline-level='1']">
1315             <xsl:apply-templates
1316             select="text:h[@text:outline-level='1'][1]" mode="hierarchy">
1317             <xsl:with-param name="source" select="'preface'"/>
1318             <xsl:with-param name="excludeNodeId" select="$prefaceTitleNodeId"/>
1319             </xsl:apply-templates>
1320         </xsl:when>
1321         <xsl:otherwise>
1322           <!--
1323           <xsl:apply-templates select="child::*[generate-id(.) != $prefaceTitleNodeId]" mode="noHierarchy"/>
1324           -->
1325           <xsl:apply-templates select="child::*[generate-id(.) != $prefaceTitleNodeId]" mode="noHierarchy"/>
1326
1327         </xsl:otherwise>
1328       </xsl:choose>
1329     </preface>
1330       </xsl:if>
1331     </xsl:for-each>
1332   </xsl:template>
1333
1334   <!-- Return the node id of the Preface Title if one is found -->
1335   <xsl:template name="prefaceTitleNodeId">
1336     <!-- fromNode is the node on which to start finding the text:p elements -->
1337     <xsl:param name="fromNode"/>
1338     <xsl:for-each select="$fromNode/text:p|$fromNode/text:h">
1339         <xsl:variable name="parentStyleName"
1340         select="/office:document/office:automatic-styles/
1341         style:style[@style:name=(current()/@text:style-name)]/@style:parent-style-name"/>
1342        
1343         <xsl:if test="(@text:style-name='Preface_20_Title'
1344         or $parentStyleName='Preface_20_Title')
1345         and position() = 1">
1346         <xsl:value-of select="generate-id()"/>
1347         </xsl:if>
1348     </xsl:for-each>
1349   </xsl:template>
1350
1351
1352   <!--
1353   ========
1354   APPENDIX
1355   ========
1356
1357   Appendices are found when an OOo section has an Appendix Title in it.
1358   IMPORTANT:
1359   Appendix must have an Appendix Title at its top.
1360   Appendix may have no other title than the Appendix Title.
1361   Appendix may have other titles than the Appendix Title, in this case
1362   the Title hierarchy must be strictly followed (Title 1, Title 2, etc.)
1363   otherwise one get the "ERROR: Title hierarchy is wrong" error message.
1364   -->
1365 <xsl:template name="appendix">
1366     <!--
1367     Using string(@text:display)!='none' is important here because some sections
1368     may not have the text:display attribute (actually all the visible
1369     sections ;-) ) and thus the test will fail on them.
1370     -->
1371     <xsl:for-each select="/office:document/office:body/office:text/text:section[string(@text:display)!='none']">
1372
1373         <xsl:variable name="appendixTitleNodeId">
1374             <xsl:call-template name="appendixTitleNodeId">
1375                 <xsl:with-param name="fromNode" select="current()"/>
1376             </xsl:call-template>
1377         </xsl:variable>
1378
1379         <xsl:if test="string($appendixTitleNodeId)">
1380     <!-- Retrieve the appendixTitle node through its id -->
1381             <!--<DEBUG><xsl:value-of select="$appendixTitleNodeId"/></DEBUG>-->
1382             <xsl:variable name="appendixTitle" select="//node()[generate-id() = $appendixTitleNodeId]"/>
1383             <appendix>
1384
1385             <!-- rajout MT recherche bookmark si oui rajout attribut id -->
1386             <xsl:if test="$appendixTitle/text:bookmark-start/@text:name">
1387             <xsl:attribute name="id">
1388                 <xsl:value-of select="$appendixTitle/text:bookmark-start/@text:name"/>
1389             </xsl:attribute>
1390             </xsl:if>
1391             <!-- fin rajout MT recherche bookmark si oui rajout attribut id -->
1392
1393             <xsl:call-template name="outputPrintOrientation">
1394                 <xsl:with-param name="styleName" select="$appendixTitle/@text:style-name"/>
1395             </xsl:call-template>
1396             <title><xsl:value-of select="$appendixTitle"/></title>
1397             <xsl:choose>
1398                 <xsl:when test="text:h[@text:outline-level='1']">
1399                     <xsl:apply-templates
1400                     select="text:h[@text:outline-level='1'][1]" mode="hierarchy">
1401                     <xsl:with-param name="source" select="'appendix'"/>
1402                     <xsl:with-param name="excludeNodeId" select="$appendixTitleNodeId"/>
1403                     </xsl:apply-templates>
1404                 </xsl:when>
1405                 <xsl:otherwise>
1406                     <!--
1407                     <xsl:apply-templates select="child::*[generate-id(.) != $appendixTitleNodeId]" mode="noHierarchy"/>
1408                     -->
1409                     <xsl:apply-templates select="child::*[generate-id(.) != $appendixTitleNodeId]" mode="noHierarchy"/>
1410                 </xsl:otherwise>
1411             </xsl:choose>
1412             </appendix>
1413         </xsl:if>
1414     </xsl:for-each>
1415 </xsl:template>
1416
1417   <!-- Return the node id of the Appendix Title if one is found -->
1418 <xsl:template name="appendixTitleNodeId">
1419     <!-- fromNode is the node on which to start finding the text:p elements -->
1420     <xsl:param name="fromNode"/>
1421     <xsl:for-each select="$fromNode/text:p|$fromNode/text:h">
1422       <xsl:variable name="parentStyleName"
1423     select="/office:document/office:automatic-styles/
1424     style:style[@style:name=(current()/@text:style-name)]/@style:parent-style-name"/>
1425       <xsl:if test="(@text:style-name='Appendix_20_Title'
1426     or $parentStyleName='Appendix_20_Title')
1427     and position() = 1">
1428
1429     <xsl:value-of select="generate-id()"/>
1430       </xsl:if>
1431     </xsl:for-each>
1432   </xsl:template>
1433
1434
1435   <!--
1436   ============
1437   BIBLIOGRAPHY
1438   ============
1439
1440   Examples of OOo markup:
1441   <text:bibliography-mark text:author="Borges, Malte; Schumacher, Jörg" text:bibliography-type="book" text:identifier="BOR02a" text:isbn="3827262763" text:pages="900" text:publisher="Markt &amp; Technik Verlag" text:title="StarOffice 6.0 Kompendium" text:year="2002">
1442   <text:bibliography-mark text:author="Bob" text:bibliography-type="book" text:identifier="XSLT" text:title="XSLT Poet">
1443   -->
1444 <xsl:template name="bibliography">
1445     <xsl:variable name="biblioEntries" select="/office:document/office:body//text:bibliography-mark"/>
1446     <xsl:if test="$biblioEntries">
1447         <bibliography>
1448             <xsl:for-each select="$biblioEntries">
1449                 <biblioentry>
1450                     <xsl:attribute name="id"><xsl:value-of select="generate-id(current())"/></xsl:attribute>
1451                     <xsl:variable name="abbrev" select="@text:identifier"/>
1452                     <xsl:if test="string($abbrev)">
1453                         <abbrev><xsl:value-of select="$abbrev"/></abbrev>
1454                     </xsl:if>
1455
1456                     <xsl:variable name="url" select="@text:url"/>
1457                     <xsl:choose>
1458                         <xsl:when test="string($url)">
1459                             <title>
1460                                 <ulink>
1461                                     <xsl:attribute name="url"><xsl:value-of select="$url"/></xsl:attribute>
1462                                     <xsl:value-of select="@text:title"/>
1463                                 </ulink>
1464                             </title>
1465                         </xsl:when>
1466                         <xsl:otherwise>
1467                             <title><xsl:value-of select="@text:title"/></title>
1468                         </xsl:otherwise>
1469                     </xsl:choose>
1470
1471                     <xsl:variable name="authorsString" select="@text:author"/>
1472                     <xsl:if test="string($authorsString)">
1473                         <authorgroup>
1474                             <xsl:call-template name="authorGroupContent">
1475                                 <xsl:with-param name="authorsString" select="@text:author"/>
1476                             </xsl:call-template>
1477                         </authorgroup>
1478                     </xsl:if>
1479
1480                     <xsl:variable name="pubdate" select="@text:year"/>
1481                     <xsl:if test="string($pubdate)">
1482                         <pubdate><xsl:value-of select="$pubdate"/></pubdate>
1483                     </xsl:if>
1484
1485                     <xsl:variable name="publisher" select="@text:publisher"/>
1486                     <xsl:if test="string($publisher)">
1487                         <publisher>
1488                             <publishername><xsl:value-of select="$publisher"/></publishername>
1489                         </publisher>
1490                     </xsl:if>
1491
1492                     <xsl:variable name="isbn" select="@text:isbn"/>
1493                     <xsl:if test="string($isbn)">
1494                         <biblioid class="isbn"><xsl:value-of select="$isbn"/></biblioid>
1495                     </xsl:if>
1496
1497                 </biblioentry>
1498             </xsl:for-each>
1499         </bibliography>
1500     </xsl:if>
1501 </xsl:template>
1502
1503
1504   <!--
1505   =============
1506   LEXICAL INDEX
1507   =============
1508
1509   Examples of OOo markup:
1510   Le <text:alphabetical-index-mark-start text:id="IMark1219739116" text:key1="web" text:key2="www"/>W3C<text:alphabetical-index-mark-end text:id="IMark1219739116"/> est une instance de normalisation des standards du <text:alphabetical-index-mark-start text:id="IMark1219743716" text:key1="web" text:key2="www"/>Web<text:alphabetical-index-mark-end text:id="IMark1219743716"/>.
1511   <text:alphabetical-index-mark-start text:id="IMark1219744572" text:key1="corba"/>CORBA<text:alphabetical-index-mark-end text:id="IMark1219744572"/> est aussi un standard.
1512   -->
1513 <xsl:template name="index">
1514     <xsl:variable name="indexEntries" select="/office:document/office:body//text:alphabetical-index-mark-start"/>
1515     <xsl:if test="$indexEntries">
1516       <index/>
1517     </xsl:if>
1518 </xsl:template>
1519
1520
1521   <!--
1522   ========
1523   GLOSSARY
1524   ========
1525
1526   Glossaries are found when an OOo section has an Glossary Title in it.
1527   IMPORTANT:
1528   Glossary must have an Glossary Title at its top.
1529   Glossary may have no other title than the Glossary Title.
1530   -->
1531 <xsl:template name="glossary">
1532     <!--
1533     Using string(@text:display)!='none' is important here because some sections
1534     may not have the text:display attribute (actually all the visible
1535     sections ;-) ) and thus the test will fail on them.
1536     -->
1537     <xsl:for-each select="/office:document/office:body//text:section[string(@text:display)!='none']">
1538 <!--<xsl:message>glossary : <xsl:value-of select="./@text:name"/></xsl:message>-->
1539         <xsl:variable name="glossaryTitleNodeId">
1540             <xsl:call-template name="glossaryTitleNodeId">
1541                 <xsl:with-param name="fromNode" select="current()"/>
1542             </xsl:call-template>
1543         </xsl:variable>
1544
1545         <xsl:if test="string($glossaryTitleNodeId)">
1546     <!-- Retrieve the glossaryTitle node through its id -->
1547             <xsl:variable name="glossaryTitle" select="//node()[generate-id() = $glossaryTitleNodeId]"/>
1548             <glossary>
1549                 <xsl:call-template name="outputPrintOrientation">
1550                     <xsl:with-param name="styleName" select="$glossaryTitle/@text:style-name"/>
1551                 </xsl:call-template>
1552                 <title><xsl:value-of select="$glossaryTitle"/></title>
1553                 <xsl:for-each select="text:p">
1554                     <xsl:variable name="parentStyleName"
1555                         select="/office:document/office:automatic-styles/
1556                         style:style[@style:name=(current()/@text:style-name)]/
1557                         @style:parent-style-name"/>
1558                     <xsl:if test="@text:style-name='Glossary_20_Term' or
1559                         $parentStyleName='Glossary_20_Term'">
1560                         <xsl:variable name="glossTermId" select="generate-id()"/>
1561                         <glossentry>
1562                             <glossterm><xsl:value-of select="string(.)"/></glossterm>
1563                             <glossdef>
1564           <!--
1565           The glossdef paras are found by selecting the next text:p
1566           elements which have the previously selected glossterm para
1567           as the closest glossterm para predecessor.
1568           -->
1569                                 <xsl:for-each select="following-sibling::text:p">
1570
1571                                     <xsl:variable name="precedingGlossTerms"
1572                                     select="preceding-sibling::text:p[
1573                                     @text:style-name='Glossary_20_Term'
1574                                     or
1575                                     /office:document/office:automatic-styles/
1576                                     style:style[@style:name=(current()/@text:style-name)]/
1577                                     @style:parent-style-name = 'Glossary_20_Term'
1578                                     ]"/>
1579                                     <xsl:variable name="closestPrecedingGlossTerm"
1580                                     select="$precedingGlossTerms[position() = last()]"/>
1581
1582                                     <xsl:variable name="parentStyleName2"
1583                                     select="/office:document/office:automatic-styles/
1584                                     style:style[@style:name=(current()/@text:style-name)]/
1585                                     @style:parent-style-name"/>
1586                                     <xsl:if test="(@text:style-name='Glossary_20_Definition'
1587                                     or $parentStyleName2='Glossary_20_Definition')
1588                                     and generate-id($closestPrecedingGlossTerm) = $glossTermId">
1589                                         <para>
1590                                             <xsl:call-template name="paraWithBreakLine"/>
1591                                             <!--<xsl:apply-templates/>-->
1592                                         </para>
1593                                     </xsl:if>
1594                                 </xsl:for-each>
1595                             </glossdef>
1596                         </glossentry>
1597                     </xsl:if>
1598                 </xsl:for-each>
1599             </glossary>
1600         </xsl:if>
1601     </xsl:for-each>
1602 </xsl:template>
1603
1604   <!-- Return the node id of the Glossary Title if one is found -->
1605 <xsl:template name="glossaryTitleNodeId">
1606     <!-- fromNode is the node on which to start finding the text:p elements -->
1607     <xsl:param name="fromNode"/>
1608     <xsl:for-each select="$fromNode/text:p|$fromNode/text:h">
1609       <xsl:variable name="parentStyleName"
1610     select="/office:document/office:automatic-styles/
1611     style:style[@style:name=(current()/@text:style-name)]/@style:parent-style-name"/>
1612
1613       <xsl:if test="(@text:style-name='Glossary_20_Title'
1614     or $parentStyleName='Glossary_20_Title')
1615     and position() = 1">
1616     <xsl:value-of select="generate-id()"/>
1617       </xsl:if>
1618     </xsl:for-each>
1619   </xsl:template>
1620
1621
1622   <!--
1623   =============
1624   DOCUMENT BODY
1625   =============
1626   -->
1627
1628   <!--
1629   BLOCKS TAGS
1630   ===========
1631   -->
1632
1633   <!-- Blocks - Standards blocks -->
1634
1635 <xsl:template name="para">
1636     <xsl:param name="source"/>
1637     <xsl:param name="pos"/>
1638     <xsl:param name="parent"/>
1639
1640     <!--
1641     Only output elements that have text or other elements (children) in them.
1642     This avoids for example empty paras in the output.
1643     -->
1644     <!-- Test original <xsl:if test="string(.) or count(./*) > 0">-->
1645     <xsl:if test="string(.) or count(./*[node() != '']) > 0">
1646         <xsl:variable name="StyleName" select="current()/@text:style-name"/>
1647         <xsl:variable name="parentStyleName"
1648         select="/office:document/office:automatic-styles/
1649         style:style[@style:name=(current()/@text:style-name)]/
1650         @style:parent-style-name"/>
1651
1652         <xsl:variable name="parentStyleNameOfPreceding"
1653         select="/office:document/office:automatic-styles/
1654         style:style[@style:name=current()/
1655         preceding-sibling::*[1]/@text:style-name]/
1656         @style:parent-style-name"/>
1657
1658         <xsl:variable name="parentStyleNameOfFollowing"
1659         select="/office:document/office:automatic-styles/
1660         style:style[@style:name=current()/
1661         following-sibling::*[1]/@text:style-name]/
1662         @style:parent-style-name"/>
1663    
1664 <!--
1665         <DEBUG>
1666         StyleName : <xsl:value-of select="$StyleName"/>
1667         parentStyleName : <xsl:value-of select="$parentStyleName"/>
1668         parentStyleNameOfPreceding : <xsl:value-of select="$parentStyleNameOfPreceding"/>
1669         parentStyleNameOfFollowing : <xsl:value-of select="$parentStyleNameOfFollowing"/>
1670         </DEBUG>
1671 -->
1672
1673 <!--<DEBUG>para</DEBUG>-->
1674 <!--
1675         <mm>
1676         <xsl:attribute name="S">
1677             <xsl:value-of select="$StyleName"/>
1678         </xsl:attribute>
1679         <xsl:attribute name="PS">
1680             <xsl:value-of select="$parentStyleName"/>
1681         </xsl:attribute>
1682         <xsl:attribute name="Sprece">
1683             <xsl:value-of select="$parentStyleNameOfPreceding"/>
1684         </xsl:attribute>
1685         <xsl:attribute name="Sfolow">
1686             <xsl:value-of select="$parentStyleNameOfFollowing"/>
1687         </xsl:attribute>
1688         <xsl:attribute name="String">
1689             <xsl:value-of select="string(.)"/>
1690         </xsl:attribute>
1691         <xsl:attribute name="Count">
1692             <xsl:value-of select="count(./*)"/>
1693         </xsl:attribute>
1694         <xsl:attribute name="StringA">
1695             <xsl:value-of select="count(./*[node() != ''])"/>
1696         </xsl:attribute>
1697         </mm>
1698 -->
1699         <xsl:call-template name="multimedia.top"/>
1700
1701         <xsl:choose>
1702
1703             <xsl:when test="@text:style-name='Epigraph' or $parentStyleName='Epigraph'">
1704               <epigraph>
1705                 <xsl:if test="following-sibling::*[1][name()='text:p' and
1706                   @text:style-name='Attribution' or
1707                   $parentStyleNameOfFollowing='Attribution']">
1708                   <xsl:apply-templates select="following-sibling::*[1]"
1709                 mode="attribution"/>
1710                 </xsl:if>
1711                 <xsl:call-template name="paraWithBreakLine"/>
1712               </epigraph>
1713             </xsl:when>
1714        
1715             <xsl:when test="@text:style-name='Quotations' or
1716               $parentStyleName='Quotations' or
1717               @text:style-name='Blockquote' or
1718               $parentStyleName='Blockquote'">
1719               <blockquote>
1720                 <xsl:if test="following-sibling::*[1][name()='text:p' and
1721                   @text:style-name='Attribution' or
1722                   $parentStyleNameOfFollowing='Attribution']">
1723                   <xsl:apply-templates select="following-sibling::*[1]"
1724                 mode="attribution"/>
1725                 </xsl:if>
1726                 <xsl:call-template name="paraWithBreakLine"/>
1727               </blockquote>
1728             </xsl:when>
1729
1730             <xsl:when test="@text:style-name='Preformatted_20_Text' or
1731               $parentStyleName='Preformatted_20_Text' or
1732               @text:style-name='ProgramListing' or
1733               $parentStyleName='ProgramListing'">
1734               <programlisting><xsl:apply-templates>
1735                   <xsl:with-param name="parent" select="'programListing'"/>
1736                 </xsl:apply-templates></programlisting>
1737             </xsl:when>
1738
1739             <xsl:when test="@text:style-name='Literallayout' or
1740               $parentStyleName='Literallayout'">
1741               <literallayout>
1742                 <xsl:apply-templates>
1743                   <xsl:with-param name="parent" select="'programListing'"/>
1744                 </xsl:apply-templates>
1745               </literallayout>
1746             </xsl:when>
1747        
1748             <xsl:when test="@text:style-name='Term' or $parentStyleName='Term'">
1749               <xsl:if
1750                 test="(preceding-sibling::*[1]/
1751                 @text:style-name != 'Definition' or
1752                 $parentStyleNameOfPreceding != 'Definition') and
1753                 (preceding-sibling::*[1]/@text:style-name != 'Term'
1754                 or $parentStyleNameOfPreceding != 'Term')">
1755                 <xsl:call-template name="varlistterm"/>
1756               </xsl:if>
1757               <xsl:if test="$source='varlist' and
1758                 (preceding-sibling::*[1]/
1759                 @text:style-name='Definition' or
1760                 $parentStyleNameOfPreceding='Definition')">
1761                 <xsl:call-template name="varlist"/>
1762               </xsl:if>
1763             </xsl:when>
1764        
1765             <xsl:when test="@text:style-name='Definition' or
1766               $parentStyleName='Definition'">
1767               <xsl:if test="$source='varlist'">
1768                 <xsl:call-template name="paraWithBreakLine"/>
1769               </xsl:if>
1770               <!--<xsl:if test="following-sibling::*[1][name()='text:p'
1771               and (@text:style-name='Definition' or
1772               $parentStyleNameOfFollowing='Definition')]">
1773               <xsl:apply-templates select="following-sibling::*[1]"
1774               mode="varlist"/>
1775             </xsl:if>-->
1776             </xsl:when>
1777
1778             <!-- Rajoute par Mt pour gerer les styles de notes important|warning|caution|tip -->
1779             <xsl:when test="@text:style-name='Note' or $parentStyleName='Note'">
1780               <note>
1781                 <xsl:if test="preceding-sibling::*[1][name()='text:p' and
1782                   @text:style-name='NoteTitle' or
1783                   $parentStyleNameOfPreceding='NoteTitle']">
1784                   <xsl:apply-templates select="preceding-sibling::*[1]"
1785                 mode="NoteTitle"/>
1786                 </xsl:if>
1787               <!--<xsl:apply-templates/>-->
1788               <xsl:call-template name="paraWithBreakLine"/>
1789               </note>
1790             </xsl:when>
1791             <xsl:when test="@text:style-name='NoteWarning' or $parentStyleName='NoteWarning'">
1792               <warning>
1793                 <xsl:if test="preceding-sibling::*[1][name()='text:p' and
1794                   @text:style-name='NoteTitle' or
1795                   $parentStyleNameOfPreceding='NoteTitle']">
1796                   <xsl:apply-templates select="preceding-sibling::*[1]"
1797                 mode="NoteTitle"/>
1798                 </xsl:if>
1799               <!--<xsl:apply-templates/>-->
1800               <xsl:call-template name="paraWithBreakLine"/>
1801               </warning>
1802             </xsl:when>
1803             <xsl:when test="@text:style-name='NoteImportant' or $parentStyleName='NoteImportant'">
1804               <important>
1805                 <xsl:if test="preceding-sibling::*[1][name()='text:p' and
1806                   @text:style-name='NoteTitle' or
1807                   $parentStyleNameOfPreceding='NoteTitle']">
1808                   <xsl:apply-templates select="preceding-sibling::*[1]"
1809                 mode="NoteTitle"/>
1810                 </xsl:if>
1811               <!--<xsl:apply-templates/>-->
1812               <xsl:call-template name="paraWithBreakLine"/>
1813               </important>
1814             </xsl:when>
1815             <xsl:when test="@text:style-name='NoteCaution' or $parentStyleName='NoteCaution'">
1816               <caution>
1817                 <xsl:if test="preceding-sibling::*[1][name()='text:p' and
1818                   @text:style-name='NoteTitle' or
1819                   $parentStyleNameOfPreceding='NoteTitle']">
1820                   <xsl:apply-templates select="preceding-sibling::*[1]"
1821                 mode="NoteTitle"/>
1822                 </xsl:if>
1823               <!--<xsl:apply-templates/>-->
1824               <xsl:call-template name="paraWithBreakLine"/>
1825               </caution>
1826             </xsl:when>
1827             <xsl:when test="@text:style-name='NoteTip' or $parentStyleName='NoteTip'">
1828               <tip>
1829                 <xsl:if test="preceding-sibling::*[1][name()='text:p' and
1830                   @text:style-name='NoteTitle' or
1831                   $parentStyleNameOfPreceding='NoteTitle']">
1832                   <xsl:apply-templates select="preceding-sibling::*[1]"
1833                 mode="NoteTitle"/>
1834                 </xsl:if>
1835               <!--<xsl:apply-templates/>-->
1836               <xsl:call-template name="paraWithBreakLine"/>
1837               </tip>
1838             </xsl:when>
1839             <!-- fin rajout MT-->
1840
1841             <!-- Suppress those styles -->
1842             <xsl:when test="@text:style-name='Remark' or $parentStyleName='Remark'"/>
1843        
1844             <xsl:when test="@text:style-name='Heading' or $parentStyleName='Heading'"/>
1845        
1846             <xsl:when test="@text:style-name='Attribution' or $parentStyleName='Attribution'"/>
1847        
1848             <!-- rajoute par MT si le style est utilise seul il n est pas affiche -->
1849             <xsl:when test="@text:style-name='NoteTitle' or $parentStyleName='NoteTitle'"/>
1850             <!-- fin rajout MT-->
1851        
1852             <xsl:when test="text:sequence"/>
1853
1854             <!-- suppress metaInfo styles -->
1855             <xsl:when test="@text:style-name='Title' or $parentStyleName='Title'"/>
1856             <xsl:when test="@text:style-name='Subtitle' or $parentStyleName='Subtitle'"/>
1857             <xsl:when test="@text:style-name='Pubsnumber' or $parentStyleName='Pubsnumber'"/>
1858             <xsl:when test="@text:style-name='Pubdate' or $parentStyleName='Pubdate'"/>
1859             <xsl:when test="@text:style-name='Author' or $parentStyleName='Author'"/>
1860             <xsl:when test="@text:style-name='Editor' or $parentStyleName='Editor'"/>
1861             <xsl:when test="@text:style-name='Authorblurb' or $parentStyleName='Authorblurb'"/>
1862             <xsl:when test="@text:style-name='Othercredit' or $parentStyleName='Othercredit'"/>
1863             <xsl:when test="@text:style-name='Corpauthor' or $parentStyleName='Corpauthor'"/>
1864             <xsl:when test="@text:style-name='Copyright' or $parentStyleName='Copyright'"/>
1865             <xsl:when test="@text:style-name='Bibliomisc' or $parentStyleName='Bibliomisc'"/>
1866             <xsl:when test="@text:style-name='Bibliocoverage' or $parentStyleName='Bibliocoverage'"/>
1867             <xsl:when test="@text:style-name='Bibliosource' or $parentStyleName='Bibliosource'"/>
1868             <xsl:when test="@text:style-name='Bibliorelation' or $parentStyleName='Bibliorelation'"/>
1869             <xsl:when test="@text:style-name='Abstract' or $parentStyleName='Abstract'"/>
1870             <xsl:when test="@text:style-name='Legalnotice' or $parentStyleName='Legalnotice'"/>
1871             <xsl:when test="@text:style-name='Keywordset' or $parentStyleName='Keywordset'"/>
1872             <!-- +++++ -->
1873        
1874             <xsl:otherwise>
1875           <!-- No breaklines in paras -->
1876       <!-- <para><xsl:apply-templates/></para> -->
1877
1878           <!-- Allow breaklines in paras -->
1879             <xsl:call-template name="paraWithBreakLine"/>
1880             </xsl:otherwise>
1881
1882         </xsl:choose>
1883
1884         <xsl:call-template name="multimedia.bottom"/>
1885     </xsl:if>
1886 </xsl:template>
1887
1888
1889 <xsl:template name="paraWithBreakLine">
1890     <!--
1891     Parameter to pass a particular role is necessary so that it can propagate to
1892     the split paras.
1893     -->
1894     <xsl:param name="role"/>
1895     <xsl:if test="text:line-break">
1896         <xsl:apply-templates select="text:line-break" mode="break2para">
1897             <xsl:with-param name="role" select="$role"/>
1898         </xsl:apply-templates>
1899     </xsl:if>
1900     <xsl:if test="not(text:line-break)">
1901         <para>
1902             <xsl:if test="string($role)">
1903                 <xsl:attribute name="role">
1904                     <xsl:value-of select="$role"/>
1905                 </xsl:attribute>
1906             </xsl:if>
1907             <xsl:apply-templates/>
1908         </para>
1909     </xsl:if>
1910 </xsl:template>
1911
1912 <xsl:template match="text:line-break" mode="break2para">
1913     <xsl:param name="role"/>
1914     <xsl:variable name="br-before" select="preceding-sibling::text:line-break[1]"/>
1915     <xsl:variable name="content"
1916       select="preceding-sibling::node()[not($br-before) or
1917       generate-id(preceding-sibling::text:line-break[1])
1918       =generate-id($br-before)]"/>
1919     <xsl:if test="$content">
1920         <para>
1921             <xsl:if test="string($role)">
1922                 <xsl:attribute name="role">
1923                     <xsl:value-of select="$role"/>
1924                 </xsl:attribute>
1925             </xsl:if>
1926             <xsl:apply-templates select="$content" />
1927         </para>
1928     </xsl:if>
1929     <xsl:if test="position()=last()">
1930         <xsl:variable name="roleWithLineBreak"
1931             select="normalize-space(concat('lineBreak ', $role))"/>
1932         <para>
1933             <xsl:attribute name="role">
1934                 <xsl:value-of select="$roleWithLineBreak"/>
1935             </xsl:attribute>
1936             <xsl:apply-templates select="following-sibling::node()"/>
1937         </para>
1938     </xsl:if>
1939 </xsl:template>
1940
1941   <!-- Template added by Nuxeo, experimental, kept for reference -->
1942 <xsl:template name="breakLineToPara">
1943     <xsl:param name="role"/>
1944     <xsl:for-each select="*|text()">
1945       <xsl:choose>
1946     <xsl:when test="name(.) != 'text:line-break'">
1947       <para>
1948         <xsl:attribute name="role">
1949           <xsl:value-of select="$role"/>
1950         </xsl:attribute>
1951         <xsl:apply-templates select="."/>
1952       </para>
1953     </xsl:when>
1954     <xsl:when test="text:span">
1955       <xsl:apply-templates select="."/>
1956     </xsl:when>
1957       </xsl:choose>
1958     </xsl:for-each>
1959   </xsl:template>
1960
1961
1962 <xsl:template match="office:annotation">
1963     <xsl:value-of disable-output-escaping="yes" select="text:p"/>
1964   </xsl:template>
1965
1966 <xsl:template match="text:line-break">
1967     <xsl:param name="parent"/>
1968     <xsl:if test="$parent='programListing'">
1969       <xsl:text disable-output-escaping="yes">&#013;</xsl:text>
1970     </xsl:if>
1971   </xsl:template>
1972
1973 <xsl:template match="text:tab-stop">
1974     <xsl:param name="parent"/>
1975     <xsl:if test="$parent='programListing'">
1976       <xsl:text
1977     disable-output-escaping="yes">&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
1978     </xsl:if>
1979   </xsl:template>
1980
1981 <xsl:template match="text:s">
1982     <xsl:param name="parent"/>
1983     <xsl:param name="spaceOccurence" select="@text:c + 1"/>
1984     <xsl:if test="$parent='programListing'">
1985       <xsl:call-template name="spaceRecursif">
1986     <xsl:with-param name="spaceOccurence"
1987       select="$spaceOccurence"/>
1988       </xsl:call-template>
1989     </xsl:if>
1990   </xsl:template>
1991
1992 <xsl:template name="spaceRecursif">
1993     <xsl:param name="spaceOccurence"/>
1994     <xsl:if test="$spaceOccurence > 0">
1995       <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
1996       <xsl:call-template name="spaceRecursif">
1997     <xsl:with-param name="spaceOccurence"
1998       select="$spaceOccurence - 1"/>
1999       </xsl:call-template>
2000     </xsl:if>
2001   </xsl:template>
2002
2003   <!-- Blocks - Attribution -->
2004
2005 <xsl:template match="text:p" mode="attribution">
2006     <attribution><xsl:apply-templates/></attribution>
2007   </xsl:template>
2008
2009   <!-- Rajout MT : Blocks - NoteTitle -->
2010 <xsl:template match="text:p" mode="NoteTitle">
2011     <title><xsl:apply-templates/></title>
2012   </xsl:template>
2013
2014   <!-- Block - Heading (local title) -->
2015
2016 <xsl:template name="paraWithTitle">
2017     <xsl:call-template name="precedingTitle"/>
2018     <xsl:call-template name="paraWithBreakLine"/>
2019   </xsl:template>
2020
2021 <xsl:template name="precedingTitle">
2022     <xsl:variable name="parentStyleNameOfPreceding"
2023       select="/office:document/office:automatic-styles/
2024       style:style[@style:name=current()/preceding-sibling::*[1]/
2025       @text:style-name]/@style:parent-style-name"/>
2026     <xsl:if test="preceding-sibling::*[1][name()='text:p'
2027       and (@text:style-name='Heading' or
2028       $parentStyleNameOfPreceding ='Heading')]">
2029       <xsl:apply-templates select="current()/preceding-sibling::*[1]"
2030     mode="includeTitle"/>
2031     </xsl:if>
2032   </xsl:template>
2033
2034 <xsl:template match="text:p" mode="includeTitle">
2035     <title><xsl:apply-templates/></title>
2036   </xsl:template>
2037
2038   <!--
2039   LISTS
2040   =====
2041   -->
2042
2043   <!-- Lists - VariableList
2044   'Term' and 'Definition' : not defaults styles of OpenOffice -->
2045
2046 <xsl:template name="varlistterm">
2047     <variablelist>
2048       <xsl:call-template name="varlist"/>
2049     </variablelist>
2050   </xsl:template>
2051
2052 <xsl:template name="varlist">
2053     <xsl:variable name="parentStyleNameOfFollowing"
2054       select="/office:document/office:automatic-styles/
2055       style:style[@style:name=current()/
2056       following-sibling::*[1]/@text:style-name]/
2057       @style:parent-style-name"/>
2058     <xsl:variable name="parentStyleNameOfFollowing2"
2059       select="/office:document/office:automatic-styles/
2060       style:style[@style:name=current()/
2061       following-sibling::*[2]/@text:style-name]/
2062       @style:parent-style-name"/>
2063     <varlistentry>
2064       <term><xsl:apply-templates/></term>
2065       <listitem>
2066     <xsl:if test="following-sibling::*[1][name()='text:p'
2067       and (@text:style-name='Definition'
2068       or $parentStyleNameOfFollowing='Definition')]">
2069       <xsl:apply-templates select="following-sibling::*[1]"
2070         mode="varlist"/>
2071     </xsl:if>
2072       </listitem>
2073     </varlistentry>
2074     <!--<xsl:choose>
2075     <xsl:when test="following-sibling::*[1][name()='text:p' and
2076     (@text:style-name='Term' or
2077     $parentStyleNameOfFollowing='Term')]">
2078     <xsl:apply-templates select="following-sibling::*[1]"
2079     mode="varlist"/>
2080   </xsl:when>
2081     <xsl:when test="following-sibling::*[2][name()='text:p' and
2082     (@text:style-name='Term' or
2083     $parentStyleNameOfFollowing2='Term')]">
2084     <xsl:apply-templates select="following-sibling::*[2]"
2085     mode="varlist"/>
2086   </xsl:when>
2087     <xsl:otherwise/>
2088   </xsl:choose>
2089     <xsl:if test="following-sibling::*[1][name()='text:p' and
2090     (@text:style-name='Term' or
2091     $parentStyleNameOfFollowing='Term')]">
2092     <xsl:apply-templates select="following-sibling::*[1]"
2093     mode="varlist"/>
2094   </xsl:if>-->
2095     <xsl:if test="following-sibling::*[2][name()='text:p' and
2096       (@text:style-name='Term' or
2097       $parentStyleNameOfFollowing2='Term')]">
2098       <xsl:apply-templates select="following-sibling::*[2]"
2099     mode="varlist"/>
2100     </xsl:if>
2101   </xsl:template>
2102
2103   <!-- Nouvelles Listes - Version 2 -->
2104
2105 <xsl:template match="text:list" name="ListesV2">
2106     <xsl:variable name="Laliste" select="ancestor-or-self::text:list"/>
2107     <xsl:variable name="StyleMM" select="$Laliste[1]/@text:style-name"/>
2108     <xsl:variable name="style" select="//text:list-style[@style:name=$StyleMM]"/>
2109     <xsl:variable name="level" select="count(ancestor-or-self::text:list)"/>
2110     <xsl:variable name="typelevel" select="name($style/*[@text:level = $level])"/>
2111
2112     <!--<DEBUG>typelevel : <xsl:value-of select="$typelevel"/></DEBUG>-->
2113
2114     <xsl:if test="$typelevel = 'text:list-level-style-number'">
2115     <orderedlist>
2116         <xsl:variable name="ConsecutiveNumbering" select="$style/@text:consecutive-numbering"/>
2117
2118         <xsl:attribute name="continuation">
2119                 <xsl:choose>
2120                     <xsl:when test="$ConsecutiveNumbering='true'">
2121                         <xsl:text>continues</xsl:text>
2122                     </xsl:when>
2123                     <xsl:otherwise>
2124                         <xsl:text>restarts</xsl:text>
2125                     </xsl:otherwise>
2126                 </xsl:choose>
2127         </xsl:attribute>
2128         <xsl:variable name="numFormat"
2129         select="$style/text:list-level-style-number[@text:level = $level]/@style:num-format"/>
2130         <xsl:if test="$numFormat">
2131             <xsl:attribute name="numeration">
2132                 <xsl:choose>
2133                 <xsl:when test="$numFormat='a'">
2134                   <xsl:text>loweralpha</xsl:text>
2135                 </xsl:when>
2136                 <xsl:when test="$numFormat='A'">
2137                   <xsl:text>upperalpha</xsl:text>
2138                 </xsl:when>
2139                 <xsl:when test="$numFormat='1'">
2140                   <xsl:text>arabic</xsl:text>
2141                 </xsl:when>
2142                 <xsl:when test="$numFormat='i'">
2143                   <xsl:text>lowerroman</xsl:text>
2144                 </xsl:when>
2145                 <xsl:when test="$numFormat='I'">
2146                   <xsl:text>upperroman</xsl:text>
2147                 </xsl:when>
2148                 </xsl:choose>
2149             </xsl:attribute>
2150         </xsl:if>
2151         <xsl:apply-templates/>
2152
2153     </orderedlist>
2154     </xsl:if>
2155     <xsl:if test="$typelevel = 'text:list-level-style-bullet'">
2156     <itemizedlist>
2157         <xsl:apply-templates/>
2158     </itemizedlist>
2159     </xsl:if>
2160
2161 </xsl:template>
2162
2163
2164
2165   <!-- Lists - Common tags -->
2166
2167 <xsl:template match="text:list-item">
2168     <xsl:param name="parent"/>
2169     <xsl:choose>
2170       <xsl:when test="$parent = 'calloutlist'">
2171     <callout>
2172       <xsl:attribute name="arearefs"><xsl:value-of select="text:p/text:reference-ref/@text:ref-name"/></xsl:attribute>
2173       <xsl:apply-templates/></callout></xsl:when>
2174       <xsl:otherwise>
2175     <listitem><xsl:apply-templates/></listitem>
2176       </xsl:otherwise>
2177     </xsl:choose>
2178 </xsl:template>
2179
2180 <xsl:template match="text:list-item/text:p">
2181     <!--<DEBUG>text:list-item/text:p</DEBUG>-->
2182
2183     <xsl:call-template name="multimedia.top"/>
2184     <xsl:call-template name="paraWithBreakLine"/>
2185     <xsl:call-template name="multimedia.bottom"/>
2186 </xsl:template>
2187
2188
2189   <!--
2190   INLINES TAGS
2191   ============
2192   -->
2193
2194 <xsl:template match="text:span">
2195     <xsl:variable name="fontStyle"
2196       select="/office:document/office:automatic-styles/
2197       style:style[@style:name=(current()/@text:style-name)]
2198       /style:text-properties/@fo:font-style"/>
2199     <xsl:variable name="fontWeight"
2200       select="/office:document/office:automatic-styles/
2201       style:style[@style:name=(current()/
2202       @text:style-name)]/style:text-properties/
2203       @fo:font-weight"/>
2204     <xsl:variable name="fontName"
2205       select="/office:document/office:automatic-styles/
2206       style:style[@style:name=(current()/
2207       @text:style-name)]/style:text-properties/
2208       @style:font-name"/>
2209     <xsl:variable name="textPosition"
2210       select="/office:document/office:automatic-styles/
2211       style:style[@style:name=(current()/
2212       @text:style-name)]/style:text-properties/
2213       @style:text-position"/>
2214     <xsl:variable name="parentStyleName"
2215       select="/office:document/office:automatic-styles/
2216       style:style[@style:name=(current()/
2217       @text:style-name)]/@style:parent-style-name"/>
2218
2219     <xsl:choose>
2220         <xsl:when test="$fontStyle='italic'">
2221             <emphasis><xsl:apply-templates/></emphasis>
2222         </xsl:when>
2223         <xsl:when test="$fontWeight='bold'">
2224             <emphasis role="strong"><xsl:apply-templates/></emphasis>
2225         </xsl:when>
2226         <xsl:when test="@text:style-name='Emphasis' or $parentStyleName='Emphasis'">
2227             <emphasis><xsl:apply-templates/></emphasis>
2228         </xsl:when>
2229         <xsl:when test="@text:style-name='Strong_20_Emphasis' or $parentStyleName='Strong_20_Emphasis'">
2230             <emphasis>
2231                 <xsl:attribute name="role">strong</xsl:attribute>
2232                 <xsl:apply-templates/>
2233                 </emphasis>
2234         </xsl:when>
2235
2236       <!--
2237       Here we keep the font names of the following fonts because they mark the
2238       fact that symbols are used and we want to pass this information to the
2239       next XSLT stylesheet that will transform this DocBook XML into, for
2240       example XHTML or PDF:
2241       "OpenSymbol"
2242       "Standard Symbols L"
2243       "Zapf Dingbats"
2244       "Bitstream Charter"
2245       Note that "Bitstream" is the name of a provider providing more than just
2246       one font.
2247       -->
2248         <xsl:when test="$fontName != ''
2249             and (
2250             contains($fontName, 'Symbol')
2251             or contains($fontName, 'Dingbats')
2252             or $fontName = 'Bitstream Charter'
2253             or $fontName = 'Andale Mono'
2254             )">
2255             <phrase>
2256                 <xsl:attribute name="role">
2257                     <xsl:value-of select="concat('font-name: ', 'Symbol')"/>
2258                 </xsl:attribute>
2259                 <xsl:apply-templates/>
2260             </phrase>
2261         </xsl:when>
2262
2263         <xsl:when test="starts-with($textPosition, 'sup')">
2264             <superscript><xsl:apply-templates/></superscript>
2265         </xsl:when>
2266         <xsl:when test="starts-with($textPosition, 'sub')">
2267             <subscript><xsl:apply-templates/></subscript>
2268         </xsl:when>
2269
2270         <xsl:when test="@text:style-name='Citation' or $parentStyleName='Citation'">
2271             <quote><xsl:apply-templates/></quote>
2272       </xsl:when>
2273
2274       <xsl:when test="@text:style-name='Source Text'
2275     or @text:style-name='Example'
2276     or @text:style-name='Teletype'
2277     or @text:style-name='Literal'
2278     or $parentStyleName='Source Text'
2279     or $parentStyleName='Example'
2280     or $parentStyleName='Teletype'
2281     or $parentStyleName='Literal'">
2282     <literal><xsl:apply-templates/></literal>
2283       </xsl:when>
2284
2285       <xsl:when test="@text:style-name='User Entry'
2286     or $parentStyleName='User Entry'
2287     or @text:style-name='Userentry'
2288     or $parentStyleName='Userentry'">
2289     <userinput><xsl:apply-templates/></userinput>
2290       </xsl:when>
2291
2292       <xsl:when test="@text:style-name='Filename'
2293     or $parentStyleName='Filename'">
2294     <filename><xsl:apply-templates/></filename>
2295       </xsl:when>
2296
2297       <xsl:when test="@text:style-name='Computeroutput'
2298     or $parentStyleName='Computeroutput'">
2299     <computeroutput><xsl:apply-templates/></computeroutput>
2300       </xsl:when>
2301
2302       <xsl:when test="@text:style-name='Command'
2303     or $parentStyleName='Command'">
2304     <command><xsl:apply-templates/></command>
2305       </xsl:when>
2306
2307       <xsl:when test="@text:style-name='Option'
2308     or $parentStyleName='Option'">
2309     <option><xsl:apply-templates/></option>
2310       </xsl:when>
2311
2312       <xsl:when test="@text:style-name='Acronym'
2313     or $parentStyleName='Acronym'">
2314     <acronym><xsl:apply-templates/></acronym>
2315       </xsl:when>
2316
2317       <xsl:when test="@text:style-name='Lineannotation'
2318     or $parentStyleName='Lineannotation'">
2319     <lineannotation><xsl:apply-templates/></lineannotation>
2320       </xsl:when>
2321
2322       <xsl:when test="@text:style-name='Replaceable'
2323     or $parentStyleName='Replaceable'">
2324     <replaceable><xsl:apply-templates/></replaceable>
2325       </xsl:when>
2326
2327       <xsl:when test="@text:style-name='Attribution'
2328     or $parentStyleName='Attribution'">
2329     <attribution><xsl:apply-templates/></attribution>
2330       </xsl:when>
2331
2332       <xsl:when test="@text:style-name='Honorific'
2333     or $parentStyleName='Honorific'">
2334     <honorific><xsl:apply-templates/></honorific>
2335       </xsl:when>
2336
2337       <xsl:when test="@text:style-name='Firstname'
2338     or $parentStyleName='Firstname'">
2339     <firstname><xsl:apply-templates/></firstname>
2340       </xsl:when>
2341
2342       <xsl:when test="@text:style-name='Othername'
2343     or $parentStyleName='Othername'">
2344     <othername><xsl:apply-templates/></othername>
2345       </xsl:when>
2346
2347       <xsl:when test="@text:style-name='Surname'
2348     or $parentStyleName='Surname'">
2349     <surname><xsl:apply-templates/></surname>
2350       </xsl:when>
2351
2352       <xsl:when test="@text:style-name='Lineage'
2353     or $parentStyleName='Lineage'">
2354     <lineage><xsl:apply-templates/></lineage>
2355       </xsl:when>
2356
2357       <xsl:when test="@text:style-name='Year'
2358     or $parentStyleName='Year'">
2359     <year><xsl:apply-templates/></year>
2360       </xsl:when>
2361
2362       <xsl:when test="@text:style-name='Holder'
2363     or $parentStyleName='Holder'">
2364     <holder><xsl:apply-templates/></holder>
2365       </xsl:when>
2366
2367       <xsl:when test="(@text:style-name='Email'
2368     or $parentStyleName='Email')">
2369     <email><xsl:apply-templates/></email>
2370       </xsl:when>
2371
2372       <xsl:when test="@text:style-name='Jobtitle'
2373     or $parentStyleName='Jobtitle'">
2374     <jobtitle><xsl:apply-templates/></jobtitle>
2375       </xsl:when>
2376
2377       <xsl:when test="@text:style-name='Orgname'
2378     or $parentStyleName='Orgname'">
2379     <orgname><xsl:apply-templates/></orgname>
2380       </xsl:when>
2381
2382       <xsl:when test="@text:style-name='Citation Title'
2383     or $parentStyleName='Citation Title'">
2384     <citetitle><xsl:apply-templates/></citetitle>
2385       </xsl:when>
2386
2387       <xsl:otherwise>
2388     <xsl:apply-templates/>
2389       </xsl:otherwise>
2390     </xsl:choose>
2391   </xsl:template>
2392
2393   <!--
2394   FOOTNOTES
2395   =========
2396   -->
2397
2398 <xsl:template match="text:note">
2399     <footnote>
2400         <xsl:attribute name="id"><xsl:value-of select="@text:id"/></xsl:attribute>
2401         <xsl:if test="text:note-citation[@text:label]">
2402             <xsl:attribute name="label">
2403                 <xsl:value-of select="text:note-citation/@text:label"/>
2404             </xsl:attribute>
2405         </xsl:if>
2406         <xsl:apply-templates select="text:note-body/*" mode="footnote"/>
2407
2408     </footnote>
2409 </xsl:template>
2410
2411 <xsl:template match="text:note-citation"/>
2412
2413 <xsl:template match="*" mode="footnote">
2414     <xsl:call-template name="allTags">
2415         <xsl:with-param name="source" select="'footnote'"/>
2416     </xsl:call-template>
2417 </xsl:template>
2418
2419 <xsl:template match="text:note-ref">
2420     <footnoteref>
2421         <xsl:attribute name="linkend">
2422             <xsl:value-of select="@text:ref-name"/>
2423         </xsl:attribute>
2424     </footnoteref>
2425 </xsl:template>
2426
2427   <!--
2428   HYPERLINKS AND CROSS REFERENCES
2429   ===============================
2430   -->
2431 <!-- Gestion des liens dans les refs biblio -->
2432 <xsl:template match="text:bibliography-mark">
2433     <xsl:variable name="abbrev" select="@text:identifier"/>
2434     <xsl:if test="string($abbrev)">
2435         <link>
2436             <xsl:attribute name="linkend"><xsl:value-of select="generate-id(current())"/></xsl:attribute>
2437             <xsl:text>[</xsl:text>
2438             <xsl:value-of select="$abbrev"/>
2439             <xsl:text>]</xsl:text>
2440         </link>
2441     </xsl:if>
2442 </xsl:template>
2443
2444
2445
2446   <!-- The id attribute goes to the tags parent -->
2447   <xsl:template match="text:reference-mark|text:bookmark|
2448     text:reference-mark-start|text:bookmark-start">
2449     <xsl:choose>
2450       <xsl:when test="starts-with(@text:name, 'co.')">
2451     <!-- generate a callout ref co -->
2452     <co>
2453       <xsl:attribute name="id">
2454         <xsl:value-of select="@text:name"/>
2455       </xsl:attribute>
2456     </co>
2457       </xsl:when>
2458       <xsl:otherwise>
2459     <!-- generate a phrase ref -->
2460     <!-- en commentaire par MT
2461     <phrase>
2462       <xsl:attribute name="id">
2463         <xsl:value-of select="@text:name"/>
2464       </xsl:attribute>
2465     </phrase>
2466            -->
2467     <!-- rajouter par MT -->
2468     <!-- on ajoute l'attribut Id au noeud uniquement s'il ne s'agit pas d'un titre
2469            dans le cas d'un titre, le lien Id est ajoute au niveau superieur par le template GenereIDSection -->
2470     <xsl:if test="not(name(..) = 'text:h')">
2471             <phrase>
2472               <xsl:attribute name="id">
2473                 <xsl:value-of select="@text:name"/>
2474               </xsl:attribute>
2475             </phrase>
2476     </xsl:if>
2477     <!-- fin rajout MT -->
2478
2479       </xsl:otherwise>
2480     </xsl:choose>
2481   </xsl:template>
2482
2483 <xsl:template match="text:reference-mark-end|text:bookmark-end"/>
2484
2485 <xsl:template match="text:reference-ref|text:bookmark-ref|
2486     text:sequence-ref">
2487     <xsl:choose>
2488       <xsl:when test="starts-with(@text:ref-name, 'co.')">
2489     <!-- generate a nothing, will be used by callout -->
2490       </xsl:when>
2491       <xsl:otherwise>
2492     <link>
2493       <xsl:attribute name="linkend">
2494         <xsl:value-of select="@text:ref-name"/>
2495       </xsl:attribute>
2496       <xsl:apply-templates/>
2497     </link>
2498       </xsl:otherwise>
2499     </xsl:choose>
2500   </xsl:template>
2501
2502 <xsl:template match="text:a">
2503     <xsl:choose>
2504       <xsl:when test="text:span/@text:style-name='Email'">
2505     <xsl:apply-templates/>
2506       </xsl:when>
2507       <xsl:otherwise>
2508     <ulink>
2509       <xsl:attribute name="url">
2510         <xsl:value-of select="@xlink:href"/>
2511       </xsl:attribute>
2512       <xsl:attribute name="type">
2513         <xsl:value-of select="@office:target-frame-name"/>
2514       </xsl:attribute>
2515       <xsl:apply-templates/>
2516     </ulink>
2517       </xsl:otherwise>
2518     </xsl:choose>
2519   </xsl:template>
2520
2521   <!--
2522   INDEX TERMS
2523   ===========
2524
2525   Examples of OOo markup:
2526   Le <text:alphabetical-index-mark-start text:id="IMark1219739116" text:key1="web" text:key2="www"/>W3C<text:alphabetical-index-mark-end text:id="IMark1219739116"/> est une instance de normalisation des standards du <text:alphabetical-index-mark-start text:id="IMark1219743716" text:key1="web" text:key2="www"/>Web<text:alphabetical-index-mark-end text:id="IMark1219743716"/>.
2527   <text:alphabetical-index-mark-start text:id="IMark1219744572" text:key1="corba"/>CORBA<text:alphabetical-index-mark-end text:id="IMark1219744572"/> est aussi un standard.
2528
2529   Outputs the text between text:alphabetical-index-mark-start and
2530   text:alphabetical-index-mark-end.
2531   -->
2532   <xsl:template name="indexTerm" match="text:alphabetical-index-mark-start">
2533     <xsl:variable name="indexId" select="@text:id"/>
2534     <xsl:variable name="indexMarkEnd"
2535       select="text:alphabetical-index-mark-end[@text:id = $indexId]"/>
2536     <!--
2537     The text is what follows the text:alphabetical-index-mark-start and which
2538     following text:alphabetical-index-mark-end is the computed indexMarkEnd.
2539     -->
2540     <xsl:variable name="indexText"
2541       select="following-sibling::node()[not($indexMarkEnd) or
2542       generate-id(following-sibling::text:alphabetical-index-mark-end[1])
2543       = generate-id($indexMarkEnd)
2544       ]"/>
2545     <xsl:if test="$indexText">
2546       <indexterm>
2547     <xsl:variable name="primary" select="$indexText"/>
2548     <xsl:variable name="secondary" select="@text:key1"/>
2549     <xsl:variable name="tertiary" select="@text:key2"/>
2550     <xsl:element name="primary">
2551       <xsl:value-of select="$primary"/>
2552     </xsl:element>
2553     <xsl:if test="string($secondary)">
2554       <xsl:element name="secondary">
2555         <xsl:value-of select="$secondary"/>
2556       </xsl:element>
2557     </xsl:if>
2558     <xsl:if test="string($tertiary)">
2559       <xsl:element name="tertiary">
2560         <xsl:value-of select="$tertiary"/>
2561       </xsl:element>
2562     </xsl:if>
2563       </indexterm>
2564     </xsl:if>
2565   </xsl:template>
2566
2567
2568   <!--
2569   ======
2570   FRAMES
2571   ======
2572   -->
2573
2574   <!-- Frame's position treatment -->
2575
2576   <xsl:template match="draw:text-box"/>
2577   <xsl:template match="draw:a[draw:text-box]"/>
2578
2579   <xsl:template match="draw:image[../@text:anchor-type='page']"/>
2580   <xsl:template match="draw:image[(../@text:anchor-type='paragraph')
2581     or (../@text:anchor-type='char')]"/>
2582
2583   <xsl:template match="draw:a[draw:image[../@text:anchor-type='page']]"/>
2584   <xsl:template match="draw:a[draw:image[(../@text:anchor-type='paragraph')
2585     or (@../text:anchor-type='char')]]"/>
2586
2587   <!--
2588   multimedia.top and multimedia.bottom have the same code, there only difference
2589   are:
2590   - the calledPos parameter
2591   - the fact that OLE objects are only treated in the first template, otherwise
2592   we get them twice
2593   -->
2594 <xsl:template name="multimedia.top">
2595     <xsl:param name="calledPos" select="'top'"/>
2596     <!--<DEBUG>MultimediaTop sur : <xsl:value-of select="name(current())"/></DEBUG>-->
2597     <xsl:apply-templates
2598       select=".//draw:image[(../@text:anchor-type='paragraph'
2599       or ../@text:anchor-type='char')
2600       and not(ancestor::draw:text-box)]
2601       | .//draw:text-box"
2602       mode="extract">
2603       <xsl:with-param name="calledPos" select="$calledPos"/>
2604     </xsl:apply-templates>
2605
2606 <!-- Original
2607     <xsl:apply-templates
2608       select=".//draw:image[(../@text:anchor-type='paragraph'
2609       or ../@text:anchor-type='char')
2610       and not(ancestor::draw:text-box)]
2611       | .//draw:object[not(ancestor::draw:text-box)]
2612       | .//draw:object-ole[not(ancestor::draw:text-box)]
2613       | .//draw:text-box"
2614       mode="extract">
2615       <xsl:with-param name="calledPos" select="$calledPos"/>
2616     </xsl:apply-templates>
2617 -->
2618    
2619 </xsl:template>
2620
2621
2622 <xsl:template name="multimedia.bottom">
2623     <xsl:param name="calledPos" select="'bottom'"/>
2624     <!--<DEBUG>MultimediaBottom sur : <xsl:value-of select="name(current())"/></DEBUG>-->
2625
2626     <xsl:apply-templates
2627       select=".//draw:image[(../@text:anchor-type='paragraph'
2628       or ../text:anchor-type='as-char')
2629       and not(ancestor::draw:text-box)]
2630       | .//draw:text-box"
2631       mode="extract">
2632       <xsl:with-param name="calledPos" select="$calledPos"/>
2633     </xsl:apply-templates>
2634 </xsl:template>
2635
2636   <!-- Frames - Dispatch -->
2637
2638 <xsl:template match="draw:text-box" mode="extract">
2639     <xsl:param name="calledPos"/>
2640
2641     <xsl:variable name="StyleMM" select=".//draw:frame/@draw:style-name"/>
2642     <xsl:variable name="style" select="/office:document/office:automatic-styles/style:style[@style:name=$StyleMM]"/>
2643
2644     <xsl:variable name="currentPos">
2645     <xsl:choose>
2646         <xsl:when test="$style/style:graphic-properties/@style:vertical-pos!=''">
2647             <xsl:value-of select="$style/style:graphic-properties/@style:vertical-pos"/>
2648         </xsl:when>
2649         <xsl:otherwise>top</xsl:otherwise>
2650     </xsl:choose>
2651     </xsl:variable>
2652    
2653     <xsl:variable name="parentStyleName"
2654       select="$style/@style:parent-style-name"/>
2655
2656     <!--<DEBUG>DRAW:TEXT-BOX-EXTRACT :
2657         Called-pos :<xsl:value-of select="$calledPos"/>
2658         Current-pos :<xsl:value-of select="$currentPos"/>
2659         StyleMM :<xsl:value-of select="$StyleMM"/>
2660         parentStyleName :<xsl:value-of select="$parentStyleName"/>
2661     </DEBUG>-->
2662
2663     <xsl:if test="$calledPos=$currentPos or
2664       ($calledPos='top' and $currentPos!='bottom')">
2665         <xsl:if test="$parentStyleName='Note'">
2666             <xsl:call-template name="note"/>
2667         </xsl:if>
2668         <xsl:if test="$parentStyleName='Frame' or $parentStyleName='Graphics' or $parentStyleName='Formula'">
2669             <xsl:call-template name="figure"/>
2670         </xsl:if>
2671     </xsl:if>
2672   </xsl:template>
2673
2674   <!-- Frames - Figure -->
2675
2676   <xsl:template name="figure">
2677     <!--<DEBUG>figure sur : <xsl:value-of select="name(current())"/></DEBUG>-->
2678     <figure>
2679       <xsl:attribute name="id">
2680             <xsl:value-of select="text:p/text:sequence/@text:ref-name"/>
2681       </xsl:attribute>
2682       <title>
2683             <xsl:apply-templates select="text:p"/>
2684       </title>
2685       <mediaobject>
2686         <xsl:if test=".//draw:frame[(@text:anchor-type='paragraph')
2687               or (@text:anchor-type='as-char')]">
2688             <xsl:apply-templates select=".//draw:image | .//draw:object | .//draw:object-ole" mode="extract">
2689                 <xsl:with-param name="inbox" select="1"/>
2690             </xsl:apply-templates>
2691         </xsl:if>
2692 <!-- remplace par script ci-dessus
2693             <xsl:apply-templates select="
2694               .//draw:image[(@text:anchor-type='paragraph')
2695               or (@text:anchor-type='as-char')]
2696               |
2697               .//draw:object[(@text:anchor-type='paragraph')
2698               or (@text:anchor-type='as-char')]
2699               |
2700               .//draw:object-ole[(@text:anchor-type='paragraph')
2701               or (@text:anchor-type='as-char')]
2702               "
2703               mode="extract">
2704             <xsl:with-param name="inbox" select="1"/>
2705             </xsl:apply-templates>
2706 -->
2707       </mediaobject>
2708     </figure>
2709   </xsl:template>
2710
2711   <!-- Frames - Note -->
2712
2713   <xsl:template name="note">
2714     <xsl:variable name="parentStyleName"
2715       select="/office:document/office:automatic-styles/
2716       style:style[@style:name=(current()/@text:style-name)]/
2717       @style:parent-style-name"/>
2718     <note>
2719       <xsl:apply-templates select="text:p[@text:style-name='Heading'
2720     or $parentStyleName='Heading']"
2721     mode="includeTitle"/>
2722       <xsl:apply-templates mode="frame"/>
2723     </note>
2724   </xsl:template>
2725
2726   <xsl:template match="*" mode="frame">
2727     <xsl:call-template name="allTags">
2728       <xsl:with-param name="source" select="'frame'"/>
2729     </xsl:call-template>
2730   </xsl:template>
2731
2732   <!--
2733   ======
2734   IMAGES
2735   ======
2736   -->
2737 <xsl:template match="draw:image[not(preceding-sibling::draw:object)]" mode="extract">
2738     <xsl:param name="inbox"/>
2739     <xsl:param name="calledPos"/>
2740     <xsl:variable name="StyleMM" select="../@draw:style-name"/>
2741
2742     <xsl:variable name="style" select="/office:document/office:automatic-styles/style:style[@style:name=$StyleMM]"/>
2743     <xsl:variable name="parentStyleName" select="$style/@style:parent-style-name"/>
2744     <xsl:variable name="currentPos">
2745       <xsl:choose>
2746     <xsl:when test="$style/style:graphic-properties/@style:vertical-pos!=''">
2747       <xsl:value-of select="$style/style:graphic-properties/@style:vertical-pos"/>
2748     </xsl:when>
2749     <xsl:otherwise>top</xsl:otherwise>
2750       </xsl:choose>
2751     </xsl:variable>
2752     <!--<DEBUG>draw:image sur : <xsl:value-of select="name(current())"/></DEBUG>-->
2753
2754 <!--
2755     <DEBUG>DRAW:IMAGE-EXTRACT :
2756         Called-pos :<xsl:value-of select="$calledPos"/>
2757         Current-pos :<xsl:value-of select="$currentPos"/>
2758         StyleMM :<xsl:value-of select="$StyleMM"/>
2759         parentStyleName :<xsl:value-of select="$parentStyleName"/>
2760         Inbox :<xsl:value-of select="$inbox"/>
2761     </DEBUG>
2762 -->
2763     <xsl:choose>
2764         <xsl:when test="substring-before(@xlink:href,'/')='#Pictures'
2765             or office:binary-data">
2766                 <xsl:if test="$calledPos=$currentPos or ($calledPos='top' and $currentPos!='bottom')">
2767                 <para>WARNING ! Incorporated graphics are not supported.</para>
2768             </xsl:if>
2769         </xsl:when>
2770         <xsl:otherwise>
2771             <xsl:choose>
2772                 <xsl:when test="$inbox=1">
2773                     <xsl:call-template name="image"/>
2774                 </xsl:when>
2775             <xsl:otherwise>
2776                 <xsl:if test="$calledPos=$currentPos or ($calledPos='top' and $currentPos!='bottom')">
2777                     <mediaobject>
2778                         <xsl:call-template name="image"/>
2779                     </mediaobject>
2780                 </xsl:if>
2781             </xsl:otherwise>
2782             </xsl:choose>
2783         </xsl:otherwise>
2784     </xsl:choose>
2785   </xsl:template>
2786
2787 <xsl:template name="image">
2788     <imageobject>
2789         <imagedata>
2790             <xsl:attribute name="fileref">
2791                 <xsl:value-of select="@xlink:href"/>
2792             </xsl:attribute>
2793             <xsl:attribute name="width">
2794                 <xsl:value-of select="../@svg:width"/>
2795             </xsl:attribute>
2796             <xsl:attribute name="depth">
2797                 <xsl:value-of select="../@svg:height"/>
2798             </xsl:attribute>
2799         </imagedata>
2800     </imageobject>
2801     <xsl:apply-templates/>
2802 </xsl:template>
2803
2804 <xsl:template name="inlineobject">
2805     <imageobject>
2806         <imagedata>
2807             <xsl:attribute name="fileref">
2808                 <xsl:value-of select="concat('images/', ../@draw:name, '.png')"/>
2809             </xsl:attribute>
2810             <xsl:attribute name="width">
2811                 <xsl:value-of select="../@svg:width"/>
2812             </xsl:attribute>
2813             <xsl:attribute name="depth">
2814                 <xsl:value-of select="../@svg:height"/>
2815             </xsl:attribute>
2816         </imagedata>
2817     </imageobject>
2818     <xsl:apply-templates/>
2819 </xsl:template>
2820
2821
2822
2823 <xsl:template match="text:p[@text:style-name='Illustration']|
2824     text:p[@text:style-name='Figure']">
2825     <xsl:choose>
2826       <xsl:when test="text:sequence">
2827     <xsl:apply-templates
2828       select="text:sequence/following-sibling::node()"/>
2829       </xsl:when>
2830       <xsl:otherwise>
2831     <xsl:apply-templates/>
2832       </xsl:otherwise>
2833     </xsl:choose>
2834 </xsl:template>
2835
2836 <!-- Inlines images -->
2837 <xsl:template match="draw:image[(../@text:anchor-type='as-char') and not(preceding-sibling::draw:object)]">
2838     <!--<DEBUG>Inlines images sur : <xsl:value-of select="name(current())"/></DEBUG>-->
2839     <inlinemediaobject>
2840       <xsl:call-template name="image"/>
2841       <xsl:apply-templates select="following-sibling::svg:desc" mode="inlinemediaobject"/>
2842     </inlinemediaobject>
2843 </xsl:template>
2844
2845 <!-- Inlines object -->
2846 <xsl:template match="draw:image[(../@text:anchor-type='as-char') and (preceding-sibling::draw:object)]">
2847     <!--<DEBUG>Inlines object sur : <xsl:value-of select="name(current())"/></DEBUG>-->
2848     <inlinemediaobject>
2849       <xsl:call-template name="inlineobject"/>
2850       <xsl:apply-templates select="following-sibling::svg:desc" mode="inlinemediaobject"/>
2851     </inlinemediaobject>
2852 </xsl:template>
2853
2854   <xsl:template match="draw:a[draw:image[../@text:anchor-type='as-char']]">
2855     <ulink>
2856       <xsl:attribute name="url">
2857     <xsl:value-of select="@xlink:href"/>
2858       </xsl:attribute>
2859       <xsl:if test="@office:target-frame-name!=''">
2860     <xsl:attribute name="type">
2861       <xsl:value-of select="@office:target-frame-name"/>
2862     </xsl:attribute>
2863       </xsl:if>
2864       <xsl:apply-templates/>
2865     </ulink>
2866   </xsl:template>
2867
2868   <xsl:template match="svg:desc" mode="inlinemediaobject">
2869     <textobject><phrase><xsl:apply-templates/></phrase></textobject>
2870   </xsl:template>
2871   <xsl:template match="svg:desc"/>
2872
2873   <!--
2874   ====================
2875   OBJECTS, OLE OBJECTS
2876   ====================
2877
2878   We treat objects and OLE objects as images
2879   -->
2880 <xsl:template match="draw:object|draw:object-ole" mode="extract">
2881     <!--
2882     Tells wether this object is contained within a box (a text-box for example)
2883     -->
2884     <xsl:param name="inbox"/>
2885
2886     <!--<DEBUG>draw:object|draw:object-ole sur : <xsl:value-of select="name(current())"/>
2887     inbox <xsl:value-of select="$inbox"/></DEBUG>-->
2888
2889     <xsl:variable name="imageref" select="concat('images/', ../@draw:name, '.png')"/>
2890     <xsl:choose>
2891         <xsl:when test="$inbox = 1">
2892             <xsl:call-template name="inlineobject"/>
2893             <!--
2894             <xsl:call-template name="objectImage">
2895               <xsl:with-param name="fileref" select="$imageref"/>
2896             </xsl:call-template>
2897             -->
2898         </xsl:when>
2899         <xsl:otherwise>
2900             <mediaobject>
2901                 <xsl:call-template name="inlineobject"/>
2902             </mediaobject>
2903         <!--
2904             <mediaobject>
2905                 <xsl:call-template name="objectImage">
2906                     <xsl:with-param name="fileref" select="$imageref"/>
2907                 </xsl:call-template>
2908             </mediaobject>
2909             -->
2910         </xsl:otherwise>
2911     </xsl:choose>
2912 </xsl:template>
2913
2914 <!-- n'est plus utilise
2915 <xsl:template name="objectImage">
2916     <xsl:param name="fileref"/>
2917     <imageobject>
2918       <imagedata>
2919     <xsl:attribute name="fileref">
2920       <xsl:value-of select="$fileref"/>
2921     </xsl:attribute>
2922       </imagedata>
2923     </imageobject>
2924     <xsl:apply-templates/>
2925   </xsl:template>
2926 -->
2927   <!--
2928   ======
2929   TABLES
2930   ======
2931   -->
2932 <xsl:template match="table:table" name="table">
2933     <xsl:param name="titlePosition" select="''"/>
2934     <xsl:param name="colsListBrut">
2935         <xsl:call-template name="colsList"/>
2936     </xsl:param>
2937
2938     <!-- Retrait des doublons et ordonnancement de la liste -->
2939     <xsl:param name="fineColsList">
2940         <xsl:call-template name="fineColsList">
2941             <xsl:with-param name="colsListBrut" select="$colsListBrut"/>
2942         </xsl:call-template>
2943     </xsl:param>
2944     <xsl:param name="colsList">
2945         <xsl:call-template name="ascendantcolsList">
2946             <xsl:with-param name="colsList" select="$fineColsList"/>
2947         </xsl:call-template>
2948     </xsl:param>
2949     <xsl:param name="colsNumber2">
2950         <xsl:call-template name="colsNumber2">
2951             <xsl:with-param name="colsList" select="$colsList"/>
2952         </xsl:call-template>
2953     </xsl:param>
2954
2955 <!--
2956     <DEBUG>TABLE:TABLE :
2957         titlePosition :<xsl:value-of select="$titlePosition"/>
2958         colsListBrut :<xsl:value-of select="count($colsListBrut)"/>
2959         fineColsList :<xsl:value-of select="count($fineColsList)"/>
2960         colsList :<xsl:value-of select="($colsList)"/>
2961         colsNumber2 :<xsl:value-of select="$colsNumber2"/>
2962     </DEBUG>
2963 -->
2964
2965
2966     <xsl:choose>
2967         <xsl:when test="following-sibling::*[1]/text:sequence/@text:name='Table'">
2968             <xsl:call-template name="formalTable">
2969                 <xsl:with-param name="titlePosition" select="'after'"/>
2970                 <xsl:with-param name="colsList" select="$colsList"/>
2971                 <xsl:with-param name="colsNumber" select="$colsNumber2"/>
2972             </xsl:call-template>
2973         </xsl:when>
2974         <xsl:otherwise>
2975             <xsl:choose>
2976                 <xsl:when test="preceding-sibling::*[1]/text:sequence/@text:name='Table'">
2977                     <xsl:call-template name="formalTable">
2978                         <xsl:with-param name="titlePosition" select="'before'"/>
2979                         <xsl:with-param name="colsList" select="$colsList"/>
2980                         <xsl:with-param name="colsNumber" select="$colsNumber2"/>
2981                     </xsl:call-template>
2982                 </xsl:when>
2983                 <xsl:otherwise>
2984                     <xsl:call-template name="informalTable">
2985                         <xsl:with-param name="colsList" select="$colsList"/>
2986                         <xsl:with-param name="colsNumber" select="$colsNumber2"/>
2987                     </xsl:call-template>
2988                 </xsl:otherwise>
2989             </xsl:choose>
2990         </xsl:otherwise>
2991     </xsl:choose>
2992 </xsl:template>
2993
2994
2995
2996   <!-- Tables - "Formal" Table -->
2997   <xsl:template name="formalTable">
2998     <xsl:param name="titlePosition"/>
2999     <xsl:param name="colsList"/>
3000     <xsl:param name="colsNumber"/>
3001     <table>
3002       <!-- Title and 'id' attribute -->
3003       <xsl:if test="$titlePosition='before'">
3004     <xsl:attribute name="id">
3005       <xsl:value-of
3006         select="preceding-sibling::*[1]/text:sequence/@text:ref-name"/>
3007     </xsl:attribute>
3008     <xsl:apply-templates select="preceding-sibling::*[1]" mode="tableTitle"/>
3009       </xsl:if>
3010       <xsl:if test="$titlePosition='after'">
3011     <xsl:attribute name="id">
3012       <xsl:value-of
3013         select="following-sibling::*[1]/text:sequence/@text:ref-name"/>
3014     </xsl:attribute>
3015     <xsl:apply-templates select="following-sibling::*[1]" mode="tableTitle"/>
3016       </xsl:if>
3017       <tgroup>
3018     <xsl:attribute name="cols">
3019       <xsl:value-of select="$colsNumber"/>
3020     </xsl:attribute>
3021     <xsl:call-template name="colspecAttrib">
3022       <xsl:with-param name="colsList" select="$colsList"/>
3023       <xsl:with-param name="colsNumber" select="$colsNumber"/>
3024     </xsl:call-template>
3025     <xsl:apply-templates select="table:table-row|table:table-header-rows/table:table-row">
3026       <xsl:with-param name="colsList" select="$colsList"/>
3027     </xsl:apply-templates>
3028       </tgroup>
3029     </table>
3030   </xsl:template>
3031
3032
3033   <!-- Table - Formaltable title -->
3034 <xsl:template match="*[text:sequence]" mode="tableTitle">
3035     <title>
3036         <xsl:apply-templates select="text:sequence/following-sibling::node()"/>
3037     </title>
3038 </xsl:template>
3039
3040
3041   <!-- Tables - InformalTables -->
3042 <xsl:template name="informalTable">
3043     <xsl:param name="colsList"/>
3044     <xsl:param name="colsNumber"/>
3045
3046 <!--
3047     <DEBUG>informalTable :
3048         colsList :<xsl:value-of select="($colsList)"/>
3049         colsNumber :<xsl:value-of select="$colsNumber"/>
3050     </DEBUG>
3051 -->
3052     <informaltable>
3053         <tgroup>
3054             <xsl:attribute name="cols">
3055                 <xsl:value-of select="$colsNumber"/>
3056             </xsl:attribute>
3057             <xsl:call-template name="colspecAttrib">
3058                 <xsl:with-param name="colsList" select="$colsList"/>
3059                 <xsl:with-param name="colsNumber" select="$colsNumber"/>
3060             </xsl:call-template>
3061             <xsl:apply-templates select="table:table-row|table:table-header-rows/table:table-row">
3062                 <xsl:with-param name="colsList" select="$colsList"/>
3063             </xsl:apply-templates>
3064         </tgroup>
3065     </informaltable>
3066 </xsl:template>
3067
3068   <!--
3069   =================
3070   COLUMNS & COLSPEC
3071   =================
3072   -->
3073
3074   <!-- Tables - Colspec attribute -->
3075 <xsl:template name="colspecAttrib">
3076     <xsl:param name="colsList"/>
3077     <xsl:param name="colsNumber"/>
3078     <xsl:param name="val1" select="0"/>
3079     <xsl:param name="val2" select="substring-before($colsList,';')"/>
3080     <xsl:param name="width">
3081       <xsl:call-template name="roundValue">
3082     <xsl:with-param name="inputValue" select="$val2 - $val1"/>
3083       </xsl:call-template>
3084     </xsl:param>
3085     <xsl:param name="cycle" select="1"/>
3086     <xsl:if test="$colsNumber >= $cycle">
3087       <colspec>
3088     <xsl:attribute name="colname">
3089       <xsl:value-of select="concat('c',$cycle)"/>
3090     </xsl:attribute>
3091     <xsl:attribute name="colwidth">
3092       <xsl:value-of select="concat($width,$measureUnit)"/>
3093     </xsl:attribute>
3094       </colspec>
3095       <xsl:call-template name="colspecAttrib">
3096     <xsl:with-param name="colsList" select="substring-after($colsList,';')"/>
3097     <xsl:with-param name="cycle" select="$cycle + 1"/>
3098     <xsl:with-param name="val1" select="$val2"/>
3099     <xsl:with-param name="colsNumber" select="$colsNumber"/>
3100       </xsl:call-template>
3101     </xsl:if>
3102 </xsl:template>
3103
3104   <!--
3105   Tables - ascendantcolsList, colsListtrunc, littleElt
3106   Ordonnent de facon ascendante les elements de 'colsList"
3107   -->
3108 <xsl:template name="ascendantcolsList">
3109     <xsl:param name="colsList"/>
3110     <xsl:param name="eltNumber">
3111       <xsl:call-template name="colsNumber2">
3112     <xsl:with-param name="colsList" select="$colsList"/>
3113       </xsl:call-template>
3114     </xsl:param>
3115     <xsl:param name="littleElt">
3116       <xsl:call-template name="littleElt">
3117     <xsl:with-param name="colsListTest" select="$colsList"/>
3118       </xsl:call-template>
3119     </xsl:param>
3120     <xsl:param name="colsListtrunc">
3121       <xsl:call-template name="colsListtrunc">
3122     <xsl:with-param name="colsListTest" select="$colsList"/>
3123     <xsl:with-param name="littleElt" select="$littleElt"/>
3124       </xsl:call-template>
3125     </xsl:param>
3126     <xsl:param name="newList" select="''"/>
3127     <xsl:choose>
3128       <xsl:when test="not(contains($colsListtrunc,';'))">
3129     <xsl:value-of select="concat($newList, $littleElt,';')"/>
3130       </xsl:when>
3131       <xsl:otherwise>
3132     <xsl:call-template name="ascendantcolsList">
3133       <xsl:with-param name="newList" select="concat($newList, $littleElt,';')"/>
3134       <xsl:with-param name="colsList" select="$colsListtrunc"/>
3135     </xsl:call-template>
3136       </xsl:otherwise>
3137     </xsl:choose>
3138 </xsl:template>
3139
3140 <xsl:template name="colsListtrunc">
3141     <xsl:param name="colsListTest"/>
3142     <xsl:param name="littleElt"/>
3143     <xsl:param name="eltCompare" select="substring-before($colsListTest,';')"/>
3144     <xsl:param name="fragmentBefore" select="''"/>
3145     <xsl:param name="fragmentAfter" select="substring-after($colsListTest,';')"/>
3146     <xsl:choose>
3147       <xsl:when test="($littleElt != $eltCompare) and ($fragmentAfter != '')">
3148     <xsl:call-template name="colsListtrunc">
3149       <xsl:with-param name="fragmentBefore">
3150         <xsl:value-of select="concat($fragmentBefore,';',$eltCompare)"/>
3151       </xsl:with-param>
3152       <xsl:with-param name="littleElt" select="$littleElt"/>
3153       <xsl:with-param name="colsListTest" select="$fragmentAfter"/>
3154     </xsl:call-template>
3155       </xsl:when>
3156       <xsl:otherwise>
3157     <xsl:choose>
3158       <xsl:when test="starts-with(concat($fragmentBefore,';',$fragmentAfter),';')">
3159         <xsl:value-of select="substring-after(concat($fragmentBefore,';',$fragmentAfter),';')"/>
3160       </xsl:when>
3161       <xsl:otherwise>
3162         <xsl:value-of select="concat($fragmentBefore,';',$fragmentAfter)"/>
3163       </xsl:otherwise>
3164     </xsl:choose>
3165       </xsl:otherwise>
3166     </xsl:choose>
3167 </xsl:template>
3168
3169 <xsl:template name="littleElt">
3170     <xsl:param name="colsListTest"/>
3171     <xsl:param name="eltBaseTest" select="substring-before($colsListTest,';')"/>
3172     <xsl:param name="eltNumber">
3173       <xsl:call-template name="colsNumber2">
3174     <xsl:with-param name="colsList" select="$colsListTest"/>
3175       </xsl:call-template>
3176     </xsl:param>
3177     <xsl:param name="actualMinDiff" select="$eltBaseTest"/>
3178     <xsl:choose>
3179       <xsl:when test="$eltNumber > 0">
3180     <xsl:call-template name="littleElt">
3181       <xsl:with-param name="actualMinDiff">
3182         <xsl:choose>
3183           <xsl:when test="$actualMinDiff > $eltBaseTest">
3184         <xsl:value-of select="$eltBaseTest"/>
3185           </xsl:when>
3186           <xsl:otherwise>
3187         <xsl:value-of select="$actualMinDiff"/>
3188           </xsl:otherwise>
3189         </xsl:choose>
3190       </xsl:with-param>
3191       <xsl:with-param name="colsListTest" select="substring-after($colsListTest,';')"/>
3192     </xsl:call-template>
3193       </xsl:when>
3194       <xsl:otherwise>
3195     <xsl:value-of select="$actualMinDiff"/>
3196       </xsl:otherwise>
3197     </xsl:choose>
3198 </xsl:template>
3199
3200
3201   <!--
3202   Tables - fineColsList et testDoublon
3203   Elimine les blancs et les doublon de "colsList"
3204   -->
3205 <xsl:template name="fineColsList">
3206     <xsl:param name="colsListBrut"/>
3207     <xsl:param name="eltNumber">
3208       <xsl:call-template name="colsNumber2">
3209     <xsl:with-param name="colsList" select="$colsListBrut"/>
3210       </xsl:call-template>
3211     </xsl:param>
3212     <xsl:param name="colsListTest" select="substring-after($colsListBrut,';')"/>
3213     <xsl:param name="eltBaseTest" select="normalize-space(substring-before($colsListBrut,';'))"/>
3214     <xsl:param name="eltTestresult"><!-- 'True' if this is a double -->
3215       <xsl:call-template name="testDoublon">
3216     <xsl:with-param name="colsListTest" select="$colsListTest"/>
3217     <xsl:with-param name="eltBaseTest" select="$eltBaseTest"/>
3218       </xsl:call-template>
3219     </xsl:param>
3220     <xsl:param name="newList" select="''"/>
3221     <xsl:choose>
3222       <xsl:when test="$eltNumber = 1">
3223     <xsl:value-of select="concat(normalize-space($eltBaseTest),';',$newList)"/>
3224       </xsl:when>
3225       <xsl:otherwise>
3226     <xsl:call-template name="fineColsList">
3227       <xsl:with-param name="newList">
3228         <xsl:choose>
3229           <xsl:when test="$eltTestresult = 'false'">
3230         <xsl:value-of select="concat($eltBaseTest,';', $newList)"/>
3231           </xsl:when>
3232           <xsl:otherwise>
3233         <xsl:value-of select="$newList"/>
3234           </xsl:otherwise>
3235         </xsl:choose>
3236       </xsl:with-param>
3237       <xsl:with-param name="colsListBrut" select="$colsListTest"/>
3238     </xsl:call-template>
3239       </xsl:otherwise>
3240     </xsl:choose>
3241 </xsl:template>
3242
3243 <xsl:template name="testDoublon">
3244     <xsl:param name="colsListTest"/>
3245     <xsl:param name="eltNumber">
3246       <xsl:call-template name="colsNumber2">
3247     <xsl:with-param name="colsList" select="$colsListTest"/>
3248       </xsl:call-template>
3249     </xsl:param>
3250     <xsl:param name="eltBaseTest"/>
3251     <xsl:param name="eltListTest" select="normalize-space(substring-before($colsListTest,';'))"/>
3252
3253     <xsl:choose>
3254       <xsl:when test="$eltBaseTest = $eltListTest">
3255     <xsl:value-of select="'true'"/>
3256       </xsl:when>
3257       <xsl:when test="$eltListTest =''">
3258     <xsl:value-of select="'false'"/>
3259       </xsl:when>
3260       <xsl:otherwise>
3261     <xsl:choose>
3262       <xsl:when test="$eltNumber >= 1">
3263         <xsl:call-template name="testDoublon">
3264           <xsl:with-param name="colsListTest" select="substring-after($colsListTest,';')"/>
3265           <xsl:with-param name="eltBaseTest" select="$eltBaseTest"/>
3266         </xsl:call-template>
3267       </xsl:when>
3268       <xsl:otherwise>
3269         <xsl:value-of select="'false'"/>
3270       </xsl:otherwise>
3271     </xsl:choose>
3272       </xsl:otherwise>
3273     </xsl:choose>
3274 </xsl:template>
3275
3276   <!--
3277   Tables - colsNumber2
3278   Cree les numeros (1, 2, etc.) qui formeront les element de colspec (c1,c2, etc)
3279   -->
3280 <xsl:template name="colsNumber2">
3281     <xsl:param name="colsList"/>
3282     <xsl:param name="cycle" select="0"/>
3283     <xsl:choose>
3284       <xsl:when test="contains($colsList,';')">
3285     <xsl:call-template name="colsNumber2">
3286       <xsl:with-param name="colsList" select="substring-after($colsList,';')"/>
3287       <xsl:with-param name="cycle" select="$cycle + 1"/>
3288     </xsl:call-template>
3289       </xsl:when>
3290       <xsl:otherwise>
3291     <xsl:value-of select="$cycle"/>
3292       </xsl:otherwise>
3293     </xsl:choose>
3294 </xsl:template>
3295
3296   <!-- Tables - colsList -->
3297
3298 <xsl:template name="colsList">
3299     <xsl:param name="stylesURI" select="/office:document/office:automatic-styles/style:style"/>
3300     <xsl:param name="repeatCol"/>
3301     <xsl:param name="cellAncestorNbr"/>
3302     <xsl:for-each select="descendant::table:table-column">
3303        
3304         <!--
3305         <xsl:variable name="mmm" select="@table:style-name"/>
3306         <xsl:variable name="nnn" select="$stylesURI[@style:name = $mmm]"/>
3307         <xsl:message>
3308         template name="colsList"
3309         noeud pere : <xsl:value-of select="../@table:name"/>
3310         table:number-columns-repeated : <xsl:value-of select="@table:number-columns-repeated"/>
3311         Style pere : <xsl:value-of select="../@table:style-name"/>
3312         Style noeud : <xsl:value-of select="$mmm"/>
3313         stylesURI : <xsl:value-of select="$stylesURI"/>
3314         Style trouve : <xsl:value-of select="$nnn/@style:family"/>
3315         Style trouve : <xsl:value-of select="$nnn/style:table-column-properties/@style:column-width"/>
3316         </xsl:message>
3317         -->
3318
3319         <xsl:call-template name="colPosition">
3320             <xsl:with-param name="origineValue">
3321                   <!-- retourne la distance d'origine de la sous-table
3322                   depuis la cellule-ancetre la plus elevee -->
3323                 <xsl:choose>
3324                     <xsl:when test="parent::table:table[@table:is-sub-table = 'true']">
3325                         <xsl:call-template name="subtableOrigine">
3326                             <xsl:with-param name="cellAncestorNbr" select="count(ancestor::table:table-cell)"/>
3327                             <xsl:with-param name="stylesURI" select="$stylesURI"/>
3328                         </xsl:call-template>
3329                     </xsl:when>
3330                     <xsl:otherwise>0</xsl:otherwise>
3331                 </xsl:choose>
3332             </xsl:with-param>
3333             <xsl:with-param name="stylesURI" select="$stylesURI"/>
3334             <xsl:with-param name="repeatCol">
3335                 <xsl:choose>
3336                     <xsl:when test="@table:number-columns-repeated">
3337                       <xsl:value-of select="@table:number-columns-repeated"/>
3338                     </xsl:when>
3339                     <xsl:otherwise>
3340                       <xsl:value-of select="1"/>
3341                     </xsl:otherwise>
3342                 </xsl:choose>
3343             </xsl:with-param>
3344         </xsl:call-template>
3345     </xsl:for-each>
3346 </xsl:template>
3347
3348   <!--
3349   Determine le distance a laquelle debute la sous-table / a la table
3350   pour la colonne en cours
3351   -->
3352 <xsl:template name="subtableOrigine">
3353     <xsl:param name="cumulOrigineValue" select="0"/>
3354     <xsl:param name="cellAncestorNbr"/>
3355     <xsl:param name="stylesURI"/>
3356     <xsl:param name="precedingCellNumber"
3357       select="count(ancestor::table:table-cell[$cellAncestorNbr]
3358       /preceding-sibling::table:table-cell) -
3359       count(ancestor::table:table-cell[$cellAncestorNbr]
3360       /preceding-sibling::table:table-cell[@table:number-columns-spanned]) +
3361       sum(ancestor::table:table-cell[$cellAncestorNbr]/
3362       preceding-sibling::table:table-cell/@table:number-columns-spanned)"
3363       />
3364
3365     <xsl:param name="columnValue">
3366         <xsl:choose>
3367             <xsl:when test="$precedingCellNumber > 0">
3368                 <xsl:apply-templates
3369                     select="ancestor::table:table-cell[$cellAncestorNbr]/parent::table:table-row/
3370                     parent::table:table/child::table:table-column[1]|
3371                     ancestor::table:table-cell[$cellAncestorNbr]/parent::table:table-row/
3372                     parent::table:table-header-rows/parent::table:table/child::table:table-column[1]"
3373                     mode="cellOrigine">
3374                     <xsl:with-param name="precedingCellNumber" select="$precedingCellNumber"/>
3375                     <xsl:with-param name="stylesURI" select="$stylesURI"/>
3376                 </xsl:apply-templates>
3377             </xsl:when>
3378             <xsl:otherwise>0</xsl:otherwise>
3379         </xsl:choose>
3380     </xsl:param>
3381
3382 <!--
3383 <xsl:message>
3384 template name="subtableOrigine"
3385 cellAncestorNbr : <xsl:value-of select="$cellAncestorNbr"/>
3386 precedingCellNumber : <xsl:value-of select="$precedingCellNumber"/>
3387 columnValue : <xsl:value-of select="$columnValue"/>
3388 </xsl:message>
3389 -->
3390     <!-- Appel de l'ancetre no X -->
3391     <xsl:choose>
3392       <xsl:when test="$cellAncestorNbr > 1">
3393     <xsl:call-template name="subtableOrigine">
3394       <xsl:with-param name="cellAncestorNbr" select="$cellAncestorNbr - 1"/>
3395       <xsl:with-param name="cumulOrigineValue" select="$cumulOrigineValue + $columnValue"/>
3396       <xsl:with-param name="stylesURI" select="$stylesURI"/>
3397     </xsl:call-template>
3398       </xsl:when>
3399       <xsl:otherwise>
3400     <xsl:value-of select="$cumulOrigineValue + $columnValue"/>
3401       </xsl:otherwise>
3402     </xsl:choose>
3403 </xsl:template>
3404
3405 <xsl:template match="table:table-column" mode="cellOrigine" name="cellOrigine">
3406     <xsl:param name="stylesURI"/>
3407     <xsl:param name="precedingCellNumber"/>
3408     <xsl:param name="colName" select="string(@table:style-name)"/>
3409    
3410     <xsl:param name="repetingCol">
3411         <xsl:choose>
3412             <xsl:when test="@table:number-columns-repeated">
3413                 <xsl:value-of select="@table:number-columns-repeated"/>
3414             </xsl:when>
3415             <xsl:otherwise>1</xsl:otherwise>
3416         </xsl:choose>
3417     </xsl:param>
3418
3419     <xsl:param name="colsNamesList" select="''"/>
3420     <xsl:param name="origineValue" select="0"/>
3421     <xsl:param name="actualWidth">
3422         <xsl:value-of select="substring-before($stylesURI[@style:name=$colName]
3423     /style:table-column-properties/@style:column-width,$measureUnit)"/>
3424     </xsl:param>
3425    
3426 <!--
3427 <xsl:message>
3428 template name="cellOrigine"
3429 precedingCellNumber : <xsl:value-of select="$precedingCellNumber"/>
3430 colName : <xsl:value-of select="$colName"/>
3431 colsNamesList : <xsl:value-of select="$colsNamesList"/>
3432 origineValue : <xsl:value-of select="$origineValue"/>
3433 repetingCol : <xsl:value-of select="$repetingCol"/>
3434 actualWidth : <xsl:value-of select="$actualWidth"/>
3435 </xsl:message>
3436 -->
3437     <xsl:choose>
3438         <xsl:when test="$repetingCol >= $precedingCellNumber">
3439             <xsl:value-of select="$origineValue + ($actualWidth * $precedingCellNumber)"/>
3440         </xsl:when>
3441         <xsl:otherwise>
3442             <xsl:apply-templates select="following-sibling::table:table-column[1]" mode="cellOrigine">
3443                 <xsl:with-param name="precedingCellNumber" select="$precedingCellNumber -  $repetingCol"/>
3444                 <xsl:with-param name="colsNamesList" select="concat($colsNamesList,';',$colName)"/>
3445                 <xsl:with-param name="origineValue" select="$origineValue + ($actualWidth * $repetingCol)"/>
3446                 <xsl:with-param name="stylesURI" select="$stylesURI"/>
3447             </xsl:apply-templates>
3448         </xsl:otherwise>
3449     </xsl:choose>
3450 </xsl:template>
3451
3452 <xsl:template name="colPosition">
3453     <!-- externes -->
3454     <xsl:param name="stylesURI"/>
3455     <xsl:param name="origineValue"/>
3456     <xsl:param name="concat"/>
3457     <xsl:param name="repeatCol"/>
3458     <xsl:param name="content"/>
3459     <xsl:param name="precedingColsSum">
3460         <xsl:choose>
3461             <xsl:when test="preceding-sibling::table:table-column">
3462                 <xsl:call-template name="precedingColsSum">
3463                     <xsl:with-param name="stylesURI" select="$stylesURI"/>
3464                 </xsl:call-template>
3465             </xsl:when>
3466             <xsl:otherwise>0</xsl:otherwise>
3467         </xsl:choose>
3468     </xsl:param>
3469     <xsl:param name="actualColWidth">
3470         <xsl:value-of select="
3471             $stylesURI[@style:name=current()/@table:style-name]/*/@style:column-width
3472             "/>
3473     </xsl:param>
3474     <xsl:param name="colWidthValue">
3475         <xsl:value-of select="substring-before($actualColWidth,$measureUnit)"/>
3476     </xsl:param>
3477     <xsl:param name="colWidthRounded">
3478         <xsl:call-template name="roundValue">
3479             <xsl:with-param name="inputValue" select="$origineValue + $precedingColsSum + ($colWidthValue * $repeatCol)"/>
3480         </xsl:call-template>
3481     </xsl:param>
3482     <xsl:value-of select="$colWidthRounded"/>;
3483
3484 <!--
3485 <xsl:message>ColPos origineValue : <xsl:value-of select="$origineValue"/> - repeatCol <xsl:value-of select="$repeatCol"/> - precedingColsSum <xsl:value-of select="$precedingColsSum"/> - actualColWidth <xsl:value-of select="$actualColWidth"/>
3486 </xsl:message>
3487 -->
3488
3489     <xsl:if test="$repeatCol > 1">
3490         <xsl:call-template name="colPosition">
3491             <xsl:with-param name="repeatCol" select="$repeatCol - 1"/>
3492             <xsl:with-param name="stylesURI" select="$stylesURI"/>
3493             <xsl:with-param name="origineValue" select="$origineValue"/>
3494         </xsl:call-template>
3495     </xsl:if>
3496 </xsl:template>
3497
3498 <xsl:template name="precedingColsSum">
3499     <!-- externe -->
3500     <xsl:param name="stylesURI"/>
3501     <!--interne -->
3502     <xsl:param name="cpt" select="'1'"/>
3503     <xsl:param name="cumul" select="'0'"/>
3504     <xsl:param name="precNodeNumber" select="count(preceding-sibling::table:table-column)"/>
3505
3506 <!--
3507 <xsl:messageprecedingColsSum precNodeNumber : <xsl:value-of select="$precNodeNumber"/>
3508 </xsl:message>
3509 -->
3510
3511 <xsl:param name="content">
3512       <xsl:choose>
3513     <xsl:when test="
3514       $stylesURI[@style:name=current()/
3515       preceding-sibling::table:table-column[$precNodeNumber]/
3516       @table:style-name]/
3517       */@style:column-width">
3518       <xsl:value-of select="
3519         $stylesURI[@style:name=current()/
3520         preceding-sibling::table:table-column[$precNodeNumber]/
3521         @table:style-name]/
3522         */@style:column-width"/>
3523     </xsl:when>
3524     <xsl:otherwise>0pt</xsl:otherwise>
3525       </xsl:choose>
3526     </xsl:param>
3527     <xsl:param name="repetCols">
3528       <xsl:choose>
3529     <xsl:when test="preceding-sibling::table:table-column[$precNodeNumber]/
3530       @table:number-columns-repeated">
3531       <xsl:value-of select="number(preceding-sibling::table:table-column
3532         [$precNodeNumber]/@table:number-columns-repeated)"/>
3533     </xsl:when>
3534     <xsl:otherwise>1</xsl:otherwise>
3535       </xsl:choose>
3536     </xsl:param>
3537     <xsl:param name="brutValue">
3538       <xsl:value-of select="substring-before(string($content), $measureUnit)"/>
3539     </xsl:param>
3540     <xsl:param name="actualValue" select="$brutValue * $repetCols"/>
3541     <xsl:if test="$precNodeNumber > 0">
3542       <xsl:call-template name="precedingColsSum">
3543     <xsl:with-param name="precNodeNumber" select="$precNodeNumber - 1"/>
3544     <xsl:with-param name="cumul" select="$cumul + $actualValue"/>
3545     <xsl:with-param name="stylesURI" select="$stylesURI"/>
3546       </xsl:call-template>
3547     </xsl:if>
3548     <xsl:if test="$precNodeNumber = 1">
3549       <xsl:value-of select="$actualValue + $cumul"/>
3550     </xsl:if>
3551 </xsl:template>
3552
3553   <!--
3554   ====
3555   ROWS
3556   ====
3557   -->
3558
3559   <!-- Tables - Rows in table-header -->
3560
3561 <xsl:template match="table:table-header-rows/table:table-row">
3562     <xsl:param name="colsList"/>
3563     <xsl:choose>
3564       <xsl:when test="count(preceding-sibling::table:table-row) != 0"/>
3565       <xsl:otherwise>
3566     <thead>
3567       <xsl:apply-templates select="current()" mode="pas">
3568         <xsl:with-param name="colsList" select="$colsList"/>
3569       </xsl:apply-templates>
3570     </thead>
3571       </xsl:otherwise>
3572     </xsl:choose>
3573 </xsl:template>
3574
3575   <!-- Tables - Rows directly in table or sub-table (body) -->
3576
3577 <xsl:template match="table:table/table:table-row">
3578     <xsl:param name="colsList"/>
3579
3580     <xsl:choose>
3581       <xsl:when test="count(preceding-sibling::table:table-row) != 0"/>
3582       <xsl:otherwise>
3583     <tbody>
3584       <xsl:apply-templates select="current()" mode="pas">
3585         <xsl:with-param name="colsList" select="$colsList"/>
3586       </xsl:apply-templates>
3587     </tbody>
3588       </xsl:otherwise>
3589     </xsl:choose>
3590 </xsl:template>
3591
3592   <!-- Tables - process rows -->
3593
3594 <xsl:template match="table:table-row" mode="pas">
3595     <xsl:param name="colsList"/>
3596     <xsl:param name="rowID" select="generate-id(current())"/>
3597     <xsl:call-template name="rowsProcess">
3598       <xsl:with-param name="colsList" select="$colsList"/>
3599       <xsl:with-param name="rowID" select="$rowID"/>
3600     </xsl:call-template>
3601     <xsl:apply-templates
3602       select="following-sibling::table:table-row[1]"
3603       mode="pas">
3604       <xsl:with-param name="colsList" select="$colsList"/>
3605     </xsl:apply-templates>
3606 </xsl:template>
3607
3608 <xsl:template name="rowsProcess">
3609     <xsl:param name="colsList"/>
3610     <xsl:param name="rowID"/>
3611     <xsl:param name="maxRowsInSubtablesList">
3612       <xsl:choose>
3613     <xsl:when test="table:table-cell/table:table[@table:is-sub-table = 'true']">
3614       <xsl:apply-templates
3615         select="table:table-cell[table:table[@table:is-sub-table = 'true']][1]"
3616         mode="pas"/>
3617     </xsl:when>
3618     <xsl:otherwise>1;</xsl:otherwise>
3619       </xsl:choose>
3620     </xsl:param>
3621     <xsl:param name="maxRowsInSubtables">
3622       <xsl:value-of select="substring-before($maxRowsInSubtablesList,';')"/>
3623     </xsl:param>
3624     <xsl:param name="cycle" select="0"/>
3625     <xsl:param name="lastRow">
3626       <xsl:choose>
3627     <xsl:when test="$maxRowsInSubtables = $cycle">yes</xsl:when>
3628     <xsl:otherwise>no</xsl:otherwise>
3629       </xsl:choose>
3630     </xsl:param>
3631     <xsl:if test="$maxRowsInSubtables > $cycle">
3632       <row>
3633     <xsl:apply-templates
3634       select="descendant::table:table-cell[not(table:table[@table:is-sub-table = 'true'])]"
3635       mode="rowProcess">
3636       <xsl:with-param name="cycle" select="$cycle"/>
3637       <xsl:with-param name="rowID" select="$rowID"/>
3638       <xsl:with-param name="colsList" select="$colsList"/>
3639       <xsl:with-param name="lastRow" select="$lastRow"/>
3640       <xsl:with-param name="maxRowsInSubtables"
3641         select="$maxRowsInSubtables"/>
3642     </xsl:apply-templates>
3643       </row>
3644       <xsl:call-template name="rowsProcess">
3645     <xsl:with-param name="cycle" select="$cycle + 1"/>
3646     <xsl:with-param name="colsList" select="$colsList"/>
3647       </xsl:call-template>
3648     </xsl:if>
3649 </xsl:template>
3650
3651   <!-- Table - Rows tools -->
3652
3653   <!-- Ce modele retourne le nombre de lignes (au sens de la DocBook)
3654   qui precedent la ligne courante -->
3655
3656 <xsl:template match="table:table-row" mode="precedingDepth">
3657     <xsl:param name="rowID"/>
3658     <xsl:param name="depthCumul"  select="0"/>
3659     <xsl:param name="precedingSiblingDepth">
3660       <xsl:for-each select="preceding-sibling::table:table-row">
3661     <xsl:apply-templates select="table:table-cell[1]" mode="pas"/>
3662       </xsl:for-each>
3663     </xsl:param>
3664     <xsl:param name="precedingSiblingDepthValue">
3665       <xsl:choose>
3666     <xsl:when test="$precedingSiblingDepth != ''">
3667       <xsl:call-template name="sumOfList">
3668         <xsl:with-param name="list" select="$precedingSiblingDepth"/>
3669       </xsl:call-template>
3670     </xsl:when>
3671     <xsl:otherwise>0</xsl:otherwise>
3672       </xsl:choose>
3673     </xsl:param>
3674     <xsl:choose>
3675       <xsl:when
3676     test="generate-id(ancestor::table:table-cell[1]/
3677     parent::table:table-row) != $rowID">
3678     <xsl:apply-templates
3679       select="ancestor::table:table-cell[1]/parent::table:table-row"
3680       mode="precedingDepth">
3681       <xsl:with-param
3682         name="depthCumul"
3683         select="$depthCumul + $precedingSiblingDepthValue"/>
3684       <xsl:with-param name="rowID" select="$rowID"/>
3685     </xsl:apply-templates>
3686       </xsl:when>
3687       <xsl:otherwise>
3688     <xsl:value-of select="$depthCumul"/>
3689       </xsl:otherwise>
3690     </xsl:choose>
3691 </xsl:template>
3692
3693   <!--
3694   This template returns the number of lines (in the DocBook meaning)
3695   following the current line.
3696   -->
3697 <xsl:template match="table:table-row" mode="followingDepth">
3698     <xsl:param name="rowID"/>
3699     <xsl:param name="depthCumul"  select="0"/>
3700     <xsl:param name="followingSiblingDepth">
3701       <xsl:for-each select="following-sibling::table:table-row">
3702     <xsl:apply-templates select="table:table-cell[1]" mode="pas"/>
3703       </xsl:for-each>
3704     </xsl:param>
3705     <xsl:param name="followingSiblingDepthValue">
3706       <xsl:choose>
3707     <xsl:when test="$followingSiblingDepth != ''">
3708       <xsl:call-template name="sumOfList">
3709         <xsl:with-param name="list" select="$followingSiblingDepth"/>
3710       </xsl:call-template>
3711     </xsl:when>
3712     <xsl:otherwise>0</xsl:otherwise>
3713       </xsl:choose>
3714     </xsl:param>
3715     <xsl:choose>
3716       <xsl:when
3717     test="generate-id(ancestor::table:table-cell[1]/
3718     parent::table:table-row) != $rowID">
3719     <xsl:apply-templates
3720       select="ancestor::table:table-cell[1]/parent::table:table-row"
3721       mode="followingDepth">
3722       <xsl:with-param
3723         name="depthCumul"
3724         select="$depthCumul + $followingSiblingDepthValue"/>
3725       <xsl:with-param name="rowID" select="$rowID"/>
3726     </xsl:apply-templates>
3727       </xsl:when>
3728       <xsl:otherwise>
3729     <xsl:value-of select="$depthCumul"/>
3730       </xsl:otherwise>
3731     </xsl:choose>
3732 </xsl:template>
3733
3734
3735   <!--
3736   This template return the line depth of the current line if this line contains
3737   cells with a sub-table.
3738   It returns a value of type x (to make it a list if needed).
3739   It doesn't return anything if there isn't any sub-table.
3740   -->
3741 <xsl:template match="table:table-cell" mode="pas">
3742     <xsl:param name="depth" select="'table'"/>
3743     <xsl:param name="nucleon" select="'sub'"/>
3744     <xsl:param name="maxDepthRows" select="1"/>
3745     <xsl:param name="subtablesDepthRows">
3746       <xsl:choose>
3747     <xsl:when
3748       test="table:table[@table:is-sub-table = 'true']/table:table-row/
3749       table:table-cell/table:table[@table:is-sub-table = 'true']">
3750       <xsl:apply-templates
3751         select="table:table[@table:is-sub-table = 'true']/table:table-row/
3752         table:table-cell[table:table[@table:is-sub-table = 'true']][1]"
3753         mode="pas">
3754         <xsl:with-param name="depth" select="concat($nucleon, '-', $depth)"/>
3755       </xsl:apply-templates>
3756     </xsl:when>
3757     <xsl:otherwise>0</xsl:otherwise>
3758       </xsl:choose>
3759     </xsl:param>
3760     <xsl:param name="stDepthRowsSum">
3761       <xsl:call-template name="sumOfList">
3762     <xsl:with-param name="list" select="$subtablesDepthRows"/>
3763       </xsl:call-template>
3764     </xsl:param>
3765     <xsl:param  name="depthRows"
3766       select="count(table:table[@table:is-sub-table = 'true']/table:table-row
3767       [not(descendant::table:table[@table:is-sub-table = 'true'])])"/>
3768     <xsl:param name="totalDepthRows" select="$depthRows + $stDepthRowsSum"/>
3769     <xsl:choose>
3770       <xsl:when test="following-sibling::table:table-cell[table:table[@table:is-sub-table = 'true']]">
3771     <xsl:apply-templates
3772       select="following-sibling::table:table-cell[table:table[@table:is-sub-table = 'true']][1]"
3773       mode="pas">
3774       <xsl:with-param name="maxDepthRows">
3775         <xsl:choose>
3776           <xsl:when test="$totalDepthRows > $maxDepthRows">
3777         <xsl:value-of select="$totalDepthRows"/>
3778           </xsl:when>
3779           <xsl:otherwise>
3780         <xsl:value-of select="$maxDepthRows"/>
3781           </xsl:otherwise>
3782         </xsl:choose>
3783       </xsl:with-param>
3784       <xsl:with-param name="depth" select="$depth"/>
3785     </xsl:apply-templates>
3786       </xsl:when>
3787       <xsl:otherwise>
3788     <xsl:choose>
3789       <xsl:when test="$totalDepthRows > $maxDepthRows">
3790         <xsl:value-of select="concat($totalDepthRows,';')"/>
3791       </xsl:when>
3792       <xsl:otherwise>
3793         <xsl:value-of select="concat($maxDepthRows,';')"/>
3794       </xsl:otherwise>
3795     </xsl:choose>
3796       </xsl:otherwise>
3797     </xsl:choose>
3798 </xsl:template>
3799
3800   <!--
3801   ===========
3802   TABLE CELLS
3803   ===========
3804   -->
3805
3806   <!-- This template does the main processing for table cells -->
3807 <xsl:template match="table:table-cell" mode="rowProcess">
3808     <xsl:param name="colsList"/>
3809     <xsl:param name="cycle"/>
3810     <xsl:param name="maxRowsInSubtables"/>
3811     <xsl:param name="rowID"/>
3812     <xsl:param name="lastRow"/>
3813     <xsl:param name="namest">
3814       <xsl:call-template name="cellStart">
3815     <xsl:with-param name="colsList" select="$colsList"/>
3816       </xsl:call-template>
3817     </xsl:param>
3818     <xsl:param name="nameend">
3819       <xsl:call-template name="cellEnd">
3820     <xsl:with-param name="colsList" select="$colsList"/>
3821       </xsl:call-template>
3822     </xsl:param>
3823     <xsl:param name="precedingDepth">
3824       <xsl:choose>
3825     <xsl:when test="generate-id(parent::table:table-row) != $rowID">
3826       <xsl:apply-templates
3827         select="parent::table:table-row"
3828         mode="precedingDepth"/>
3829     </xsl:when>
3830     <xsl:otherwise>false</xsl:otherwise>
3831       </xsl:choose>
3832     </xsl:param>
3833     <xsl:param name="precedingDepthValue">
3834       <xsl:choose>
3835     <xsl:when test="$precedingDepth != 'false'">
3836       <xsl:value-of select="$precedingDepth"/>
3837     </xsl:when>
3838     <xsl:otherwise>0</xsl:otherwise>
3839       </xsl:choose>
3840     </xsl:param>
3841     <xsl:param name="followingDepth">
3842       <xsl:choose>
3843     <xsl:when test="generate-id(parent::table:table-row) != $rowID">
3844       <xsl:apply-templates
3845         select="parent::table:table-row"
3846         mode="followingDepth"/>
3847     </xsl:when>
3848     <xsl:otherwise>false</xsl:otherwise>
3849       </xsl:choose>
3850     </xsl:param>
3851     <xsl:param name="followingDepthValue">
3852       <xsl:choose>
3853     <xsl:when test="$followingDepth != 'false'">
3854       <xsl:value-of select="$followingDepth"/>
3855     </xsl:when>
3856     <xsl:otherwise>0</xsl:otherwise>
3857       </xsl:choose>
3858     </xsl:param>
3859     <xsl:param name="moreRowsBrut">
3860       <xsl:choose>
3861     <xsl:when test="parent::table:table-row/
3862       child::table:table-cell[table:table[@table:is-sub-table = 'true']]
3863       and not(table:table[@table:is-sub-table = 'true'])">
3864       <xsl:apply-templates
3865         select="parent::table:table-row/child::table:table-cell
3866         [table:table[@table:is-sub-table = 'true']][1]"
3867         mode="pas"/>
3868     </xsl:when>
3869     <xsl:otherwise>1</xsl:otherwise>
3870       </xsl:choose>
3871     </xsl:param>
3872     <xsl:param name="moreRowsValue">
3873       <xsl:choose>
3874     <xsl:when test="$moreRowsBrut != ''">
3875       <xsl:call-template name="sumOfList">
3876         <xsl:with-param name="list" select="$moreRowsBrut"/>
3877       </xsl:call-template>
3878     </xsl:when>
3879     <xsl:otherwise>1</xsl:otherwise>
3880       </xsl:choose>
3881     </xsl:param>
3882     <xsl:param name="moreRows">
3883       <xsl:choose>
3884     <xsl:when test="($followingDepthValue = 0) and
3885       $maxRowsInSubtables > ($precedingDepthValue + $moreRowsValue)">
3886       <xsl:value-of select="$maxRowsInSubtables - $precedingDepthValue "/>
3887     </xsl:when>
3888     <xsl:otherwise>
3889       <xsl:value-of select="$moreRowsValue"/>
3890     </xsl:otherwise>
3891       </xsl:choose>
3892     </xsl:param>
3893
3894     <xsl:param name="contenu" select="text:p/text()"/>
3895     <xsl:if test="$cycle = $precedingDepthValue">
3896       <xsl:call-template name="entryNormal">
3897     <xsl:with-param name="moreRowsValue" select="$moreRows - 1"/>
3898     <xsl:with-param name="namestValue" select="$namest"/>
3899     <xsl:with-param name="nameendValue" select="$nameend"/>
3900       </xsl:call-template>
3901     </xsl:if>
3902   </xsl:template>
3903
3904   <!-- Retourne le debut  de la cellule appelante au sens DocBook (namest)-->
3905 <xsl:template name="cellStart">
3906     <xsl:param name="colsList"/>
3907     <xsl:param name="extremite" select="'start'"/>
3908     <xsl:param name="cellPosition">
3909       <xsl:choose>
3910     <xsl:when test="preceding-sibling::table:table-cell">
3911       <xsl:apply-templates
3912         select="preceding-sibling::table:table-cell[1]"
3913         mode="cellPosition">
3914         <xsl:with-param name="extremite" select="$extremite"/>
3915       </xsl:apply-templates>
3916     </xsl:when>
3917     <xsl:otherwise>
3918       <xsl:choose>
3919         <xsl:when test="../parent::table:table[@table:is-sub-table = 'true']">
3920           <xsl:apply-templates
3921         select="../../table:table-column[1]"
3922         mode="subtablePosition"/>
3923         </xsl:when>
3924         <xsl:otherwise>0</xsl:otherwise>
3925       </xsl:choose>
3926     </xsl:otherwise>
3927       </xsl:choose>
3928     </xsl:param>
3929     <xsl:param name="order">
3930       <xsl:choose>
3931     <xsl:when test="$cellPosition != 0">
3932       <xsl:call-template name="position2order">
3933         <xsl:with-param name="colsList" select="$colsList"/>
3934         <xsl:with-param name="cellPosition" select="$cellPosition"/>
3935       </xsl:call-template>
3936     </xsl:when>
3937     <xsl:otherwise>0</xsl:otherwise>
3938       </xsl:choose>
3939     </xsl:param>
3940     <xsl:value-of select="$order"/>
3941   </xsl:template>
3942
3943   <!-- Retourne la fin de la cellule appelante au sens DocBook (nameend) -->
3944 <xsl:template name="cellEnd">
3945     <xsl:param name="colsList"/>
3946     <xsl:param name="extremite" select="'end'"/>
3947     <xsl:param name="cellPosition">
3948       <xsl:apply-templates select="current()"
3949     mode="cellPosition">
3950     <xsl:with-param name="extremite" select="$extremite"/>
3951     <xsl:with-param name="colsList" select="$colsList"/>
3952       </xsl:apply-templates>
3953     </xsl:param>
3954     <xsl:param name="order">
3955       <xsl:call-template name="position2order">
3956     <xsl:with-param name="colsList" select="$colsList"/>
3957     <xsl:with-param name="cellPosition" select="$cellPosition"/>
3958       </xsl:call-template>
3959     </xsl:param>
3960     <xsl:value-of select="$order"/>
3961   </xsl:template>
3962
3963   <!--
3964   Retourne le numero de colonne de la cellule en fonction de sa
3965   position absolue dans le tableau.
3966   Requiert :
3967   - "colsList" = liste des position absolues de colonnes
3968   - "cellPosition" = position absolue de la cellule
3969   -->
3970 <xsl:template name="position2order">
3971     <xsl:param name="colsList"/>
3972     <xsl:param name="cellPosition"/>
3973     <xsl:param name="cycle" select="1"/>
3974     <xsl:param name="colsListElt" select="substring-before($colsList,';')"/>
3975 <!--
3976 <xsl:message>
3977 template name="position2order"
3978 colsList : <xsl:value-of select="$colsList"/>
3979 cellPosition : <xsl:value-of select="$cellPosition"/>
3980 cycle : <xsl:value-of select="$cycle"/>
3981 colsListElt : <xsl:value-of select="$colsListElt"/>
3982 </xsl:message>
3983 -->
3984     <xsl:choose>
3985         <xsl:when test="$colsList != ''">
3986         <!-- nouveau test pour eviter une boucle infinie-->
3987             <xsl:choose>
3988                 <xsl:when test="$cellPosition != $colsListElt">
3989                     <xsl:call-template name="position2order">
3990                         <xsl:with-param name="cycle" select="$cycle + 1"/>
3991                         <xsl:with-param name="colsList" select="substring-after($colsList,';')"/>
3992                         <xsl:with-param name="cellPosition" select="$cellPosition"/>
3993                     </xsl:call-template>
3994                 </xsl:when>
3995                 <xsl:otherwise>
3996                     <xsl:value-of select="$cycle"/>
3997                 </xsl:otherwise>
3998             </xsl:choose>
3999         </xsl:when>
4000         <!-- nouveau test pour eviter une boucle infinie ; on renvoie 0 dans ce cas !-->
4001         <xsl:otherwise>0</xsl:otherwise>
4002     </xsl:choose>
4003 </xsl:template>
4004
4005   <!--
4006   Retourne la position de la cellule numero "placeOfCell" dont l'etendue OOo
4007   "repeatCol" est donnee
4008   -->
4009 <xsl:template match="table:table-cell" mode="cellPosition">
4010     <xsl:param name="extremite"/>
4011     <xsl:param name="currentCellSpan">
4012       <xsl:choose>
4013     <xsl:when test="@table:number-columns-spanned">
4014       <xsl:value-of select="@table:number-columns-spanned"/>
4015     </xsl:when>
4016     <xsl:otherwise>1</xsl:otherwise>
4017       </xsl:choose>
4018     </xsl:param>
4019     <xsl:param name="precedingCellsNbr"
4020       select="count(preceding-sibling::table:table-cell
4021       [not(@table:number-columns-spanned)]) +
4022       sum(preceding-sibling::table:table-cell/
4023       @table:number-columns-spanned)"/>
4024     <xsl:param name="placeOfCol">
4025       <xsl:choose>
4026     <xsl:when test="parent::table:table-row/parent::table:table">
4027       <xsl:apply-templates select="../../table:table-column[1]"
4028         mode="placeOfColl">
4029         <xsl:with-param name="placeOfCell" select="$precedingCellsNbr + $currentCellSpan"/>
4030       </xsl:apply-templates>
4031     </xsl:when>
4032     <xsl:otherwise><!-- table:table-header-rows -->
4033       <xsl:apply-templates select="../../../table:table-column[1]"
4034         mode="placeOfColl">
4035         <xsl:with-param name="placeOfCell" select="$precedingCellsNbr + $currentCellSpan"/>
4036       </xsl:apply-templates>
4037     </xsl:otherwise>
4038       </xsl:choose>
4039     </xsl:param>
4040     <xsl:param name="content"  select="text:p/text()"/>
4041     <xsl:param name="numCol" select="substring-before($placeOfCol,';')"/>
4042     <xsl:param name="repeatCol" select="substring-after($placeOfCol,';')"/>
4043
4044     <xsl:param name="colposition">
4045       <xsl:choose>
4046     <xsl:when test="parent::table:table-row/parent::table:table">
4047       <xsl:apply-templates select="../../table:table-column[position()=$numCol]" mode="colposition">
4048         <xsl:with-param name="repeatCol" select="$repeatCol"/>
4049       </xsl:apply-templates>
4050     </xsl:when>
4051     <xsl:otherwise>
4052       <xsl:apply-templates
4053         select="../../../table:table-column[position()=$numCol]"
4054         mode="colposition">
4055         <xsl:with-param name="repeatCol" select="$repeatCol"/>
4056       </xsl:apply-templates>
4057     </xsl:otherwise>
4058       </xsl:choose>
4059     </xsl:param>
4060     <xsl:value-of select="$colposition"/>
4061 </xsl:template>
4062
4063   <!--
4064   Retourne le numero de la colonne
4065   correspondant a une position de cellule donnee (placeofCell)
4066   pour le conteneur table ou sub-table courant
4067   -->
4068 <xsl:template match="table:table-column" mode="placeOfColl">
4069     <xsl:param name="placeOfCell"/>
4070     <xsl:param name="placeOfColl" select="1"/>
4071     <xsl:param name="repeatOfCol">
4072       <xsl:choose>
4073     <xsl:when test="@table:number-columns-repeated">
4074       <xsl:value-of select="@table:number-columns-repeated"/>
4075     </xsl:when>
4076     <xsl:otherwise>1</xsl:otherwise>
4077       </xsl:choose>
4078     </xsl:param>
4079     <xsl:choose>
4080       <xsl:when test="$placeOfCell > 0">
4081     <xsl:choose>
4082       <xsl:when test="$placeOfCell > $repeatOfCol">
4083         <xsl:apply-templates
4084           select="following-sibling::table:table-column[1]"
4085           mode="placeOfColl">
4086           <xsl:with-param name="placeOfCell" select="$placeOfCell - $repeatOfCol"/>
4087           <xsl:with-param name="placeOfColl" select="$placeOfColl + 1"/>
4088         </xsl:apply-templates>
4089       </xsl:when>
4090       <xsl:otherwise>
4091         <xsl:value-of select="concat($placeOfColl,';',$placeOfCell)"/>
4092       </xsl:otherwise>
4093     </xsl:choose>
4094       </xsl:when>
4095       <xsl:otherwise>
4096     <xsl:value-of select="concat($placeOfColl,';',1)"/>
4097       </xsl:otherwise>
4098     </xsl:choose>
4099 </xsl:template>
4100
4101   <!--
4102   Retourne la position absolue de la colonne (distance entre la fin
4103   de la colonne et le bord gauche du tableau)dans l'unite de mesure courante du document
4104   -->
4105 <xsl:template match="table:table-column" mode="colposition">
4106     <xsl:param name="stylesURI" select="/office:document/office:automatic-styles/style:style"/>
4107     <xsl:param name="repeatCol"/>
4108     <xsl:param name="cellAncestorNbr"/>
4109     <xsl:param name="precedingCellsNbr" select="count(preceding-sibling::table:table-cell)"/>
4110     <xsl:param name="colPosition">
4111       <xsl:call-template name="colPosition">
4112     <xsl:with-param name="origineValue">
4113       <xsl:choose>
4114         <xsl:when test="parent::table:table[@table:is-sub-table = 'true']">
4115           <xsl:call-template name="subtableOrigine">
4116         <xsl:with-param name="cellAncestorNbr"
4117           select="count(ancestor::table:table-cell)"/>
4118         <xsl:with-param name="stylesURI" select="$stylesURI"/>
4119           </xsl:call-template>
4120         </xsl:when>
4121         <xsl:otherwise>0</xsl:otherwise>
4122       </xsl:choose>
4123     </xsl:with-param>
4124     <xsl:with-param name="stylesURI" select="$stylesURI"/>
4125     <xsl:with-param name="repeatCol" select="$repeatCol"/>
4126       </xsl:call-template>
4127     </xsl:param>
4128     <xsl:param name="colposfine" select="substring-before($colPosition,';')"/>
4129     <xsl:value-of select="$colposfine"/>
4130 </xsl:template>
4131
4132   <!-- Retourne la position absolue de la sous-table qui incorpore la colonne courante
4133   (postion absolue = distance entre bord gauche de la sous-table
4134   et bord gauche du tableau) -->
4135 <xsl:template match="table:table-column" mode="subtablePosition">
4136     <xsl:param name="stylesURI" select="/office:document/office:automatic-styles/style:style"/>
4137     <xsl:param name="repeatCol"/>
4138     <xsl:param name="cellAncestorNbr"/>
4139     <xsl:param name="precedingCellsNbr" select="count(preceding-sibling::table:table-cell)"/>
4140     <xsl:param name="subtablePosition">
4141       <xsl:call-template name="subtableOrigine">
4142     <xsl:with-param name="cellAncestorNbr"
4143       select="count(ancestor::table:table-cell)"/>
4144     <xsl:with-param name="stylesURI" select="$stylesURI"/>
4145       </xsl:call-template>
4146     </xsl:param>
4147     <xsl:param name="colposfine">
4148       <xsl:call-template name="roundValue">
4149     <xsl:with-param name="inputValue" select="$subtablePosition"/>
4150       </xsl:call-template>
4151     </xsl:param>
4152     <xsl:value-of select="$colposfine"/>
4153   </xsl:template>
4154
4155   <!--
4156   Retourne la somme des elements de la liste passee en parametre
4157   La liste doit etre du type a;b;c; (le ';' final est requit)
4158   -->
4159 <xsl:template name="sumOfList">
4160     <xsl:param name="list"/>
4161     <xsl:param name="sum" select="0"/>
4162     <xsl:choose>
4163       <xsl:when test="substring-before($list,';') != ''">
4164     <xsl:call-template name="sumOfList">
4165       <xsl:with-param name="sum" select="$sum + substring-before($list,';')"/>
4166       <xsl:with-param name="list" select="substring-after($list,';')"/>
4167     </xsl:call-template>
4168       </xsl:when>
4169       <xsl:otherwise>
4170     <xsl:value-of select="$sum"/>
4171       </xsl:otherwise>
4172     </xsl:choose>
4173   </xsl:template>
4174
4175   <!-- Retourne la valeur arrondie adaptee a l'unite de messure en cour du document-->
4176 <xsl:template name="roundValue">
4177     <xsl:param name="inputValue"/>
4178     <xsl:choose>
4179       <xsl:when test="$measureUnit = 'pt' or $measureUnit = 'pi' or $measureUnit = '%'">
4180     <xsl:value-of select="round($inputValue)"/>
4181       </xsl:when>
4182       <xsl:when test="$measureUnit = 'cm' or $measureUnit = 'inch'">
4183     <xsl:value-of select="round($inputValue * 10) div 10"/>
4184       </xsl:when>
4185       <xsl:otherwise><!-- mm -->
4186     <xsl:value-of select="round($inputValue)"/>
4187       </xsl:otherwise>
4188     </xsl:choose>
4189 </xsl:template>
4190
4191   <!-- Table - Table-cell -->
4192   <!-- Final treatment of table cells -->
4193 <xsl:template name="entryNormal">
4194     <xsl:param name="namestValue"/>
4195     <xsl:param name="nameendValue"/>
4196     <xsl:param name="moreRowsValue" select="'0'"/>
4197
4198     <xsl:variable name="stylecellule" select="/office:document/office:automatic-styles/
4199       style:style[@style:name=current()/@table:style-name]"/>
4200     <xsl:variable name="valign"
4201       select="$stylecellule/style:table-cell-properties/@style:vertical-align"/>
4202
4203     <!--
4204     The align attribute handling here is a bit tricky because the
4205     information we rely on is the align attribute located in the
4206     first element contained in the table cell (current()/child::*[1]).
4207     So this treatment assumes that all the elements contains in this
4208     table cell will have the same alignment. This is not a very bad
4209     assumption because doing complicated layout settings in table is
4210     bad.
4211     -->
4212     <xsl:variable name="align"
4213       select="/office:document/office:automatic-styles/
4214       style:style[@style:name=(current()/child::*[1]/@text:style-name)]/
4215       */@fo:text-align"/>
4216
4217     <xsl:variable name="border"
4218       select="$stylecellule/style:table-cell-properties/@fo:border"/>
4219     <xsl:variable name="border-top"
4220       select="$stylecellule/style:table-cell-properties/@fo:border-top"/>
4221     <xsl:variable name="border-right"
4222       select="$stylecellule/style:table-cell-properties/@fo:border-right"/>
4223     <xsl:variable name="border-bottom"
4224       select="$stylecellule/style:table-cell-properties/@fo:border-bottom"/>
4225     <xsl:variable name="border-left"
4226       select="$stylecellule/style:table-cell-properties/@fo:border-left"/>
4227
4228 <!--
4229 <xsl:message>
4230 stylecellule <xsl:value-of select="$stylecellule/@style:family"/>
4231 valign <xsl:value-of select="$valign"/>
4232 border <xsl:value-of select="$border"/>
4233 border-top <xsl:value-of select="$border-top"/>
4234 border-right <xsl:value-of select="$border-right"/>
4235 border-left <xsl:value-of select="$border-left"/>
4236 border-bottom <xsl:value-of select="$border-bottom"/>
4237 </xsl:message>
4238 -->
4239
4240
4241
4242
4243     <entry>
4244       <xsl:if test="($nameendValue - $namestValue) > 1">
4245     <xsl:attribute name="namest">
4246       <xsl:value-of select="concat('c', ($namestValue + 1))"/>
4247     </xsl:attribute>
4248     <xsl:attribute name="nameend">
4249       <xsl:value-of select="concat('c', $nameendValue)"/>
4250     </xsl:attribute>
4251       </xsl:if>
4252       <xsl:if test="$moreRowsValue >= 1">
4253     <xsl:attribute name="morerows">
4254       <xsl:value-of select="$moreRowsValue"/>
4255     </xsl:attribute>
4256       </xsl:if>
4257       <xsl:if test="$valign">
4258     <xsl:attribute name="valign">
4259       <xsl:value-of select="$valign"/>
4260     </xsl:attribute>
4261       </xsl:if>
4262       <xsl:if test="$align">
4263     <xsl:attribute name="align">
4264       <xsl:choose>
4265         <xsl:when test="$align='start'">
4266           <xsl:value-of select="'left'"/>
4267         </xsl:when>
4268         <xsl:when test="$align='end'">
4269           <xsl:value-of select="'right'"/>
4270         </xsl:when>
4271         <xsl:when test="$align='center'">
4272           <xsl:value-of select="'center'"/>
4273         </xsl:when>
4274         <xsl:when test="$align='justify'">
4275           <xsl:value-of select="'justify'"/>
4276         </xsl:when>
4277       </xsl:choose>
4278     </xsl:attribute>
4279       </xsl:if>
4280
4281       <!-- Border specification as processing instructions -->
4282       <xsl:if test="$border and $border != 'none'">
4283     <xsl:processing-instruction name="border">
4284       <xsl:value-of select="$border"/>
4285     </xsl:processing-instruction>
4286       </xsl:if>
4287       <xsl:if test="$border-top and $border-top != 'none'">
4288     <xsl:processing-instruction name="border-top">
4289       <xsl:value-of select="$border-top"/>
4290     </xsl:processing-instruction>
4291       </xsl:if>
4292       <xsl:if test="$border-right and $border-right != 'none'">
4293     <xsl:processing-instruction name="border-right">
4294       <xsl:value-of select="$border-right"/>
4295     </xsl:processing-instruction>
4296       </xsl:if>
4297       <xsl:if test="$border-bottom and $border-bottom != 'none'">
4298     <xsl:processing-instruction name="border-bottom">
4299       <xsl:value-of select="$border-bottom"/>
4300     </xsl:processing-instruction>
4301       </xsl:if>
4302       <xsl:if test="$border-left and $border-left != 'none'">
4303     <xsl:processing-instruction name="border-left">
4304       <xsl:value-of select="$border-left"/>
4305     </xsl:processing-instruction>
4306       </xsl:if>
4307
4308       <xsl:apply-templates mode="inCellTable"/>
4309     </entry>
4310   </xsl:template>
4311
4312   <!-- Tables - Cell content -->
4313 <xsl:template match="*" mode="inCellTable">
4314     <xsl:call-template name="allTags">
4315         <xsl:with-param name="source" select="'cellTable'"/>
4316     </xsl:call-template>
4317 </xsl:template>
4318
4319
4320   <!-- Deleted styles -->
4321 <xsl:template match="text:sequence-decls"/>
4322 <xsl:template match="text:table-of-content"/>
4323  
4324 <!--Modif MT generation fils Id -->
4325 <xsl:template name="GenereIdSection">
4326     <xsl:if test="text:bookmark-start">
4327         <xsl:attribute name="id">
4328             <xsl:value-of select="text:bookmark-start/@text:name"/>
4329         </xsl:attribute>
4330     </xsl:if>
4331 </xsl:template>
4332 <!-- Fin modif MT    -->
4333
4334 <!--Rajoute par MT pour gerer la correspondance des styles Notes - important|warning|caution|tip-->
4335   <xsl:template name="NoteImportant">
4336     <important>
4337         <xsl:value-of select="@text:name"/>
4338     </important>
4339   </xsl:template>
4340   <xsl:template name="NoteWarning">
4341     <warning>
4342         <xsl:value-of select="@text:name"/>
4343     </warning>
4344   </xsl:template>
4345   <xsl:template name="NoteCaution">
4346     <caution>
4347         <xsl:value-of select="@text:name"/>
4348     </caution>
4349   </xsl:template>
4350   <xsl:template name="NoteTip">
4351     <tip>
4352         <xsl:value-of select="@text:name"/>
4353     </tip>
4354   </xsl:template>
4355
4356 </xsl:stylesheet>
Note: See TracBrowser for help on using the browser.