1 <?xml version="1.0" encoding="UTF-8"?>
4 odt2phpwiki: OpenDocument to Phpwiki transformation
5 Copyright (C) 2007 Bernhard Haumacher (haui at haumacher dot de)
6 Copyright (C) 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 This program is based on the OpenDocument to Mediawiki converter by
25 Modifications to convert to Phpwiki were made by Marc-Etienne Vargenau
26 and are Copyright (C) 2008-2009 Alcatel-Lucent
28 Standard Alcatel-Lucent disclaimer for contributing to open source
30 "The OpenDocument to Phpwiki converter ("Contribution") has not been tested and/or
31 validated for release as or in products, combinations with products or
32 other commercial use. Any use of the Contribution is entirely made at
33 the user's own responsibility and the user can not rely on any features,
34 functionalities or performances Alcatel-Lucent has attributed to the
37 THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
38 OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
39 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
40 NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
41 CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
42 ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
43 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
44 CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
45 TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
49 <stylesheet version="1.0"
50 xmlns="http://www.w3.org/1999/XSL/Transform"
52 xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
53 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
54 xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
55 xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
56 xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
57 xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
58 xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
59 xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
60 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
61 xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
62 xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
63 xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
64 xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
65 xmlns:xlink="http://www.w3.org/1999/xlink"
66 xmlns:dc="http://purl.org/dc/elements/1.1/"
67 xmlns:math="http://www.w3.org/1998/Math/MathML"
68 xmlns:dom="http://www.w3.org/2001/xml-events"
69 xmlns:xforms="http://www.w3.org/2002/xforms"
70 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
71 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
75 media-type="text/plain"
80 == Reference resolution ==
91 match="//text:list-style"
97 match="//style:font-face"
102 name="reference-resolution"
103 match="//text:reference-mark | //text:reference-mark-start"
108 <!-- Wiki style constants. -->
110 <!-- Bold character style. -->
111 <variable name="BOLD_BIT" select="1"/>
113 <!-- Italic character style. -->
114 <variable name="ITALIC_BIT" select="2"/>
116 <!-- Subscript character style. -->
117 <variable name="SUBSCRIPT_BIT" select="4"/>
119 <!-- Superscript character style. -->
120 <variable name="SUPERSCRIPT_BIT" select="8"/>
122 <!-- Typewriter character style. -->
123 <variable name="TYPEWRITER_BIT" select="16"/>
125 <!-- Preformatted text paragraph style. -->
126 <variable name="CODE_BIT" select="32"/>
128 <!-- Centered paragraph style. -->
129 <variable name="CENTER_BIT" select="64"/>
131 <!-- Right aligned paragraph style. -->
132 <variable name="RIGHT_BIT" select="128"/>
134 <!-- Constant defining the empty style. -->
135 <variable name="NO_STYLE" select="0"/>
137 <!-- Constant defining the newline token. -->
138 <variable name="NL" select="' '"/>
141 Multiple pages (draw only)
144 <template match="draw:page">
145 <value-of select="concat(' <!-- Page ', @draw:name, '--> ')"/>
147 <value-of select="' ---- '"/>
155 <template match="text:list-item">
156 <if test="position() > 1 or boolean(ancestor::text:list-item)">
157 <value-of select="$NL"/>
159 <variable name="list-style"
160 select="key('list-style-ref',ancestor::text:list[boolean(@text:style-name)][1]/@text:style-name)"/>
161 <call-template name="mk-list-token">
162 <with-param name="list-style" select="$list-style"/>
163 <with-param name="level" select="count(ancestor::text:list)"/>
167 <if test="position() = last() and not(boolean(ancestor::text:list-item))">
168 <value-of select="$NL"/>
169 <value-of select="$NL"/>
173 <template name="mk-list-token">
174 <param name="list-style"/>
175 <param name="level"/>
177 <if test="$level > 1">
178 <call-template name="mk-list-token">
179 <with-param name="list-style" select="$list-style"/>
180 <with-param name="level" select="$level - 1"/>
184 <variable name="number-style" select="$list-style/text:list-level-style-number[@text:level=$level]"/>
185 <variable name="bullet-style" select="$list-style/text:list-level-style-bullet[@text:level=$level]"/>
187 <when test="boolean($number-style)">
189 <when test="string-length($number-style/@style:num-format) > 0">
197 <when test="boolean($bullet-style)">
208 <template match="text:h">
209 <if test="string-length(.) > 0">
210 <variable name="token">
211 <call-template name="mk-heading-prefix">
212 <with-param name="level" select="1 + @text:outline-level"/>
215 <value-of select="$token"/>
219 <value-of select="$token"/>
225 Function generating a wiki heading prefix.
228 The heading level. The value must be between 1 and 5.
230 <template name="mk-heading-prefix">
231 <param name="level"/>
233 <when test="$level > 6">
234 <call-template name="mk-heading-prefix">
235 <with-param name="level" select="6"/>
238 <when test="$level > 0">
240 <call-template name="mk-heading-prefix">
241 <with-param name="level" select="$level - 1"/>
248 Function generating a token consisting of the given character
249 repeated 'level' times.
252 The lengh of the result.
254 The character that should be repeated 'level' times.
256 <template name="mk-token">
257 <param name="level"/>
259 <if test="$level > 0">
260 <value-of select="$char"/>
261 <call-template name="mk-token">
262 <with-param name="level" select="$level - 1"/>
263 <with-param name="char" select="$char"/>
273 <template match="table:table">
275 <text>{| class="bordered"</text>
285 <template match="table:table-header-rows">
289 <template match="table:table-row[position() < last()] | table:table-header-rows/table:table-row">
296 <template match="table:table-row">
300 <template match="table:table-header-rows//table:table-cell">
302 <if test="@table:number-columns-spanned">
303 <text>colspan="</text>
304 <value-of select="@table:number-columns-spanned"/>
308 <value-of select="$NL"/>
311 <template match="table:table-cell">
313 <if test="@table:number-columns-spanned">
314 <text>colspan="</text>
315 <value-of select="@table:number-columns-spanned"/>
319 <value-of select="$NL"/>
327 <template match="text:span[@text:style-name='WikiMath']">
328 <value-of select="'<math>'"/>
330 <value-of select="'</math>'"/>
338 <template match="text:a">
339 <variable name="link-ref" select="@xlink:href"/>
341 <when test="string-length($link-ref) > 0">
342 <variable name="link-label" select="string(.)"/>
344 <value-of select="$link-ref"/>
346 <value-of select="$link-label"/>
361 <template match="text:span[@text:style-name='WikiLink']">
362 <value-of select="'[['"/>
363 <variable name="link-def" select="string(.)"/>
364 <variable name="link-label" select="normalize-space(substring-before($link-def, '['))"/>
365 <variable name="link-ref" select="normalize-space(substring-before(substring-after($link-def, '['), ']'))"/>
367 <when test="boolean($link-ref)">
368 <value-of select="concat($link-ref, '|', $link-label)"/>
371 <value-of select="$link-def"/>
374 <value-of select="']]'"/>
382 <template match="text:p[string-length(.) > 0]">
383 <variable name="style">
384 <call-template name="mk-style-set">
385 <with-param name="node" select="."/>
389 <variable name="code"
390 select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/>
391 <variable name="center"
392 select="($style mod (2 * $CENTER_BIT)) - ($style mod ($CENTER_BIT)) != 0"/>
393 <variable name="right"
394 select="($style mod (2 * $RIGHT_BIT)) - ($style mod ($RIGHT_BIT)) != 0"/>
397 <when test="$center">
398 <text><div align="center"></text>
401 <text><div align="right"></text>
404 <value-of select="' '"/>
411 <when test="$center">
412 <text></div></text>
415 <text></div></text>
419 <variable name="paragraph-right"
420 select="./following-sibling::text:p[1]"/>
422 <if test="boolean($paragraph-right)">
424 Insert end of line only if not within a list. Within wiki lists,
425 a line break leaves the current list item.
428 <when test="boolean(ancestor::text:list-item)">
432 <variable name="style-right">
433 <call-template name="mk-style-set">
434 <with-param name="node" select="$paragraph-right"/>
438 <variable name="code-right"
439 select="($style-right mod (2 * $CODE_BIT)) - ($style-right mod ($CODE_BIT)) != 0"/>
441 <value-of select="$NL"/>
442 <if test="$code-right">
443 <value-of select="' '"/>
445 <value-of select="$NL"/>
448 <value-of select="$NL"/>
449 <value-of select="$NL"/>
455 <template match="text:p[string-length(.) = 0 and string-length(preceding-sibling::text:p[1]) > 0]">
456 <value-of select="$NL"/>
461 == Preformatted text ==
464 <template match="text:s">
465 <variable name="style">
466 <call-template name="mk-style-set">
467 <with-param name="node" select="."/>
471 <variable name="code"
472 select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/>
476 <when test="@text:c">
477 <call-template name="mk-token">
478 <with-param name="level" select="@text:c"/>
479 <with-param name="char" select="' '"/>
483 <value-of select="' '"/>
489 <template match="text:line-break">
490 <variable name="style">
491 <call-template name="mk-style-set">
492 <with-param name="node" select="."/>
496 <variable name="code"
497 select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/>
500 <value-of select="$NL"/>
501 <value-of select="' '"/>
509 <template match="text:note-body">
510 <variable name="note" select="./parent::text:note"/>
512 <if test="$note/@text:note-class = 'footnote'">
513 <text><ref name="</text>
514 <value-of select="$note/@text:id"/>
517 <text></ref></text>
521 <template match="text:note-ref[@text:note-class='footnote']">
522 <text><ref name="</text>
523 <value-of select="@text:ref-name"/>
532 <template match="draw:text-box[boolean(.//draw:image)]">
533 <variable name="image" select=".//draw:image[1]"/>
535 <variable name="image-description">
540 <call-template name="mk-image-name">
541 <with-param name="image" select="$image"/>
544 <value-of select="normalize-space($image-description)"/>
548 <template match="draw:image[not(boolean(ancestor::draw:text-box))]">
550 <call-template name="mk-image-name">
551 <with-param name="image" select="."/>
556 <template name="mk-image-name">
557 <param name="image"/>
559 <variable name="base-name">
560 <call-template name="mk-base-name">
561 <with-param name="href" select="$image/@xlink:href"/>
565 <if test="not(starts-with($base-name, 'Image:'))">
566 <value-of select="'Image:'"/>
568 <value-of select="$base-name"/>
571 <template name="mk-base-name">
574 <variable name="result" select="substring-after($href, '/')"/>
576 <when test="boolean($result)">
577 <call-template name="mk-base-name">
578 <with-param name="href" select="$result"/>
582 <value-of select="$href"/>
592 <!-- TODO: text:bibliography-mark -->
594 <template match="text:reference-ref">
595 <variable name="reference-mark" select="key('reference-resolution', @text:ref-name)"/>
598 <when test="boolean($reference-mark)">
600 In wiki syntax, only a local reference to a heading can be inserted.
601 If the link target is a descendant of a heading element, a link can be
602 inserted in the result. -->
603 <variable name="header-anchor" select="$reference-mark/ancestor::text:h[1]"/>
604 <if test="boolean($header-anchor)">
606 <value-of select="string($header-anchor)"/>
610 <variable name="reference-text" select="string(.)"/>
613 <!-- Check, whether the reference text is cached in the document. -->
614 <when test="string-length($reference-text) > 0">
615 <value-of select="$reference-text"/>
620 TODO: Evaluate the @text:reference-format attribute and
621 generate the replacement text (difficult).-->
622 <text>(REFERENCE TEXT UNAVAILABLE: "</text>
623 <value-of select="@text:ref-name"/>
628 <if test="boolean($header-anchor)">
634 <text>(UNDEFINED REFERENCE: "</text>
635 <value-of select="@text:ref-name"/>
641 <template match="text:reference-mark">
642 <!-- TODO: Output an anchor. -->
646 <template match="text:reference-mark-start">
647 <!-- TODO: Output an anchor. -->
654 <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()">
656 <when test="boolean(./ancestor::table:table-header-rows | ./ancestor::text:h)">
658 No explicit styles within table headings or section headings,
659 because those styles are consistently declared by the Wiki engine. -->
660 <value-of select="."/>
663 <when test="string-length(.) > 0">
664 <variable name="style">
665 <call-template name="mk-style-set">
666 <with-param name="node" select="."/>
670 <variable name="current-paragraph"
671 select="./ancestor::text:p[1]"/>
672 <variable name="paragraph-id"
673 select="generate-id($current-paragraph)"/>
674 <variable name="frames"
675 select="$current-paragraph/descendant::draw:frame"/>
676 <variable name="frame-count"
677 select="count($frames)"/>
680 The current style context consists of all text nodes that are
681 descendants of the paragraph ancestor of this text node but not
682 descendants of any frame nodes that are descendants of the current
683 text nodes paragraph.
685 <variable name="context"
686 select="$current-paragraph//text()[not(boolean(./ancestor::draw:frame[1]) and count(./ancestor::draw:frame[1] | $frames) = $frame-count)]"/>
687 <variable name="context-size" select="count($context)"/>
689 <variable name="context-index">
690 <call-template name="mk-context-index">
691 <with-param name="current-id" select="generate-id(.)"/>
692 <with-param name="context" select="$context"/>
693 <with-param name="test-index" select="1"/>
697 <variable name="style-left">
699 <when test="$context-index > 1">
700 <variable name="left" select="$context[$context-index - 1]"/>
702 The preceding text node is a child of this nodes topmost
703 styled ancestor. This means that the result of the
704 transformation will be directly concatenated.
706 <call-template name="mk-style-set">
707 <with-param name="node" select="$left"/>
711 <value-of select="$NO_STYLE"/>
715 <variable name="style-right">
717 <when test="$context-index < count($context)">
718 <variable name="right" select="$context[$context-index + 1]"/>
720 The preceding text node is a child of this nodes topmost
721 styled ancestor. This means that the result of the
722 transformation will be directly concatenated.
724 <call-template name="mk-style-set">
725 <with-param name="node" select="$right"/>
729 <value-of select="$NO_STYLE"/>
734 <variable name="bold"
735 select="($style mod (2 * $BOLD_BIT)) != 0"/>
736 <variable name="italic"
737 select="($style mod (2 * $ITALIC_BIT)) - ($style mod ($ITALIC_BIT)) != 0"/>
738 <variable name="superscript"
739 select="($style mod (2 * $SUPERSCRIPT_BIT)) - ($style mod ($SUPERSCRIPT_BIT)) != 0"/>
740 <variable name="subscript"
741 select="($style mod (2 * $SUBSCRIPT_BIT)) - ($style mod ($SUBSCRIPT_BIT)) != 0"/>
742 <variable name="code"
743 select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/>
744 <variable name="typewriter"
745 select="($style mod (2 * $TYPEWRITER_BIT)) - ($style mod ($TYPEWRITER_BIT)) != 0"/>
747 <variable name="bold-left"
748 select="($style-left mod (2 * $BOLD_BIT)) != 0"/>
749 <variable name="italic-left"
750 select="($style-left mod (2 * $ITALIC_BIT)) - ($style-left mod ($ITALIC_BIT)) != 0"/>
751 <variable name="superscript-left"
752 select="($style-left mod (2 * $SUPERSCRIPT_BIT)) - ($style-left mod ($SUPERSCRIPT_BIT)) != 0"/>
753 <variable name="subscript-left"
754 select="($style-left mod (2 * $SUBSCRIPT_BIT)) - ($style-left mod ($SUBSCRIPT_BIT)) != 0"/>
755 <variable name="typewriter-left"
756 select="($style-left mod (2 * $TYPEWRITER_BIT)) - ($style-left mod ($TYPEWRITER_BIT)) != 0"/>
758 <variable name="bold-right"
759 select="($style-right mod (2 * $BOLD_BIT)) != 0"/>
760 <variable name="italic-right"
761 select="($style-right mod (2 * $ITALIC_BIT)) - ($style-right mod ($ITALIC_BIT)) != 0"/>
762 <variable name="superscript-right"
763 select="($style-right mod (2 * $SUPERSCRIPT_BIT)) - ($style-right mod ($SUPERSCRIPT_BIT)) != 0"/>
764 <variable name="subscript-right"
765 select="($style-right mod (2 * $SUBSCRIPT_BIT)) - ($style-right mod ($SUBSCRIPT_BIT)) != 0"/>
766 <variable name="typewriter-right"
767 select="($style-right mod (2 * $TYPEWRITER_BIT)) - ($style-right mod ($TYPEWRITER_BIT)) != 0"/>
769 <!-- Debugging: Add style infos to the output. -->
771 <value-of select="'{'"/>
772 <value-of select="$style-left"/>
773 <value-of select="'-'"/>
774 <value-of select="$style"/>
775 <value-of select="','"/>
776 <value-of select="$context-size"/>
777 <value-of select="'}'"/>
780 <if test="$superscript and not($superscript-left)">
783 <if test="$subscript and not($subscript-left)">
786 <if test="not($code) and $typewriter and not($typewriter-left)">
789 <if test="$bold and not($bold-left)">
792 <if test="$italic and not($italic-left)">
796 <call-template name="render-quoted-text">
797 <with-param name="text" select="."/>
800 <if test="$italic and not($italic-right)">
803 <if test="$bold and not($bold-right)">
806 <if test="not($code) and $typewriter and not($typewriter-right)">
809 <if test="$subscript and not($subscript-right)">
812 <if test="$superscript and not($superscript-right)">
816 <!-- Debugging: Add style details to the output. -->
818 <value-of select="'{'"/>
819 <value-of select="$style"/>
820 <value-of select="'-'"/>
821 <value-of select="$style-right"/>
822 <value-of select="'}'"/>
830 Function for looking up the position of a node identified by the given
831 'current-id' within a node set 'context'.
833 The search starts with the the index 'test-index'. The search is recursive
834 in the 'test-index' argument. To save recursion depth, each recursive call
835 iteratively tests a fixed number of indexes (by loop unrolling).
837 <template name="mk-context-index">
838 <param name="current-id"/>
839 <param name="context"/>
840 <param name="test-index"/>
842 <variable name="context-size" select="count($context)"/>
845 <when test="context-size < $test-index">
847 <when test="$current-id = generate-id($context[$test-index])">
848 <value-of select="$test-index"/>
850 <when test="context-size < ($test-index + 1)">
852 <when test="$current-id = generate-id($context[$test-index + 1])">
853 <value-of select="$test-index + 1"/>
855 <when test="context-size < ($test-index + 2)">
857 <when test="$current-id = generate-id($context[$test-index + 2])">
858 <value-of select="$test-index + 2"/>
860 <when test="context-size < ($test-index + 3)">
862 <when test="$current-id = generate-id($context[$test-index + 3])">
863 <value-of select="$test-index + 3"/>
865 <when test="context-size < ($test-index + 4)">
867 <when test="$current-id = generate-id($context[$test-index + 4])">
868 <value-of select="$test-index + 4"/>
870 <when test="context-size < ($test-index + 5)">
872 <when test="$current-id = generate-id($context[$test-index + 5])">
873 <value-of select="$test-index + 5"/>
875 <when test="context-size < ($test-index + 6)">
878 <call-template name="mk-context-index">
879 <with-param name="current-id" select="$current-id"/>
880 <with-param name="context" select="$context"/>
881 <with-param name="test-index" select="$test-index + 6"/>
887 <template name="render-quoted-text">
891 <when test="contains($text, '<') or contains($text, '[') or starts-with($text, '----') or starts-with($text, '=') or starts-with($text, '*') or starts-with($text, ';') or starts-with($text, '#')">
892 <text><nowiki></text>
894 <when test="contains($text, '</nowiki>')">
895 <call-template name="render-escaped-text">
896 <with-param name="text" select="$text"/>
900 <value-of select="$text"/>
903 <text></nowiki></text>
906 <value-of select="$text"/>
911 <template name="render-escaped-text">
915 <when test="contains($text, '<')">
916 <value-of select="substring-before($text, '<')"/>
917 <value-of select="'&'"/>
918 <value-of select="'lt;'"/>
919 <value-of select="substring-after($text, '<')"/>
922 <value-of select="$text"/>
928 == Wiki styles: bold, italics, ... ==
931 <template name="mk-style-set">
936 select="$node/ancestor-or-self::*[@text:style-name][1]"
940 <when test="boolean($context)">
943 select="key('style-ref', $context/@text:style-name)"
946 <!-- Debugging: Print inspected styles. -->
949 <value-of select="'=== '"/>
950 <value-of select="$style/@style:name"/>
951 <value-of select="' ==='"/>
955 <call-template name="mk-style-set-internal">
956 <with-param name="node" select="$context"/>
957 <with-param name="style" select="$style"/>
958 <with-param name="style-set" select="$NO_STYLE"/>
959 <with-param name="style-mask" select="$NO_STYLE"/>
963 <value-of select="$NO_STYLE"/>
969 Compute the wiki style set that corresponds
970 to the given office style at the given context node.
973 A node in which context the style is computed. If neither the given style
974 nor one of its linked styles does specify a style of the given type,
975 ancestor nodes of the given context node are considered.
977 A style:style element node. The style of the requested type is searched
978 in the given style and its linked styles.
980 A bit set of styles already defined by the context.
982 A bit set of styles that must not be taken from the currently inspected
983 style, because those styles are already defined by the context.
985 @return A bit set composed of the wiki style constants.
987 <template name="mk-style-set-internal">
989 <param name="style"/>
990 <param name="style-set"/>
991 <param name="style-mask"/>
993 <variable name="text-properties" select="$style/style:text-properties"/>
995 <!-- Decompose style-mask into individual bits. -->
996 <variable name="bold-requested"
997 select="($style-mask mod (2 * $BOLD_BIT)) = 0"/>
998 <variable name="italic-requested"
999 select="($style-mask mod (2 * $ITALIC_BIT)) - ($style-mask mod ($ITALIC_BIT)) = 0"/>
1000 <variable name="superscript-requested"
1001 select="($style-mask mod (2 * $SUPERSCRIPT_BIT)) - ($style-mask mod ($SUPERSCRIPT_BIT)) = 0"/>
1002 <variable name="subscript-requested"
1003 select="($style-mask mod (2 * $SUBSCRIPT_BIT)) - ($style-mask mod ($SUBSCRIPT_BIT)) = 0"/>
1004 <variable name="typewriter-requested"
1005 select="($style-mask mod (2 * $TYPEWRITER_BIT)) - ($style-mask mod ($TYPEWRITER_BIT)) = 0"/>
1006 <variable name="code-requested"
1007 select="($style-mask mod (2 * $CODE_BIT)) - ($style-mask mod ($CODE_BIT)) = 0"/>
1008 <variable name="center-requested"
1009 select="($style-mask mod (2 * $CENTER_BIT)) - ($style-mask mod ($CENTER_BIT)) = 0"/>
1010 <variable name="right-requested"
1011 select="($style-mask mod (2 * $RIGHT_BIT)) - ($style-mask mod ($RIGHT_BIT)) = 0"/>
1013 <!-- Extract styles that are not already defined by the context. -->
1014 <variable name="bold-style">
1016 <when test="$bold-requested and boolean($text-properties/@fo:font-weight='bold')">
1017 <!-- Bold found in current style. -->
1018 <value-of select="$BOLD_BIT"/>
1021 <value-of select="$NO_STYLE"/>
1025 <variable name="bold-mask">
1027 <when test="$bold-requested and boolean($text-properties/@fo:font-weight)">
1029 Other value than "bold" means that the character style is not
1030 bold and no parent style must be considered.
1032 <value-of select="$BOLD_BIT"/>
1035 <value-of select="$NO_STYLE"/>
1040 <variable name="italic-style">
1042 <when test="$italic-requested and boolean($text-properties/@fo:font-style='italic')">
1043 <!-- Italic found in current style. -->
1044 <value-of select="$ITALIC_BIT"/>
1047 <value-of select="$NO_STYLE"/>
1051 <variable name="italic-mask">
1053 <when test="$italic-requested and boolean($text-properties/@fo:font-style)">
1055 Other value than "italic" means that the character style is not
1056 italic and no parent style must be considered.
1058 <value-of select="$ITALIC_BIT"/>
1061 <value-of select="$NO_STYLE"/>
1066 <variable name="superscript-style">
1068 <when test="$superscript-requested and contains($text-properties/@style:text-position, 'super')">
1069 <value-of select="$SUPERSCRIPT_BIT"/>
1072 <value-of select="$NO_STYLE"/>
1076 <variable name="superscript-mask">
1078 <when test="$superscript-requested and boolean($text-properties/@style:text-position)">
1079 <value-of select="$SUPERSCRIPT_BIT"/>
1082 <value-of select="$NO_STYLE"/>
1087 <variable name="subscript-style">
1089 <when test="$subscript-requested and contains($text-properties/@style:text-position, 'sub')">
1090 <value-of select="$SUBSCRIPT_BIT"/>
1093 <value-of select="$NO_STYLE"/>
1097 <variable name="subscript-mask">
1099 <when test="$subscript-requested and boolean($text-properties/@style:text-position)">
1100 <value-of select="$SUBSCRIPT_BIT"/>
1103 <value-of select="$NO_STYLE"/>
1108 <variable name="typewriter-style">
1110 <when test="$typewriter-requested and ($style/@style:family='text') and boolean($text-properties/@style:font-name)">
1111 <variable name="font-face"
1112 select="key('font-face-ref', $text-properties/@style:font-name)"/>
1114 <when test="$font-face/@style:font-pitch='fixed'">
1115 <value-of select="$TYPEWRITER_BIT"/>
1118 <value-of select="$NO_STYLE"/>
1123 <value-of select="$NO_STYLE"/>
1127 <variable name="typewriter-mask">
1129 <!-- Note: Suppress the typewriter style on text within a code paragraph. -->
1130 <when test="$typewriter-requested and boolean($text-properties/@style:font-name)">
1131 <value-of select="$TYPEWRITER_BIT"/>
1134 <value-of select="$NO_STYLE"/>
1139 <variable name="code-style">
1141 <when test="$code-requested and ($style/@style:family='paragraph') and boolean($text-properties/@style:font-name)">
1142 <variable name="font-face"
1143 select="key('font-face-ref', $text-properties/@style:font-name)"/>
1145 <when test="$font-face/@style:font-pitch='fixed'">
1146 <value-of select="$CODE_BIT"/>
1149 <value-of select="$NO_STYLE"/>
1154 <value-of select="$NO_STYLE"/>
1158 <variable name="code-mask">
1160 <when test="$code-requested and ($style/@style:family='paragraph') and boolean($text-properties/@style:font-name)">
1161 <value-of select="$CODE_BIT"/>
1164 <value-of select="$NO_STYLE"/>
1169 <variable name="center-style">
1171 <when test="$center-requested and ($style/@style:family='paragraph') and boolean($style/style:paragraph-properties/@fo:text-align='center')">
1172 <value-of select="$CENTER_BIT"/>
1175 <value-of select="$NO_STYLE"/>
1179 <variable name="center-mask">
1181 <when test="$center-requested and ($style/@style:family='paragraph') and boolean($style/style:paragraph-properties/@fo:text-align)">
1182 <value-of select="$CENTER_BIT"/>
1185 <value-of select="$NO_STYLE"/>
1190 <variable name="right-style">
1192 <when test="$right-requested and ($style/@style:family='paragraph') and boolean($style/style:paragraph-properties/@fo:text-align='end')">
1193 <value-of select="$RIGHT_BIT"/>
1196 <value-of select="$NO_STYLE"/>
1200 <variable name="right-mask">
1202 <when test="$center-requested and ($style/@style:family='paragraph') and boolean($style/style:paragraph-properties/@fo:text-align)">
1203 <value-of select="$RIGHT_BIT"/>
1206 <value-of select="$NO_STYLE"/>
1212 <!-- Compute the updated styles and mask. -->
1214 Note: The bit masks style-mask, bold-style, italic-style,... are
1215 guaranteed to be disjoint, therefore, addition can be use instead
1216 of bitwise or (which is missing in XPath). -->
1217 <variable name="updated-style"
1218 select="$style-set + $bold-style + $italic-style + $superscript-style + $subscript-style + $code-style + $typewriter-style + $center-style + $right-style"/>
1219 <variable name="updated-mask"
1220 select="$style-mask + $bold-mask + $italic-mask + $superscript-mask + $subscript-mask + $code-mask + $typewriter-mask + $center-mask + $right-mask"/>
1222 <!-- Inspect linked and nested styles. -->
1224 <when test="boolean($style/@style:parent-style-name)">
1225 <!-- Look through the style, the current style is based on. -->
1226 <call-template name="mk-style-set-internal">
1227 <with-param name="node" select="$node"/>
1228 <with-param name="style" select="key('style-ref', $style/@style:parent-style-name)"/>
1229 <with-param name="style-set" select="$updated-style"/>
1230 <with-param name="style-mask" select="$updated-mask"/>
1234 <variable name="ancestors" select="$node/ancestor::*[@text:style-name][1]"/>
1236 <!-- Debugging: Print currently inspected style. -->
1239 <value-of select="'{'"/>
1240 <value-of select="$style/@style:name"/>
1241 <value-of select="','"/>
1242 <value-of select="$updated-style"/>
1243 <value-of select="','"/>
1244 <value-of select="$updated-mask"/>
1245 <value-of select="','"/>
1246 <value-of select="local-name($ancestors)"/>
1247 <value-of select="',('"/>
1248 <value-of select="$node"/>
1249 <value-of select="')'"/>
1250 <value-of select="'}'"/>
1255 If there is an ancestor that has a style, use that style,
1256 otherwise, a style is not found. -->
1258 <when test="boolean($ancestors)">
1259 <!-- Look through the style of the nearest ancestor that has a style. -->
1260 <call-template name="mk-style-set-internal">
1261 <with-param name="node" select="$ancestors"/>
1262 <with-param name="style" select="key('style-ref', $ancestors/@text:style-name)"/>
1263 <with-param name="style-set" select="$updated-style"/>
1264 <with-param name="style-mask" select="$updated-mask"/>
1268 <!-- No more styles to inspect. Return the result. -->
1269 <value-of select="$updated-style"/>
1278 == Descending the tree ==
1281 <template match="/">
1283 <value-of select="$NL"/>
1284 <if test="boolean(//text:note[@text:note-class='footnote'])">
1285 <value-of select="$NL"/>
1287 <value-of select="$NL"/>
1288 <text><references/></text>
1289 <value-of select="$NL"/>
1293 <template match="office:document-content">
1297 <template match="office:body">
1301 <template match="office:* | text:* | draw:frame | draw:text-box | draw:frame | draw:a">
1305 <template match="node()">