1 <?xml version=
"1.0" encoding=
"UTF-8"?>
3 odt2mediawiki: OpenDocument to WikiMedia transformation
4 Copyright (C) 2007-2013 Bernhard Haumacher (haui at haumacher dot de)
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
18 $Id: odt2mediawiki.xsl 3180 2013-03-17 16:00:43Z hauma $
20 <stylesheet version=
"1.0"
21 xmlns=
"http://www.w3.org/1999/XSL/Transform"
23 xmlns:
office=
"urn:oasis:names:tc:opendocument:xmlns:office:1.0"
24 xmlns:
style=
"urn:oasis:names:tc:opendocument:xmlns:style:1.0"
25 xmlns:
text=
"urn:oasis:names:tc:opendocument:xmlns:text:1.0"
26 xmlns:
table=
"urn:oasis:names:tc:opendocument:xmlns:table:1.0"
27 xmlns:
draw=
"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
28 xmlns:
fo=
"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
29 xmlns:
meta=
"urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
30 xmlns:
number=
"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
31 xmlns:
svg=
"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
32 xmlns:
chart=
"urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
33 xmlns:
dr3d=
"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
34 xmlns:
form=
"urn:oasis:names:tc:opendocument:xmlns:form:1.0"
35 xmlns:
script=
"urn:oasis:names:tc:opendocument:xmlns:script:1.0"
36 xmlns:
xlink=
"http://www.w3.org/1999/xlink"
37 xmlns:
dc=
"http://purl.org/dc/elements/1.1/"
38 xmlns:
math=
"http://www.w3.org/1998/Math/MathML"
39 xmlns:
dom=
"http://www.w3.org/2001/xml-events"
40 xmlns:
xforms=
"http://www.w3.org/2002/xforms"
41 xmlns:
xsd=
"http://www.w3.org/2001/XMLSchema"
42 xmlns:
xsi=
"http://www.w3.org/2001/XMLSchema-instance"
46 == Customization options ==
49 <!-- Constant defining the newline token. -->
50 <param name=
"NL" select=
"' '"/>
52 <!-- String that a tabulator is expanded with in preformatted paragraphs. -->
54 <variable name=
"codetabdocument-value"
55 select=
"/office:document/office:meta/meta:user-defined[@meta:name='CODE_TAB_REPLACEMENT']"/>
57 <param name=
"CODE_TAB_REPLACEMENT">
61 <when test=
"boolean($codetabdocument-value)">
62 <value-of select=
"$codetabdocument-value"/>
66 <value-of select=
"' '"/>
72 Switch that suppresses separation of paragraphs with empty lines.
73 (Set to 1 to activate) -->
74 <param name=
"CODE_JOIN_PARAGRAPHS"
75 select=
"boolean(string(/office:document/office:meta/meta:user-defined[@meta:name='CODE_JOIN_PARAGRAPHS']) != 'false')"/>
77 <variable name=
"document-value"
78 select=
"/office:document/office:meta/meta:user-defined[@meta:name='CODE_STYLES']"/>
80 <param name=
"CODE_STYLES">
83 <when test=
"boolean($document-value)">
84 <value-of select=
"$document-value"/>
88 <value-of select=
"''"/>
93 <variable name=
"table-class"
94 select=
"/office:document/office:meta/meta:user-defined[@meta:name='TABLE_CLASS']"/>
96 <param name=
"TABLE_CLASS">
98 <when test=
"boolean($table-class)">
99 <value-of select=
"$table-class"/>
103 <value-of select=
"''"/>
108 <variable name=
"USE_DEFAULT_TABLE_CLASS" select=
"string-length($TABLE_CLASS) > 0"/>
112 == Wiki style constants ==
115 <!-- Bold character style. -->
116 <variable name=
"BOLD_BIT" select=
"1"/>
118 <!-- Italic character style. -->
119 <variable name=
"ITALIC_BIT" select=
"2"/>
121 <!-- Underline character style. -->
122 <variable name=
"UNDERLINE_BIT" select=
"4"/>
124 <!-- Subscript character style. -->
125 <variable name=
"SUBSCRIPT_BIT" select=
"8"/>
127 <!-- Superscript character style. -->
128 <variable name=
"SUPERSCRIPT_BIT" select=
"16"/>
130 <!-- Typewriter character style. -->
131 <variable name=
"TYPEWRITER_BIT" select=
"32"/>
133 <!-- Preformatted text paragraph style. -->
134 <variable name=
"CODE_BIT" select=
"64"/>
136 <!-- Centered paragraph style. -->
137 <variable name=
"CENTER_BIT" select=
"128"/>
139 <!-- Right aligned paragraph style. -->
140 <variable name=
"RIGHT_BIT" select=
"256"/>
142 <!-- Constant defining the empty style. -->
143 <variable name=
"NO_STYLE" select=
"0"/>
149 media-type=
"text/plain"
155 == Reference resolution ==
160 match=
"//style:style"
165 name=
"list-style-ref"
166 match=
"//text:list-style"
172 match=
"//style:font-face"
177 name=
"text:table-of-content-entry-ref"
178 match=
"//text:table-of-content-entry-template"
179 use=
"@text:style-name"
183 name=
"reference-resolution"
184 match=
"//text:reference-mark | //text:reference-mark-start"
190 Multiple pages (draw only)
193 <template match=
"draw:page">
194 <value-of select=
"concat(' <!-- Page ', @draw:name, '--> ')"/>
196 <value-of select=
"' ---- '"/>
204 <template match=
"text:list">
206 Check, whether this list is used to implement the outline numbering
207 for headings. Such list must not be exported, because within the wiki,
208 automatic outline numbering is performed. An outline list has a single
209 text:h element as its single leaf grandchild.
211 This method of section numbering seems not to be used when creating new
212 documents with OpenOffice.org 2.2, but the document containing the
213 OpenDocument specification version 1.1 uses such numbering through nested
217 <when test=
"boolean(./descendant::node()[not(./self::text:list) and not(./self::text:list-item) and not(./ancestor-or-self::text:h)])">
222 <apply-templates select=
".//text:h"/>
227 <template match=
"text:list-item">
228 <if test=
"position() > 1 or boolean(ancestor::text:list-item)">
229 <value-of select=
"$NL"/>
231 <variable name=
"list-style"
232 select=
"key('list-style-ref',ancestor::text:list[boolean(@text:style-name)][1]/@text:style-name)"/>
233 <call-template name=
"mk-list-token">
234 <with-param name=
"list-style" select=
"$list-style"/>
235 <with-param name=
"level" select=
"count(ancestor::text:list)"/>
239 <if test=
"position() = last() and not(boolean(ancestor::text:list-item))">
240 <!-- End of (potentially nested) list is marked with a double newline. -->
241 <value-of select=
"$NL"/>
242 <value-of select=
"$NL"/>
246 <template name=
"mk-list-token">
247 <param name=
"list-style"/>
248 <param name=
"level"/>
250 <if test=
"$level > 1">
251 <call-template name=
"mk-list-token">
252 <with-param name=
"list-style" select=
"$list-style"/>
253 <with-param name=
"level" select=
"$level - 1"/>
257 <variable name=
"number-style" select=
"$list-style/text:list-level-style-number[@text:level=$level]"/>
258 <variable name=
"bullet-style" select=
"$list-style/text:list-level-style-bullet[@text:level=$level]"/>
260 <when test=
"boolean($number-style)">
262 <when test=
"string-length($number-style/@style:num-format) > 0">
270 <when test=
"boolean($bullet-style)">
281 <template match=
"text:h">
282 <if test=
"string-length(.) > 0">
283 <variable name=
"token">
284 <call-template name=
"mk-heading-prefix">
285 <with-param name=
"level" select=
"@text:outline-level"/>
288 <value-of select=
"$token"/>
292 <value-of select=
"$token"/>
293 <value-of select=
"$NL"/>
294 <value-of select=
"$NL"/>
298 <template match=
"text:index-title">
299 <text>__NOTOC__
</text>
300 <value-of select=
"$NL"/>
304 <value-of select=
"$NL"/>
305 <value-of select=
"$NL"/>
309 Function generating a wiki heading prefix.
312 The heading level. The value must be between 1 and 6.
314 <template name=
"mk-heading-prefix">
315 <param name=
"level"/>
317 <when test=
"$level > 6">
318 <call-template name=
"mk-heading-prefix">
319 <with-param name=
"level" select=
"6"/>
322 <when test=
"$level > 0">
324 <call-template name=
"mk-heading-prefix">
325 <with-param name=
"level" select=
"$level - 1"/>
332 Function generating a token consisting of the given character
333 repeated 'level' times.
336 The length of the result.
338 The character that should be repeated 'level' times.
340 <template name=
"mk-token">
341 <param name=
"level"/>
343 <if test=
"$level > 0">
344 <value-of select=
"$char"/>
345 <call-template name=
"mk-token">
346 <with-param name=
"level" select=
"$level - 1"/>
347 <with-param name=
"char" select=
"$char"/>
357 <template match=
"table:table">
358 <value-of select=
"$NL"/>
362 <when test=
"$USE_DEFAULT_TABLE_CLASS">
363 <text> class=
"</text>
364 <value-of select="$TABLE_CLASS
"/>
369 <variable name=
"style-element" select=
"key('style-ref', @table:style-name)"/>
370 <variable name=
"table-align" select=
"$style-element/style:table-properties/@table:align"/>
371 <!-- Table alignment using align -->
372 <if test=
"boolean($table-align)">
373 <variable name=
"align">
375 <when test=
"$table-align='center'">
380 <if test=
"string-length($align) > 0">
381 <text> align=
"</text>
382 <value-of select="$align
"/>
386 <variable name=
"style">
387 <!-- Default setting to translate detailed office table cell styles correctly. -->
388 <text>border-spacing:
0;
</text>
389 <!-- Table alignment using css -->
390 <if test=
"boolean($table-align)">
392 <when test=
"$table-align='margins'">
393 <text>margin:auto;
</text>
397 <if test=
"boolean($style-element/style:table-properties/@style:width)">
399 <value-of select=
"$style-element/style:table-properties/@style:width"/>
403 <text> style=
"</text>
404 <value-of select="$style
"/>
409 <value-of select=
"$NL"/>
412 <value-of select=
"$NL"/>
414 <value-of select=
"$NL"/>
417 <template match=
"table:table-header-rows">
421 <template match=
"table:table-row">
424 <if test=
"not($USE_DEFAULT_TABLE_CLASS) and boolean(table:table-cell[1]/@table:style-name)">
425 <variable name=
"style-name" select=
"table:table-cell[1]/@table:style-name"/>
426 <variable name=
"total-style-name" select=
"count(table:table-cell/@table:style-name)"/>
427 <variable name=
"total-equal-style-name" select=
"count(table:table-cell[@table:style-name=$style-name])"/>
429 <variable name=
"style">
430 <if test=
"$total-equal-style-name=$total-style-name">
431 <call-template name=
"translate-table-cell-properties">
432 <with-param name=
"style-element" select=
"key('style-ref', $style-name)"/>
437 <if test=
"string-length($style) > 0">
438 <text> style=
"</text>
439 <value-of select="$style
"/>
444 <value-of select=
"$NL"/>
448 <template match=
"table:table-header-rows//table:table-cell">
450 <if test=
"@table:number-columns-spanned">
451 <text>colspan=
"</text>
452 <value-of select="@table:number-columns-spanned
"/>
456 <!-- Cell alignment -->
457 <if test=
"text:p and count(*) = 1">
458 <variable name=
"style-number">
459 <call-template name=
"mk-style-set">
460 <with-param name=
"node" select=
"text:p"/>
464 <variable name=
"code"
465 select=
"($style-number mod (2 * $CODE_BIT)) - ($style-number mod ($CODE_BIT)) != 0"/>
466 <variable name=
"center"
467 select=
"($style-number mod (2 * $CENTER_BIT)) - ($style-number mod ($CENTER_BIT)) != 0"/>
468 <variable name=
"right"
469 select=
"($style-number mod (2 * $RIGHT_BIT)) - ($style-number mod ($RIGHT_BIT)) != 0"/>
472 <when test=
"$center">
473 <text> align=center
</text>
476 <text> align=right
</text>
481 <if test=
"not($USE_DEFAULT_TABLE_CLASS) and boolean(@table:style-name)">
482 <variable name=
"style-name" select=
"@table:style-name"/>
484 <variable name=
"style">
485 <!-- Only if cells have a different style-name -->
486 <if test=
"count(../table:table-cell/@table:style-name) != count(../table:table-cell[@table:style-name=$style-name]) and count(../table:table-cell/@table:style-name) > 0">
487 <call-template name=
"translate-table-cell-properties">
488 <with-param name=
"style-element" select=
"key('style-ref', $style-name)"/>
493 <if test=
"string-length($style) > 0">
494 <text> style=
"</text>
495 <value-of select="$style
"/>
501 <value-of select=
"$NL"/>
504 <template match=
"table:table-cell">
506 <if test=
"@table:number-columns-spanned">
507 <text> colspan=
"</text>
508 <value-of select="@table:number-columns-spanned
"/>
512 <!-- Cell alignment -->
513 <if test=
"text:p and count(*) = 1">
514 <variable name=
"style-number">
515 <call-template name=
"mk-style-set">
516 <with-param name=
"node" select=
"text:p"/>
520 <variable name=
"code"
521 select=
"($style-number mod (2 * $CODE_BIT)) - ($style-number mod ($CODE_BIT)) != 0"/>
522 <variable name=
"center"
523 select=
"($style-number mod (2 * $CENTER_BIT)) - ($style-number mod ($CENTER_BIT)) != 0"/>
524 <variable name=
"right"
525 select=
"($style-number mod (2 * $RIGHT_BIT)) - ($style-number mod ($RIGHT_BIT)) != 0"/>
528 <when test=
"$center">
529 <text> align=center
</text>
532 <text> align=right
</text>
537 <if test=
"not($USE_DEFAULT_TABLE_CLASS) and boolean(@table:style-name)">
538 <variable name=
"style-name" select=
"@table:style-name"/>
540 <variable name=
"style">
541 <!-- Only if cells have a different style-name -->
542 <if test=
"count(../table:table-cell/@table:style-name) != count(../table:table-cell[@table:style-name=$style-name]) and count(../table:table-cell/@table:style-name) > 0">
543 <call-template name=
"translate-table-cell-properties">
544 <with-param name=
"style-element" select=
"key('style-ref', $style-name)"/>
548 <if test=
"text:p and count(*) = 1">
549 <if test=
"boolean(text:p/@text:style-name)">
550 <variable name=
"style-element" select=
"key('style-ref', text:p/@text:style-name)"/>
552 <call-template name=
"translate-style-property">
553 <with-param name=
"style-name" select=
"'color'"/>
554 <with-param name=
"style-property" select=
"$style-element/style:text-properties/@fo:color"/>
560 <if test=
"string-length($style) > 0">
561 <text> style=
"</text>
562 <value-of select="$style
"/>
568 <value-of select=
"$NL"/>
571 <template name=
"translate-table-cell-properties">
572 <param name=
"style-element"/>
573 <call-template name=
"translate-style-property">
574 <with-param name=
"style-name" select=
"'background-color'"/>
575 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:background-color"/>
578 <call-template name=
"translate-style-property">
579 <with-param name=
"style-name" select=
"'border'"/>
580 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:border"/>
582 <call-template name=
"translate-style-property">
583 <with-param name=
"style-name" select=
"'border-top'"/>
584 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:border-top"/>
586 <call-template name=
"translate-style-property">
587 <with-param name=
"style-name" select=
"'border-bottom'"/>
588 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:border-bottom"/>
590 <call-template name=
"translate-style-property">
591 <with-param name=
"style-name" select=
"'border-left'"/>
592 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:border-left"/>
594 <call-template name=
"translate-style-property">
595 <with-param name=
"style-name" select=
"'border-right'"/>
596 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:border-right"/>
599 <call-template name=
"translate-style-property">
600 <with-param name=
"style-name" select=
"'padding'"/>
601 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:padding"/>
603 <call-template name=
"translate-style-property">
604 <with-param name=
"style-name" select=
"'padding-top'"/>
605 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:padding-top"/>
607 <call-template name=
"translate-style-property">
608 <with-param name=
"style-name" select=
"'padding-bottom'"/>
609 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:padding-bottom"/>
611 <call-template name=
"translate-style-property">
612 <with-param name=
"style-name" select=
"'padding-left'"/>
613 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:padding-left"/>
615 <call-template name=
"translate-style-property">
616 <with-param name=
"style-name" select=
"'padding-right'"/>
617 <with-param name=
"style-property" select=
"$style-element/style:table-cell-properties/@fo:padding-right"/>
621 <template name=
"translate-style-property">
622 <param name=
"style-name"/>
623 <param name=
"style-property"/>
625 <if test=
"boolean($style-property)">
626 <value-of select=
"$style-name"/>
628 <value-of select=
"string($style-property)"/>
638 Make sure to join sibling node that are all formatted with WikiMath style without repeating
639 the <math>..</math> markup.
641 Do not apply any transformation to the contents marked as WikiMath.
643 <template match=
"text:span[@text:style-name='WikiMath']">
644 <value-of select=
"'<math>'"/>
645 <value-of select=
"string(.)"/>
646 <value-of select=
"'</math>'"/>
649 <template match=
"text:span[@text:style-name='WikiMath' and boolean(preceding-sibling::node()[position()=1 and local-name(.)='span' and @text:style-name='WikiMath'])]">
650 <value-of select=
"string(.)"/>
651 <value-of select=
"'</math>'"/>
654 <template match=
"text:span[@text:style-name='WikiMath' and boolean(following-sibling::node()[position()=1 and local-name(.)='span' and @text:style-name='WikiMath'])]">
655 <value-of select=
"'<math>'"/>
656 <value-of select=
"string(.)"/>
659 <template match=
"text:span[@text:style-name='WikiMath' and boolean(following-sibling::node()[position()=1 and local-name(.)='span' and @text:style-name='WikiMath']) and boolean(preceding-sibling::node()[position()=1 and local-name(.)='span' and @text:style-name='WikiMath'])]">
660 <value-of select=
"string(.)"/>
667 <template match=
"text:a">
668 <variable name=
"link-ref" select=
"@xlink:href"/>
670 <when test=
"string-length($link-ref) > 0">
672 <when test=
"starts-with($link-ref, '#')">
675 <when test=
"contains($link-ref, '_')">
676 <value-of select=
"translate($link-ref,'_','')"/>
679 <value-of select=
"$link-ref"/>
684 <when test=
"text:tab and ancestor::text:index-body">
685 <value-of select=
"node()[1]"/>
688 <value-of select=
"string(.)"/>
696 <value-of select=
"$link-ref"/>
698 <value-of select=
"string(.)"/>
711 Function for generating tabulations in TOC entries.
714 The style of the TOC entry
716 <template name=
"mk-tab-toc">
717 <param name=
"style"/>
718 <if test=
"number($style/@text:outline-level) > 0">
719 <call-template name=
"mk-token">
720 <with-param name=
"level" select=
"number($style/@text:outline-level) - 1"/>
721 <with-param name=
"char" select=
"':'"/>
730 <template match=
"text:span[@text:style-name='WikiLink']">
731 <value-of select=
"'[['"/>
732 <variable name=
"link-def" select=
"string(.)"/>
733 <variable name=
"link-label" select=
"normalize-space(substring-before($link-def, '['))"/>
734 <variable name=
"link-ref" select=
"normalize-space(substring-before(substring-after($link-def, '['), ']'))"/>
736 <when test=
"boolean($link-ref)">
737 <value-of select=
"concat($link-ref, '|', $link-label)"/>
740 <value-of select=
"$link-def"/>
743 <value-of select=
"']]'"/>
751 <template match=
"text:p">
753 <if test=
"ancestor::text:index-body and boolean(@text:style-name)">
754 <variable name=
"style" select=
"key('style-ref', @text:style-name)"/>
755 <if test=
"boolean($style/@style:parent-style-name)">
756 <call-template name=
"mk-tab-toc">
757 <with-param name=
"style" select=
"key('text:table-of-content-entry-ref', $style/@style:parent-style-name)"/>
762 <variable name=
"alignment">
763 <call-template name=
"mk-style-set">
764 <with-param name=
"node" select=
"."/>
768 <variable name=
"code"
769 select=
"($alignment mod (2 * $CODE_BIT)) - ($alignment mod ($CODE_BIT)) != 0"/>
770 <variable name=
"center"
771 select=
"($alignment mod (2 * $CENTER_BIT)) - ($alignment mod ($CENTER_BIT)) != 0"/>
772 <variable name=
"right"
773 select=
"($alignment mod (2 * $RIGHT_BIT)) - ($alignment mod ($RIGHT_BIT)) != 0"/>
775 <variable name=
"style">
777 <when test=
"name(parent::*) != 'table:table-cell'">
779 <when test=
"$center">
780 <text>text-align:center;
</text>
783 <text>text-align:right;
</text>
786 <if test=
"boolean(@text:style-name)">
787 <variable name=
"style-element" select=
"key('style-ref', @text:style-name)"/>
789 <call-template name=
"translate-style-property">
790 <with-param name=
"style-name" select=
"'color'"/>
791 <with-param name=
"style-property" select=
"$style-element/style:text-properties/@fo:color"/>
793 <call-template name=
"translate-style-property">
794 <with-param name=
"style-name" select=
"'margin-left'"/>
795 <with-param name=
"style-property" select=
"$style-element/style:paragraph-properties/@fo:margin-left"/>
797 <call-template name=
"translate-style-property">
798 <with-param name=
"style-name" select=
"'margin-right'"/>
799 <with-param name=
"style-property" select=
"$style-element/style:paragraph-properties/@fo:margin-right"/>
804 <if test=
"count(../text:p) > 1 and boolean(@text:style-name)">
805 <variable name=
"style-element" select=
"key('style-ref', @text:style-name)"/>
807 <call-template name=
"translate-style-property">
808 <with-param name=
"style-name" select=
"'color'"/>
809 <with-param name=
"style-property" select=
"$style-element/style:text-properties/@fo:color"/>
816 <if test=
"string-length($style) > 0">
817 <text><div
style=
"</text>
818 <value-of select="$style
"/>
824 <if test=
"string-length($style) > 0">
825 <text></div
></text>
828 <variable name=
"paragraph-right"
829 select=
"./following-sibling::*[1]/self::text:p"/>
832 <when test=
"boolean($paragraph-right)">
834 Insert end of line only if not within a list. Within wiki lists,
835 a line break leaves the current list item.
838 <when test=
"boolean(ancestor::text:list-item)">
839 <text><br/
></text>
842 <variable name=
"style-right">
843 <call-template name=
"mk-style-set">
844 <with-param name=
"node" select=
"$paragraph-right"/>
848 <variable name=
"code-right"
849 select=
"($style-right mod (2 * $CODE_BIT)) - ($style-right mod ($CODE_BIT)) != 0"/>
852 <when test=
"$code-right">
854 <when test=
"$CODE_JOIN_PARAGRAPHS">
855 <value-of select=
"$NL"/>
859 <value-of select=
"$NL"/>
860 <value-of select=
"' '"/>
861 <value-of select=
"$NL"/>
866 <value-of select=
"$NL"/>
867 <value-of select=
"$NL"/>
872 <value-of select=
"$NL"/>
873 <value-of select=
"$NL"/>
877 <when test=
"not(boolean(ancestor::text:note)) and (boolean(./following::*[1]/self::text:h) or boolean(./following::*[1]/self::table:table) or boolean(./following::*[1]/self::text:bibliography))">
878 <!-- Newline before following heading or table. -->
879 <value-of select=
"$NL"/>
880 <value-of select=
"$NL"/>
882 <when test=
"not(./following-sibling::*[1]) and name(./following::*[1])='text:p' and ancestor::text:list-item">
883 <!-- End of the list -->
884 <value-of select=
"$NL"/>
885 <value-of select=
"$NL"/>
890 <template match=
"text:p[string-length(.) = 0 and string-length(preceding-sibling::*[1]/self::text:p) > 0]">
891 <value-of select=
"$NL"/>
895 == Preformatted text ==
898 <template match=
"text:s">
899 <variable name=
"style">
900 <call-template name=
"mk-style-set">
901 <with-param name=
"node" select=
"."/>
905 <variable name=
"code"
906 select=
"($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/>
910 <when test=
"@text:c">
911 <call-template name=
"mk-token">
912 <with-param name=
"level" select=
"@text:c"/>
913 <with-param name=
"char" select=
"' '"/>
917 <value-of select=
"' '"/>
923 <template match=
"text:span[string-length(.) > 0]">
924 <if test=
"boolean(@text:style-name)">
925 <variable name=
"style-element" select=
"key('style-ref', @text:style-name)"/>
926 <variable name=
"style">
927 <call-template name=
"translate-style-property">
928 <with-param name=
"style-name" select=
"'background-color'"/>
929 <with-param name=
"style-property" select=
"$style-element/style:text-properties/@fo:background-color"/>
931 <call-template name=
"translate-style-property">
932 <with-param name=
"style-name" select=
"'color'"/>
933 <with-param name=
"style-property" select=
"$style-element/style:text-properties/@fo:color"/>
937 <if test=
"string-length($style) > 0">
938 <text><span
style=
"</text>
939 <value-of select="$style
"/>
945 <if test=
"string-length($style) > 0">
946 <text></span
></text>
951 <template match=
"text:tab">
952 <variable name=
"style">
953 <call-template name=
"mk-style-set">
954 <with-param name=
"node" select=
"."/>
958 <variable name=
"code"
959 select=
"($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/>
962 <value-of select=
"$CODE_TAB_REPLACEMENT"/>
966 <template match=
"text:line-break">
967 <variable name=
"style">
968 <call-template name=
"mk-style-set">
969 <with-param name=
"node" select=
"."/>
973 <variable name=
"code"
974 select=
"($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/>
977 <value-of select=
"$NL"/>
978 <value-of select=
"' '"/>
986 <template match=
"text:note-body">
987 <variable name=
"note" select=
"./parent::text:note"/>
989 <if test=
"$note/@text:note-class = 'footnote'">
990 <text><ref
name=
"</text>
991 <value-of select="$note/@text:id
"/>
994 <text></ref
></text>
998 <template match=
"text:note-ref[@text:note-class='footnote']">
999 <text><ref
name=
"</text>
1000 <value-of select="@text:ref-name
"/>
1009 <template match=
"draw:text-box[boolean(.//draw:image)]">
1010 <variable name=
"image" select=
".//draw:image[1]"/>
1012 <variable name=
"image-description">
1016 <variable name=
"picture">
1018 <call-template name=
"mk-image-name">
1019 <with-param name=
"image" select=
"$image"/>
1020 <with-param name=
"frame" select=
"."/>
1021 <with-param name=
"extension" select=
"'.png'"/>
1026 <!-- Picture markup + Horizontal & Vertical align -->
1027 <call-template name=
"mk-image-align">
1028 <with-param name=
"picture" select=
"$picture"/>
1031 <!-- Image caption -->
1033 <value-of select=
"normalize-space($image-description)"/>
1038 <template match=
"draw:image[not(boolean(ancestor::draw:text-box))]">
1039 <variable name=
"picture">
1041 <call-template name=
"mk-image-name">
1042 <with-param name=
"image" select=
"."/>
1043 <with-param name=
"frame" select=
"parent::node()"/>
1047 <!-- Picture markup + Horizontal & Vertical align -->
1048 <call-template name=
"mk-image-align">
1049 <with-param name=
"picture" select=
"$picture"/>
1053 <if test=
"name(following-sibling::*)='svg:title'">
1055 <value-of select="following-sibling::*/text()
"/>
1062 <template name=
"mk-image-align">
1063 <param name=
"picture"/>
1066 <when test=
"name(..)='draw:frame' and boolean(../@draw:style-name)">
1067 <variable name=
"style-element" select=
"key('style-ref', ../@draw:style-name)"/>
1069 <when test=
"boolean($style-element/style:graphic-properties/@style:wrap)">
1072 <when test=
"$style-element/style:graphic-properties/@style:wrap='none'">
1073 <text>{{clear}}
</text>
1074 <value-of select=
"$NL"/>
1075 <value-of select=
"$picture"/>
1077 <when test=
"boolean($style-element/style:graphic-properties/@style:horizontal-pos)">
1079 <when test=
"$style-element/style:graphic-properties/@style:horizontal-pos='center'">
1080 <text>|center
</text>
1092 <!-- wrap != none -->
1094 <value-of select=
"$picture"/>
1095 <!-- Horizontal align -->
1096 <call-template name=
"mk-image-horizontal-align">
1097 <with-param name=
"style-element" select=
"$style-element"/>
1099 <!-- Vertical align -->
1100 <call-template name=
"mk-image-vertical-align">
1101 <with-param name=
"style-element" select=
"$style-element"/>
1106 <!-- without wrap -->
1108 <value-of select=
"$picture"/>
1109 <!-- Horizontal align -->
1110 <call-template name=
"mk-image-horizontal-align">
1111 <with-param name=
"style-element" select=
"$style-element"/>
1113 <!-- Vertical align -->
1114 <call-template name=
"mk-image-vertical-align">
1115 <with-param name=
"style-element" select=
"$style-element"/>
1121 <value-of select=
"$picture"/>
1126 <template name=
"mk-image-horizontal-align">
1127 <param name=
"style-element"/>
1129 <if test=
"boolean($style-element/style:graphic-properties/@style:horizontal-pos)">
1131 <when test=
"$style-element/style:graphic-properties/@style:horizontal-pos='right'">
1134 <when test=
"$style-element/style:graphic-properties/@style:horizontal-pos='left'">
1141 <template name=
"mk-image-vertical-align">
1142 <param name=
"style-element"/>
1144 <if test=
"boolean($style-element/style:graphic-properties/@style:vertical-pos)">
1146 <when test=
"$style-element/style:graphic-properties/@style:vertical-pos='top'">
1149 <when test=
"$style-element/style:graphic-properties/@style:vertical-pos='middle'">
1150 <text>|middle
</text>
1152 <when test=
"$style-element/style:graphic-properties/@style:vertical-pos='below'">
1159 <template name=
"mk-image-name">
1160 <param name=
"image"/>
1161 <param name=
"frame"/>
1162 <param name=
"extension"/>
1164 <variable name=
"base-name">
1165 <call-template name=
"mk-base-name">
1166 <with-param name=
"href" select=
"$image/@xlink:href"/>
1170 <if test=
"not(starts-with($base-name, 'Image:'))">
1171 <value-of select=
"'Image:'"/>
1173 <value-of select=
"$base-name"/>
1174 <value-of select=
"$frame/@draw:name"/>
1175 <value-of select=
"'.png'"/>
1178 <template name=
"mk-base-name">
1179 <param name=
"href"/>
1181 <variable name=
"result" select=
"substring-after($href, '/')"/>
1183 <when test=
"boolean($result)">
1184 <call-template name=
"mk-base-name">
1185 <with-param name=
"href" select=
"$result"/>
1189 <value-of select=
"$href"/>
1196 <template match=
"draw:frame">
1198 <when test=
"draw:object/math:math">
1199 <apply-templates select=
"draw:object/math:math[1]"/>
1202 <when test=
"draw:image">
1203 <apply-templates select=
"draw:image[1]"/>
1207 <apply-templates select=
"./*[1]"/>
1213 <!-- Formulas (Objects) -->
1215 <include href=
"math/mmltex.xsl"/>
1217 <template match=
"math:math" priority=
"1">
1218 <text><math
></text>
1220 <text></math
></text>
1228 <!-- TODO: text:bibliography-mark -->
1230 <template match=
"text:reference-ref">
1231 <variable name=
"reference-mark" select=
"key('reference-resolution', @text:ref-name)"/>
1234 <when test=
"boolean($reference-mark)">
1236 In wiki syntax, only a local reference to a heading can be inserted.
1237 If the link target is a descendant of a heading element, a link can be
1238 inserted in the result. -->
1239 <variable name=
"header-anchor" select=
"$reference-mark/ancestor::text:h[1]"/>
1240 <if test=
"boolean($header-anchor)">
1242 <value-of select=
"string($header-anchor)"/>
1246 <variable name=
"reference-text" select=
"string(.)"/>
1249 <!-- Check, whether the reference text is cached in the document. -->
1250 <when test=
"string-length($reference-text) > 0">
1251 <value-of select=
"$reference-text"/>
1256 TODO: Evaluate the @text:reference-format attribute and
1257 generate the replacement text (difficult).-->
1258 <text>(REFERENCE TEXT UNAVAILABLE:
"</text>
1259 <value-of select="@text:ref-name
"/>
1264 <if test=
"boolean($header-anchor)">
1270 <text>(UNDEFINED REFERENCE:
"</text>
1271 <value-of select="@text:ref-name
"/>
1277 <template match=
"text:reference-mark">
1278 <!-- TODO: Output an anchor. -->
1282 <template match=
"text:reference-mark-start">
1283 <!-- TODO: Output an anchor. -->
1286 <template match=
"text:bookmark-start">
1287 <if test=
"boolean(@text:name)">
1288 <variable name=
"bookmark">
1290 <when test=
"contains(@text:name,'_')">
1291 <value-of select=
"translate(@text:name,'_','')"/>
1294 <value-of select=
"@text:name"/>
1298 <text>{{anchor|
</text>
1299 <value-of select=
"$bookmark"/>
1309 <template match=
"text:p/text() | text:h/text() | text:span/text() | text:sequence/text() | text:sequence-ref/text() | text:a/text() | text:bookmark-ref/text() | text:reference-mark/text() | text:date/text() | text:time/text() | text:page-number/text() | text:sender-firstname/text() | text:sender-lastname/text() | text:sender-initials/text() | text:sender-title/text() | text:sender-position/text() | text:sender-email/text() | text:sender-phone-private/text() | text:sender-fax/text() | text:sender-company/text() | text:sender-phone-work/text() | text:sender-street/text() | text:sender-city/text() | text:sender-postal-code/text() | text:sender-country/text() | text:sender-state-or-province/text() | text:author-name/text() | text:author-initials/text() | text:chapter/text() | text:file-name/text() | text:template-name/text() | text:sheet-name/text() | text:variable-get/text() | text:variable-input/text() | text:user-field-get/text() | text:user-field-input/text() | text:expression/text() | text:text-input/text() | text:initial-creator/text() | text:creation-date/text() | text:creation-time/text() | text:description/text() | text:user-defined/text() | text:print-date/text() | text:printed-by/text() | text:title/text() | text:subject/text() | text:keywords/text() | text:editing-cycles/text() | text:editing-duration/text() | text:modification-date/text() | text:creator/text() | text:modification-time/text() | text:page-count/text() | text:paragraph-count/text() | text:word-count/text() | text:character-count/text() | text:table-count/text() | text:image-count/text() | text:object-count/text() | text:database-display/text() | text:database-row-number/text() | text:database-name/text() | text:page-variable-get/text() | text:placeholder/text() | text:conditional-text/text() | text:hidden-text/text() | text:execute-macro/text() | text:dde-connection/text() | text:measure/text() | text:table-formula/text()">
1311 <when test=
"boolean(./ancestor::table:table-header-rows) or boolean(./ancestor::text:h)">
1313 No explicit styles within table headings or section headings,
1314 because those styles are consistently declared by the Wiki engine. -->
1315 <value-of select=
"."/>
1318 <when test=
"string-length(.) > 0">
1319 <variable name=
"style">
1320 <call-template name=
"mk-style-set">
1321 <with-param name=
"node" select=
"./parent::node()"/>
1325 <variable name=
"current-paragraph"
1326 select=
"./ancestor::text:p[1]"/>
1327 <variable name=
"paragraph-id"
1328 select=
"generate-id($current-paragraph)"/>
1329 <variable name=
"frames"
1330 select=
"$current-paragraph/descendant::draw:frame"/>
1331 <variable name=
"frame-count"
1332 select=
"count($frames)"/>
1335 The current style context consists of all text nodes that are
1336 descendants of the paragraph ancestor of this text node but not
1337 descendants of any frame nodes that are descendants of the current
1338 text nodes paragraph.
1340 <variable name=
"context"
1341 select=
"$current-paragraph//text()[not(boolean(./ancestor::draw:frame[1]) and count(./ancestor::draw:frame[1] | $frames) = $frame-count)]"/>
1342 <variable name=
"context-size" select=
"count($context)"/>
1344 <variable name=
"context-index">
1345 <call-template name=
"mk-context-index">
1346 <with-param name=
"current-id" select=
"generate-id(.)"/>
1347 <with-param name=
"context" select=
"$context"/>
1348 <with-param name=
"test-index" select=
"1"/>
1352 <variable name=
"style-left">
1354 <when test=
"$context-index > 1">
1355 <variable name=
"left" select=
"$context[$context-index - 1]"/>
1357 The preceding text node is a child of this nodes topmost
1358 styled ancestor. This means that the result of the
1359 transformation will be directly concatenated.
1361 <call-template name=
"mk-style-set">
1362 <with-param name=
"node" select=
"$left"/>
1366 <value-of select=
"$NO_STYLE"/>
1370 <variable name=
"style-right">
1372 <when test=
"$context-index < count($context)">
1373 <variable name=
"right" select=
"$context[$context-index + 1]"/>
1375 The preceding text node is a child of this nodes topmost
1376 styled ancestor. This means that the result of the
1377 transformation will be directly concatenated.
1379 <call-template name=
"mk-style-set">
1380 <with-param name=
"node" select=
"$right"/>
1384 <value-of select=
"$NO_STYLE"/>
1389 <variable name=
"bold"
1390 select=
"($style mod (2 * $BOLD_BIT)) != 0"/>
1391 <variable name=
"italic"
1392 select=
"($style mod (2 * $ITALIC_BIT)) - ($style mod ($ITALIC_BIT)) != 0"/>
1393 <variable name=
"underline"
1394 select=
"($style mod (2 * $UNDERLINE_BIT)) - ($style mod ($UNDERLINE_BIT)) != 0"/>
1395 <variable name=
"superscript"
1396 select=
"($style mod (2 * $SUPERSCRIPT_BIT)) - ($style mod ($SUPERSCRIPT_BIT)) != 0"/>
1397 <variable name=
"subscript"
1398 select=
"($style mod (2 * $SUBSCRIPT_BIT)) - ($style mod ($SUBSCRIPT_BIT)) != 0"/>
1399 <variable name=
"code"
1400 select=
"($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/>
1401 <variable name=
"typewriter"
1402 select=
"($style mod (2 * $TYPEWRITER_BIT)) - ($style mod ($TYPEWRITER_BIT)) != 0"/>
1404 <variable name=
"bold-left"
1405 select=
"($style-left mod (2 * $BOLD_BIT)) != 0"/>
1406 <variable name=
"italic-left"
1407 select=
"($style-left mod (2 * $ITALIC_BIT)) - ($style-left mod ($ITALIC_BIT)) != 0"/>
1408 <variable name=
"underline-left"
1409 select=
"($style-left mod (2 * $UNDERLINE_BIT)) - ($style-left mod ($UNDERLINE_BIT)) != 0"/>
1410 <variable name=
"superscript-left"
1411 select=
"($style-left mod (2 * $SUPERSCRIPT_BIT)) - ($style-left mod ($SUPERSCRIPT_BIT)) != 0"/>
1412 <variable name=
"subscript-left"
1413 select=
"($style-left mod (2 * $SUBSCRIPT_BIT)) - ($style-left mod ($SUBSCRIPT_BIT)) != 0"/>
1414 <variable name=
"typewriter-left"
1415 select=
"($style-left mod (2 * $TYPEWRITER_BIT)) - ($style-left mod ($TYPEWRITER_BIT)) != 0"/>
1417 <variable name=
"bold-right"
1418 select=
"($style-right mod (2 * $BOLD_BIT)) != 0"/>
1419 <variable name=
"italic-right"
1420 select=
"($style-right mod (2 * $ITALIC_BIT)) - ($style-right mod ($ITALIC_BIT)) != 0"/>
1421 <variable name=
"underline-right"
1422 select=
"($style-right mod (2 * $UNDERLINE_BIT)) - ($style-right mod ($UNDERLINE_BIT)) != 0"/>
1423 <variable name=
"superscript-right"
1424 select=
"($style-right mod (2 * $SUPERSCRIPT_BIT)) - ($style-right mod ($SUPERSCRIPT_BIT)) != 0"/>
1425 <variable name=
"subscript-right"
1426 select=
"($style-right mod (2 * $SUBSCRIPT_BIT)) - ($style-right mod ($SUBSCRIPT_BIT)) != 0"/>
1427 <variable name=
"typewriter-right"
1428 select=
"($style-right mod (2 * $TYPEWRITER_BIT)) - ($style-right mod ($TYPEWRITER_BIT)) != 0"/>
1430 <!-- Debugging: Add style infos to the output. -->
1432 <value-of select="'{'"/>
1433 <value-of select="$style-left"/>
1434 <value-of select="'-'"/>
1435 <value-of select="$style"/>
1436 <value-of select="','"/>
1437 <value-of select="$context-size"/>
1438 <value-of select="'}'"/>
1441 <if test=
"$superscript and not($superscript-left) and not(boolean(ancestor::text:note))">
1442 <text><sup
></text>
1444 <if test=
"$subscript and not($subscript-left)">
1445 <text><sub
></text>
1447 <if test=
"not($code) and $typewriter and not($typewriter-left)">
1448 <text><tt
></text>
1450 <if test=
"$underline and not($underline-left)">
1451 <text><u
></text>
1453 <if test=
"$bold and not($bold-left)">
1456 <if test=
"$italic and not($italic-left)">
1460 <call-template name=
"render-quoted-text">
1461 <with-param name=
"text" select=
"."/>
1464 <if test=
"$italic and not($italic-right)">
1467 <if test=
"$bold and not($bold-right)">
1470 <if test=
"$underline and not($underline-right)">
1471 <text></u
></text>
1473 <if test=
"not($code) and $typewriter and not($typewriter-right)">
1474 <text></tt
></text>
1476 <if test=
"$subscript and not($subscript-right)">
1477 <text></sub
></text>
1479 <if test=
"$superscript and not($superscript-right) and not(boolean(ancestor::text:note))">
1480 <text></sup
></text>
1483 <!-- Debugging: Add style details to the output. -->
1485 <value-of select="'{'"/>
1486 <value-of select="$style"/>
1487 <value-of select="'-'"/>
1488 <value-of select="$style-right"/>
1489 <value-of select="'}'"/>
1497 Function for looking up the position of a node identified by the given
1498 'current-id' within a node set 'context'.
1500 The search starts with the index 'test-index'. The search is recursive
1501 in the 'test-index' argument. To save recursion depth, each recursive call
1502 iteratively tests a fixed number of indexes (by loop unrolling).
1504 <template name=
"mk-context-index">
1505 <param name=
"current-id"/>
1506 <param name=
"context"/>
1507 <param name=
"test-index"/>
1509 <variable name=
"context-size" select=
"count($context)"/>
1512 <when test=
"context-size < $test-index">
1514 <when test=
"$current-id = generate-id($context[$test-index])">
1515 <value-of select=
"$test-index"/>
1517 <when test=
"context-size < ($test-index + 1)">
1519 <when test=
"$current-id = generate-id($context[$test-index + 1])">
1520 <value-of select=
"$test-index + 1"/>
1522 <when test=
"context-size < ($test-index + 2)">
1524 <when test=
"$current-id = generate-id($context[$test-index + 2])">
1525 <value-of select=
"$test-index + 2"/>
1527 <when test=
"context-size < ($test-index + 3)">
1529 <when test=
"$current-id = generate-id($context[$test-index + 3])">
1530 <value-of select=
"$test-index + 3"/>
1532 <when test=
"context-size < ($test-index + 4)">
1534 <when test=
"$current-id = generate-id($context[$test-index + 4])">
1535 <value-of select=
"$test-index + 4"/>
1537 <when test=
"context-size < ($test-index + 5)">
1539 <when test=
"$current-id = generate-id($context[$test-index + 5])">
1540 <value-of select=
"$test-index + 5"/>
1542 <when test=
"context-size < ($test-index + 6)">
1545 <call-template name=
"mk-context-index">
1546 <with-param name=
"current-id" select=
"$current-id"/>
1547 <with-param name=
"context" select=
"$context"/>
1548 <with-param name=
"test-index" select=
"$test-index + 6"/>
1554 <template name=
"render-quoted-text">
1555 <param name=
"text"/>
1558 <when test=
"contains($text, '[[') or starts-with($text, '----') or starts-with($text, '=') or starts-with($text, '*') or starts-with($text, ';') or starts-with($text, '#')">
1559 <text><nowiki
></text>
1560 <call-template name=
"render-encoded-text">
1561 <with-param name=
"text" select=
"$text"/>
1563 <text></nowiki
></text>
1566 <call-template name=
"render-encoded-text">
1567 <with-param name=
"text" select=
"$text"/>
1573 <template name=
"render-escaped-text">
1574 <param name=
"text"/>
1577 <when test=
"contains($text, '<')">
1578 <call-template name=
"render-encoded-text">
1579 <with-param name=
"text" select=
"substring-before($text, '<')"/>
1581 <value-of select=
"'&lt;'"/>
1582 <call-template name=
"render-escaped-text">
1583 <with-param name=
"text" select=
"substring-after($text, '<')"/>
1587 <call-template name=
"render-encoded-text">
1588 <with-param name=
"text" select=
"$text"/>
1594 <template name=
"render-encoded-text">
1595 <param name=
"text"/>
1598 <when test=
"contains($text, ' ')">
1599 <value-of select=
"substring-before($text, ' ')"/>
1600 <value-of select=
"'&nbsp;'"/>
1601 <call-template name=
"render-encoded-text">
1602 <with-param name=
"text" select=
"substring-after($text, ' ')"/>
1606 <value-of select=
"$text"/>
1612 == Wiki styles: bold, italics, ... ==
1615 <template name=
"mk-style-set">
1616 <param name=
"node"/>
1619 <when test=
"$node/ancestor-or-self::*[@text:style-name]">
1620 <variable name=
"context" select=
"$node/ancestor-or-self::*[@text:style-name][1]"/>
1621 <call-template name=
"mk-style-set-internal">
1622 <with-param name=
"node" select=
"$context"/>
1623 <with-param name=
"style" select=
"key('style-ref', $context/@text:style-name)"/>
1624 <with-param name=
"style-set" select=
"$NO_STYLE"/>
1625 <with-param name=
"style-mask" select=
"$NO_STYLE"/>
1629 <value-of select=
"$NO_STYLE"/>
1635 Compute the wiki style set that corresponds
1636 to the given office style at the given context node.
1639 A node in which context the style is computed. If neither the given style
1640 nor one of its linked styles does specify a style of the given type,
1641 ancestor nodes of the given context node are considered.
1643 A style:style element node. The style of the requested type is searched
1644 in the given style and its linked styles.
1646 A bit set of styles already defined by the context.
1648 A bit set of styles that must not be taken from the currently inspected
1649 style, because those styles are already defined by the context.
1651 @return A bit set composed of the wiki style constants.
1653 <template name=
"mk-style-set-internal">
1654 <param name=
"node"/>
1655 <param name=
"style"/>
1656 <param name=
"style-set"/>
1657 <param name=
"style-mask"/>
1659 <variable name=
"text-properties" select=
"$style/style:text-properties"/>
1661 <!-- Decompose style-mask into individual bits. -->
1662 <variable name=
"bold-requested"
1663 select=
"($style-mask mod (2 * $BOLD_BIT)) = 0"/>
1664 <variable name=
"italic-requested"
1665 select=
"($style-mask mod (2 * $ITALIC_BIT)) - ($style-mask mod ($ITALIC_BIT)) = 0"/>
1666 <variable name=
"underline-requested"
1667 select=
"($style-mask mod (2 * $UNDERLINE_BIT)) - ($style-mask mod ($UNDERLINE_BIT)) = 0"/>
1668 <variable name=
"superscript-requested"
1669 select=
"($style-mask mod (2 * $SUPERSCRIPT_BIT)) - ($style-mask mod ($SUPERSCRIPT_BIT)) = 0"/>
1670 <variable name=
"subscript-requested"
1671 select=
"($style-mask mod (2 * $SUBSCRIPT_BIT)) - ($style-mask mod ($SUBSCRIPT_BIT)) = 0"/>
1672 <variable name=
"typewriter-requested"
1673 select=
"($style-mask mod (2 * $TYPEWRITER_BIT)) - ($style-mask mod ($TYPEWRITER_BIT)) = 0"/>
1674 <variable name=
"code-requested"
1675 select=
"($style-mask mod (2 * $CODE_BIT)) - ($style-mask mod ($CODE_BIT)) = 0"/>
1676 <variable name=
"center-requested"
1677 select=
"($style-mask mod (2 * $CENTER_BIT)) - ($style-mask mod ($CENTER_BIT)) = 0"/>
1678 <variable name=
"right-requested"
1679 select=
"($style-mask mod (2 * $RIGHT_BIT)) - ($style-mask mod ($RIGHT_BIT)) = 0"/>
1681 <!-- Extract styles that are not already defined by the context. -->
1682 <variable name=
"bold-style">
1684 <when test=
"$bold-requested and boolean($text-properties/@fo:font-weight='bold')">
1685 <!-- Bold found in current style. -->
1686 <value-of select=
"$BOLD_BIT"/>
1689 <value-of select=
"$NO_STYLE"/>
1693 <variable name=
"bold-mask">
1695 <when test=
"$bold-requested and boolean($text-properties/@fo:font-weight)">
1697 Other value than "bold" means that the character style is not
1698 bold and no parent style must be considered.
1700 <value-of select=
"$BOLD_BIT"/>
1703 <value-of select=
"$NO_STYLE"/>
1708 <variable name=
"italic-style">
1710 <when test=
"$italic-requested and boolean($text-properties/@fo:font-style='italic')">
1711 <!-- Italic found in current style. -->
1712 <value-of select=
"$ITALIC_BIT"/>
1715 <value-of select=
"$NO_STYLE"/>
1719 <variable name=
"italic-mask">
1721 <when test=
"$italic-requested and boolean($text-properties/@fo:font-style)">
1723 Other value than "italic" means that the character style is not
1724 italic and no parent style must be considered.
1726 <value-of select=
"$ITALIC_BIT"/>
1729 <value-of select=
"$NO_STYLE"/>
1734 <variable name=
"underline-style">
1736 <when test=
"$underline-requested and boolean($text-properties/@style:text-underline-style='solid')">
1737 <!-- Underline found in current style. -->
1738 <value-of select=
"$UNDERLINE_BIT"/>
1741 <value-of select=
"$NO_STYLE"/>
1745 <variable name=
"underline-mask">
1747 <when test=
"$underline-requested and boolean($text-properties/@style:text-underline-style='solid')">
1749 Other value than "underline" means that the character style is not
1750 underline and no parent style must be considered.
1752 <value-of select=
"$UNDERLINE_BIT"/>
1755 <value-of select=
"$NO_STYLE"/>
1760 <variable name=
"superscript-style">
1762 <when test=
"$superscript-requested and contains($text-properties/@style:text-position, 'super')">
1763 <value-of select=
"$SUPERSCRIPT_BIT"/>
1766 <value-of select=
"$NO_STYLE"/>
1770 <variable name=
"superscript-mask">
1772 <when test=
"$superscript-requested and boolean($text-properties/@style:text-position)">
1773 <value-of select=
"$SUPERSCRIPT_BIT"/>
1776 <value-of select=
"$NO_STYLE"/>
1781 <variable name=
"subscript-style">
1783 <when test=
"$subscript-requested and contains($text-properties/@style:text-position, 'sub')">
1784 <value-of select=
"$SUBSCRIPT_BIT"/>
1787 <value-of select=
"$NO_STYLE"/>
1791 <variable name=
"subscript-mask">
1793 <when test=
"$subscript-requested and boolean($text-properties/@style:text-position)">
1794 <value-of select=
"$SUBSCRIPT_BIT"/>
1797 <value-of select=
"$NO_STYLE"/>
1802 <variable name=
"typewriter-style">
1804 <when test=
"$typewriter-requested and ($style/@style:family='text') and boolean($text-properties/@style:font-name)">
1805 <variable name=
"font-face"
1806 select=
"key('font-face-ref', $text-properties/@style:font-name)"/>
1808 <when test=
"$font-face/@style:font-pitch='fixed'">
1809 <value-of select=
"$TYPEWRITER_BIT"/>
1812 <value-of select=
"$NO_STYLE"/>
1817 <value-of select=
"$NO_STYLE"/>
1821 <variable name=
"typewriter-mask">
1823 <!-- Note: Suppress the typewriter style on text within a code paragraph. -->
1824 <when test=
"$typewriter-requested and boolean($text-properties/@style:font-name)">
1825 <value-of select=
"$TYPEWRITER_BIT"/>
1828 <value-of select=
"$NO_STYLE"/>
1833 <variable name=
"code-style">
1835 <when test=
"$code-requested and ($style/@style:family='paragraph') and boolean($text-properties/@style:font-name)">
1836 <variable name=
"font-face"
1837 select=
"key('font-face-ref', $text-properties/@style:font-name)"/>
1839 <when test=
"$font-face/@style:font-pitch='fixed' or (boolean(@style:display-name) and contains($CODE_STYLES, $style/@style:display-name))">
1840 <value-of select=
"$CODE_BIT"/>
1843 <value-of select=
"$NO_STYLE"/>
1848 <value-of select=
"$NO_STYLE"/>
1852 <variable name=
"code-mask">
1854 <when test=
"$code-requested and ($style/@style:family='paragraph') and boolean($text-properties/@style:font-name)">
1855 <value-of select=
"$CODE_BIT"/>
1858 <value-of select=
"$NO_STYLE"/>
1863 <variable name=
"center-style">
1865 <when test=
"$center-requested and ($style/@style:family='paragraph') and boolean($style/style:paragraph-properties/@fo:text-align='center')">
1866 <value-of select=
"$CENTER_BIT"/>
1869 <value-of select=
"$NO_STYLE"/>
1873 <variable name=
"center-mask">
1875 <when test=
"$center-requested and ($style/@style:family='paragraph') and boolean($style/style:paragraph-properties/@fo:text-align)">
1876 <value-of select=
"$CENTER_BIT"/>
1879 <value-of select=
"$NO_STYLE"/>
1884 <variable name=
"right-style">
1886 <when test=
"$right-requested and ($style/@style:family='paragraph') and boolean($style/style:paragraph-properties/@fo:text-align='end')">
1887 <value-of select=
"$RIGHT_BIT"/>
1890 <value-of select=
"$NO_STYLE"/>
1894 <variable name=
"right-mask">
1896 <when test=
"$center-requested and ($style/@style:family='paragraph') and boolean($style/style:paragraph-properties/@fo:text-align)">
1897 <value-of select=
"$RIGHT_BIT"/>
1900 <value-of select=
"$NO_STYLE"/>
1906 <!-- Compute the updated styles and mask. -->
1908 Note: The bit masks style-mask, bold-style, italic-style,... are
1909 guaranteed to be disjoint, therefore, addition can be use instead
1910 of bitwise or (which is missing in XPath). -->
1911 <variable name=
"updated-style"
1912 select=
"$style-set + $bold-style + $italic-style + $underline-style + $superscript-style + $subscript-style + $code-style + $typewriter-style + $center-style + $right-style"/>
1913 <variable name=
"updated-mask"
1914 select=
"$style-mask + $bold-mask + $italic-mask + $underline-mask + $superscript-mask + $subscript-mask + $code-mask + $typewriter-mask + $center-mask + $right-mask"/>
1916 <!-- Inspect linked and nested styles. -->
1918 <when test=
"boolean($style/@style:parent-style-name)">
1919 <!-- Look through the style, the current style is based on. -->
1920 <call-template name=
"mk-style-set-internal">
1921 <with-param name=
"node" select=
"$node"/>
1922 <with-param name=
"style" select=
"key('style-ref', $style/@style:parent-style-name)"/>
1923 <with-param name=
"style-set" select=
"$updated-style"/>
1924 <with-param name=
"style-mask" select=
"$updated-mask"/>
1928 <variable name=
"ancestors" select=
"$node/ancestor::*[@text:style-name][1]"/>
1930 <!-- Debugging: Print currently inspected style. -->
1933 <value-of select="'{'"/>
1934 <value-of select="$style/@style:name"/>
1935 <value-of select="','"/>
1936 <value-of select="$updated-style"/>
1937 <value-of select="','"/>
1938 <value-of select="$updated-mask"/>
1939 <value-of select="','"/>
1940 <value-of select="local-name($ancestors)"/>
1941 <value-of select="',('"/>
1942 <value-of select="$node"/>
1943 <value-of select="')'"/>
1944 <value-of select="'}'"/>
1949 If there is an ancestor that has a style, use that style,
1950 otherwise, a style is not found. -->
1952 <when test=
"boolean($ancestors)">
1953 <!-- Look through the style of the nearest ancestor that has a style. -->
1954 <call-template name=
"mk-style-set-internal">
1955 <with-param name=
"node" select=
"$ancestors"/>
1956 <with-param name=
"style" select=
"key('style-ref', $ancestors/@text:style-name)"/>
1957 <with-param name=
"style-set" select=
"$updated-style"/>
1958 <with-param name=
"style-mask" select=
"$updated-mask"/>
1962 <!-- No more styles to inspect. Return the result. -->
1963 <value-of select=
"$updated-style"/>
1972 == Descending the tree ==
1975 <template match=
"/">
1977 <value-of select=
"$NL"/>
1978 <if test=
"boolean(//text:note[@text:note-class='footnote'])">
1979 <value-of select=
"$NL"/>
1981 <value-of select=
"$NL"/>
1982 <text><references/
></text>
1983 <value-of select=
"$NL"/>
1987 <template match=
"office:document-content">
1991 <template match=
"office:body">
1995 <template match=
"text:tracked-changes">
1996 <!-- Ignore change history. -->
1999 <template match=
"office:* | text:* | draw:text-box | draw:a">
2003 <template match=
"node()">