From: <var...@us...> - 2009-05-20 15:21:26
|
Revision: 6812 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6812&view=rev Author: vargenau Date: 2009-05-20 15:21:13 +0000 (Wed, 20 May 2009) Log Message: ----------- New converter: use Wikicreole syntax Modified Paths: -------------- trunk/admin/odt2phpwiki.xsl Modified: trunk/admin/odt2phpwiki.xsl =================================================================== --- trunk/admin/odt2phpwiki.xsl 2009-05-20 08:50:21 UTC (rev 6811) +++ trunk/admin/odt2phpwiki.xsl 2009-05-20 15:21:13 UTC (rev 6812) @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - odt2phpwiki: OpenDocument to Phpwiki transformation - + odt2phpwiki: OpenDocument to Phpwiki transformation Copyright (C) 2007 Bernhard Haumacher (haui at haumacher dot de) - Copyright (C) 2008 Marc-Etienne Vargenau, Alcatel-Lucent + Copyright (C) 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,23 +17,23 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. This program is based on the OpenDocument to Mediawiki converter by Bernhard Haumacher. Modifications to convert to Phpwiki were made by Marc-Etienne Vargenau - and are Copyright (C) 2008 Alcatel-Lucent + and are Copyright (C) 2008-2009 Alcatel-Lucent Standard Alcatel-Lucent disclaimer for contributing to open source - + "The OpenDocument to Phpwiki converter ("Contribution") has not been tested and/or validated for release as or in products, combinations with products or other commercial use. Any use of the Contribution is entirely made at the user's own responsibility and the user can not rely on any features, functionalities or performances Alcatel-Lucent has attributed to the Contribution. - + THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE, @@ -48,1407 +47,1268 @@ --> <stylesheet version="1.0" - xmlns="http://www.w3.org/1999/XSL/Transform" + xmlns="http://www.w3.org/1999/XSL/Transform" - xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" - xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" - xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" - xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" - xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" - xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" - xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" - xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" - xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" - xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" - xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" - xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" - xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:math="http://www.w3.org/1998/Math/MathML" - xmlns:dom="http://www.w3.org/2001/xml-events" - xmlns:xforms="http://www.w3.org/2002/xforms" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" + xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" + xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" + xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" + xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" + xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" + xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" + xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" + xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" + xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" + xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" + xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" + xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:math="http://www.w3.org/1998/Math/MathML" + xmlns:dom="http://www.w3.org/2001/xml-events" + xmlns:xforms="http://www.w3.org/2002/xforms" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > - - <!-- - == Customization options == - --> + <output + method="text" + media-type="text/plain" + encoding="UTF-8" + /> - <!-- Constant defining the newline token. --> - <param name="NL" select="' '"/> + <!-- + == Reference resolution == + --> - <!-- String that a tabulator is expanded with in preformatted paragraphs. --> - <param name="CODE_TAB_REPLACEMENT"> - <variable name="document-value" - select="/office:document/office:meta/meta:user-defined[@meta:name='CODE_TAB_REPLACEMENT']"/> - <choose> - <when test="boolean($document-value)"> - <value-of select="$document-value"/> - </when> - - <otherwise> - <value-of select="' '"/> - </otherwise> - </choose> - </param> - - <!-- - Switch that suppresses separation of paragraphs with empty lines. - (Set to 1 to activate) --> - <param name="CODE_JOIN_PARAGRAPHS" - select="boolean(string(/office:document/office:meta/meta:user-defined[@meta:name='CODE_JOIN_PARAGRAPHS']) != 'false')"/> - - <param name="CODE_STYLES"> - <variable name="document-value" - select="/office:document/office:meta/meta:user-defined[@meta:name='CODE_STYLES']"/> - <choose> - <when test="boolean($document-value)"> - <value-of select="$document-value"/> - </when> - - <otherwise> - <value-of select="''"/> - </otherwise> - </choose> - </param> + <key + name="style-ref" + match="//style:style" + use="@style:name" + /> - <!-- - == Wiki style constants == - --> - - <!-- Bold character style. --> - <variable name="BOLD_BIT" select="1"/> + <key + name="list-style-ref" + match="//text:list-style" + use="@style:name" + /> + + <key + name="font-face-ref" + match="//style:font-face" + use="@style:name" + /> + + <key + name="reference-resolution" + match="//text:reference-mark | //text:reference-mark-start" + use="@text:name" + /> + - <!-- Italic character style. --> - <variable name="ITALIC_BIT" select="2"/> + <!-- Wiki style constants. --> + + <!-- Bold character style. --> + <variable name="BOLD_BIT" select="1"/> - <!-- Subscript character style. --> - <variable name="SUBSCRIPT_BIT" select="4"/> + <!-- Italic character style. --> + <variable name="ITALIC_BIT" select="2"/> - <!-- Superscript character style. --> - <variable name="SUPERSCRIPT_BIT" select="8"/> + <!-- Subscript character style. --> + <variable name="SUBSCRIPT_BIT" select="4"/> - <!-- Typewriter character style. --> - <variable name="TYPEWRITER_BIT" select="16"/> - - <!-- Preformatted text paragraph style. --> - <variable name="CODE_BIT" select="32"/> + <!-- Superscript character style. --> + <variable name="SUPERSCRIPT_BIT" select="8"/> - <!-- Centered paragraph style. --> - <variable name="CENTER_BIT" select="64"/> + <!-- Typewriter character style. --> + <variable name="TYPEWRITER_BIT" select="16"/> + + <!-- Preformatted text paragraph style. --> + <variable name="CODE_BIT" select="32"/> - <!-- Right aligned paragraph style. --> - <variable name="RIGHT_BIT" select="128"/> - - <!-- Constant defining the empty style. --> - <variable name="NO_STYLE" select="0"/> + <!-- Centered paragraph style. --> + <variable name="CENTER_BIT" select="64"/> + <!-- Right aligned paragraph style. --> + <variable name="RIGHT_BIT" select="128"/> + + <!-- Constant defining the empty style. --> + <variable name="NO_STYLE" select="0"/> + <!-- Constant defining the newline token. --> + <variable name="NL" select="' '"/> - <output - method="text" - media-type="text/plain" - encoding="UTF-8" - /> + <!-- + Multiple pages (draw only) + --> + <template match="draw:page"> + <value-of select="concat(' <!-- Page ', @draw:name, '--> ')"/> + <apply-templates/> + <value-of select="' ---- '"/> + </template> - <!-- - == Reference resolution == - --> - <key - name="style-ref" - match="//style:style" - use="@style:name" - /> + <!-- + == Lists == + --> - <key - name="list-style-ref" - match="//text:list-style" - use="@style:name" - /> - - <key - name="font-face-ref" - match="//style:font-face" - use="@style:name" - /> - - <key - name="reference-resolution" - match="//text:reference-mark | //text:reference-mark-start" - use="@text:name" - /> + <template match="text:list-item"> + <if test="position() > 1 or boolean(ancestor::text:list-item)"> + <value-of select="$NL"/> + </if> + <variable name="list-style" + select="key('list-style-ref',ancestor::text:list[boolean(@text:style-name)][1]/@text:style-name)"/> + <call-template name="mk-list-token"> + <with-param name="list-style" select="$list-style"/> + <with-param name="level" select="count(ancestor::text:list)"/> + </call-template> + <text> </text> + <apply-templates/> + <if test="position() = last() and not(boolean(ancestor::text:list-item))"> + <value-of select="$NL"/> + <value-of select="$NL"/> + </if> + </template> + + <template name="mk-list-token"> + <param name="list-style"/> + <param name="level"/> + + <if test="$level > 1"> + <call-template name="mk-list-token"> + <with-param name="list-style" select="$list-style"/> + <with-param name="level" select="$level - 1"/> + </call-template> + </if> + <variable name="number-style" select="$list-style/text:list-level-style-number[@text:level=$level]"/> + <variable name="bullet-style" select="$list-style/text:list-level-style-bullet[@text:level=$level]"/> + <choose> + <when test="boolean($number-style)"> + <choose> + <when test="string-length($number-style/@style:num-format) > 0"> + <text>#</text> + </when> + <otherwise> + <text>:</text> + </otherwise> + </choose> + </when> + <when test="boolean($bullet-style)"> + <text>*</text> + </when> + </choose> + </template> - <!-- - Multiple pages (draw only) - --> - <template match="draw:page"> - <value-of select="concat(' <!-- Page ', @draw:name, '--> ')"/> - <apply-templates/> - <value-of select="' ---- '"/> - </template> + <!-- + == Headings == + --> + <template match="text:h"> + <if test="string-length(.) > 0"> + <variable name="token"> + <call-template name="mk-heading-prefix"> + <with-param name="level" select="1 + @text:outline-level"/> + </call-template> + </variable> + <value-of select="$token"/> + <text> </text> + <apply-templates/> + <text> </text> + <value-of select="$token"/> + <text> </text> + </if> + </template> - <!-- - == Lists == - --> + <!-- + Function generating a wiki heading prefix. + + @param level + The heading level. The value must be between 1 and 5. + --> + <template name="mk-heading-prefix"> + <param name="level"/> + <choose> + <when test="$level > 6"> + <call-template name="mk-heading-prefix"> + <with-param name="level" select="6"/> + </call-template> + </when> + <when test="$level > 0"> + <text>=</text> + <call-template name="mk-heading-prefix"> + <with-param name="level" select="$level - 1"/> + </call-template> + </when> + </choose> + </template> - <template match="text:list"> - <!-- - Check, whether this list is used to implement the outline numbering - for headings. Such list must not be exported, because within the wiki, - automatic outline numbering is performed. An outline list has a single - text:h element as its single leaf grandchild. - - This method of section numbering seems not to be used when creating new - documents with OpenOffice.org 2.2, but the document containing the - OpenDocument specification version 1.1 uses such numbering through nested - lists. - --> - <choose> - <when test="boolean(./descendant::node()[not(./self::text:list) and not(./self::text:list-item) and not(./ancestor-or-self::text:h)])"> - <apply-templates/> - </when> - - <otherwise> - <apply-templates select=".//text:h"/> - </otherwise> - </choose> - </template> - - <template match="text:list-item"> - <if test="position() > 1 or boolean(ancestor::text:list-item)"> - <value-of select="$NL"/> - </if> - <variable name="list-style" - select="key('list-style-ref',ancestor::text:list[boolean(@text:style-name)][1]/@text:style-name)"/> - <call-template name="mk-list-token"> - <with-param name="list-style" select="$list-style"/> - <with-param name="level" select="count(ancestor::text:list)"/> - </call-template> - <text> </text> - <apply-templates/> - <if test="position() = last() and not(boolean(ancestor::text:list-item))"> - <!-- End of (potentially nested) list is marked with a double newline. --> - <value-of select="$NL"/> - <value-of select="$NL"/> - </if> - </template> - - <template name="mk-list-token"> - <param name="list-style"/> - <param name="level"/> - - <if test="$level > 1"> - <call-template name="mk-list-token"> - <with-param name="list-style" select="$list-style"/> - <with-param name="level" select="$level - 1"/> - </call-template> - </if> + <!-- + Function generating a token consisting of the given character + repeated 'level' times. + + @param level + The lengh of the result. + @param char + The character that should be repeated 'level' times. + --> + <template name="mk-token"> + <param name="level"/> + <param name="char"/> + <if test="$level > 0"> + <value-of select="$char"/> + <call-template name="mk-token"> + <with-param name="level" select="$level - 1"/> + <with-param name="char" select="$char"/> + </call-template> + </if> + </template> + + + <!-- + == Tables == + --> - <variable name="number-style" select="$list-style/text:list-level-style-number[@text:level=$level]"/> - <variable name="bullet-style" select="$list-style/text:list-level-style-bullet[@text:level=$level]"/> - <choose> - <when test="boolean($number-style)"> - <choose> - <when test="string-length($number-style/@style:num-format) > 0"> - <text>#</text> - </when> - <otherwise> - <text>:</text> - </otherwise> - </choose> - </when> - <when test="boolean($bullet-style)"> - <text>*</text> - </when> - </choose> - </template> + <template match="table:table"> + <text> </text> + <text>{| class="bordered"</text> + <text> </text> + <text>|-</text> + <text> </text> + <apply-templates/> + <text> </text> + <text>|}</text> + <text> </text> + </template> + <template match="table:table-header-rows"> + <apply-templates/> + </template> - <!-- - == Headings == - --> + <template match="table:table-row[position() < last()] | table:table-header-rows/table:table-row"> + <apply-templates/> + <text> </text> + <text>|-</text> + <text> </text> + </template> - <template match="text:h"> - <if test="string-length(.) > 0"> - <variable name="token"> - <call-template name="mk-heading-prefix"> - <with-param name="level" select="@text:outline-level"/> - </call-template> - </variable> - <value-of select="$token"/> - <text> </text> - <apply-templates/> - <value-of select="$NL"/> - </if> - </template> + <template match="table:table-row"> + <apply-templates/> + </template> - <template match="text:index-title"> - <text>== </text> - <apply-templates/> - <text> ==</text> - <value-of select="$NL"/> - </template> + <template match="table:table-header-rows//table:table-cell"> + <text>! </text> + <if test="@table:number-columns-spanned"> + <text>colspan="</text> + <value-of select="@table:number-columns-spanned"/> + <text>" | </text> + </if> + <apply-templates/> + <value-of select="$NL"/> + </template> - <!-- - Function generating a wiki heading prefix. - - @param level - The heading level. The value must be between 1 and 3. - --> - <template name="mk-heading-prefix"> - <param name="level"/> - <choose> - <when test="$level > 3"> - <call-template name="mk-heading-prefix"> - <with-param name="level" select="3 - $level"/> - </call-template> - </when> - <when test="$level > 0"> - <text>!</text> - <call-template name="mk-heading-prefix"> - <with-param name="level" select="$level + 1"/> - </call-template> - </when> - </choose> - </template> + <template match="table:table-cell"> + <text>| </text> + <if test="@table:number-columns-spanned"> + <text>colspan="</text> + <value-of select="@table:number-columns-spanned"/> + <text>" | </text> + </if> + <apply-templates/> + <value-of select="$NL"/> + </template> - <!-- - Function generating a token consisting of the given character - repeated 'level' times. - - @param level - The lengh of the result. - @param char - The character that should be repeated 'level' times. - --> - <template name="mk-token"> - <param name="level"/> - <param name="char"/> - <if test="$level > 0"> - <value-of select="$char"/> - <call-template name="mk-token"> - <with-param name="level" select="$level - 1"/> - <with-param name="char" select="$char"/> - </call-template> - </if> - </template> - - - <!-- - == Tables == - --> - <template match="table:table"> - <text> </text> - <text><?plugin MediawikiTable</text> - <text> </text> - <text>{| class="bordered"</text> - <text> </text> - <text>|-</text> - <text> </text> - <apply-templates/> - <text>|}</text> - <text> </text> - <text>?></text> - <text> </text> - </template> + <!-- + == WikiMath == + --> - <template match="table:table-header-rows"> - <apply-templates/> - </template> + <template match="text:span[@text:style-name='WikiMath']"> + <value-of select="'<math>'"/> + <apply-templates/> + <value-of select="'</math>'"/> + </template> - <template match="table:table-row[position() < last()] | table:table-header-rows/table:table-row"> - <apply-templates/> - <text> </text> - <text>|-</text> - <text> </text> - </template> - <template match="table:table-row"> - <apply-templates/> - </template> + <!-- + == Native links == + --> - <template match="table:table-header-rows//table:table-cell"> - <text>! </text> - <if test="@table:number-columns-spanned"> - <text>colspan="</text> - <value-of select="@table:number-columns-spanned"/> - <text>" | </text> - </if> - <apply-templates/> - <value-of select="$NL"/> - </template> + <template match="text:a"> + <variable name="link-ref" select="@xlink:href"/> + <choose> + <when test="string-length($link-ref) > 0"> + <variable name="link-label" select="string(.)"/> + <text>[</text> + <value-of select="$link-ref"/> + <text> </text> + <value-of select="$link-label"/> + <text>]</text> + </when> + + <otherwise> + <apply-templates/> + </otherwise> + </choose> + </template> - <template match="table:table-cell"> - <text>| </text> - <if test="@table:number-columns-spanned"> - <text>colspan="</text> - <value-of select="@table:number-columns-spanned"/> - <text>" | </text> - </if> - <apply-templates/> - <value-of select="$NL"/> - </template> + <!-- + == WikiLink == + --> - <!-- - == WikiMath == - --> + <template match="text:span[@text:style-name='WikiLink']"> + <value-of select="'[['"/> + <variable name="link-def" select="string(.)"/> + <variable name="link-label" select="normalize-space(substring-before($link-def, '['))"/> + <variable name="link-ref" select="normalize-space(substring-before(substring-after($link-def, '['), ']'))"/> + <choose> + <when test="boolean($link-ref)"> + <value-of select="concat($link-ref, '|', $link-label)"/> + </when> + <otherwise> + <value-of select="$link-def"/> + </otherwise> + </choose> + <value-of select="']]'"/> + </template> + + + <!-- + == Paragraphs == + --> - <template match="text:span[@text:style-name='WikiMath']"> - <value-of select="'<math>'"/> - <apply-templates/> - <value-of select="'</math>'"/> - </template> + <template match="text:p[string-length(.) > 0]"> + <variable name="style"> + <call-template name="mk-style-set"> + <with-param name="node" select="."/> + </call-template> + </variable> + <variable name="code" + select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> + <variable name="center" + select="($style mod (2 * $CENTER_BIT)) - ($style mod ($CENTER_BIT)) != 0"/> + <variable name="right" + select="($style mod (2 * $RIGHT_BIT)) - ($style mod ($RIGHT_BIT)) != 0"/> + + <choose> + <when test="$center"> + <text><div align="center"></text> + </when> + <when test="$right"> + <text><div align="right"></text> + </when> + <when test="$code"> + <value-of select="' '"/> + </when> + </choose> + + <apply-templates/> - <!-- - == Native links == - --> + <choose> + <when test="$center"> + <text></div></text> + </when> + <when test="$right"> + <text></div></text> + </when> + </choose> - <template match="text:a"> - <variable name="link-ref" select="@xlink:href"/> - <choose> - <when test="string-length($link-ref) > 0"> - <variable name="link-label" select="string(.)"/> - <text>[</text> - <value-of select="$link-ref"/> - <text> </text> - <value-of select="$link-label"/> - <text>]</text> - </when> - - <otherwise> - <apply-templates/> - </otherwise> - </choose> - </template> + <variable name="paragraph-right" + select="./following-sibling::text:p[1]"/> + <if test="boolean($paragraph-right)"> + <!-- + Insert end of line only if not within a list. Within wiki lists, + a line break leaves the current list item. + --> + <choose> + <when test="boolean(ancestor::text:list-item)"> + <text><br/> </text> + </when> + <when test="$code"> + <variable name="style-right"> + <call-template name="mk-style-set"> + <with-param name="node" select="$paragraph-right"/> + </call-template> + </variable> + + <variable name="code-right" + select="($style-right mod (2 * $CODE_BIT)) - ($style-right mod ($CODE_BIT)) != 0"/> + + <value-of select="$NL"/> + <if test="$code-right"> + <value-of select="' '"/> + </if> + <value-of select="$NL"/> + </when> + <otherwise> + <value-of select="$NL"/> + <value-of select="$NL"/> + </otherwise> + </choose> + </if> + </template> - <!-- - == WikiLink == - --> + <template match="text:p[string-length(.) = 0 and string-length(preceding-sibling::text:p[1]) > 0]"> + <value-of select="$NL"/> + </template> - <template match="text:span[@text:style-name='WikiLink']"> - <value-of select="'['"/> - <variable name="link-def" select="string(.)"/> - <variable name="link-label" select="normalize-space(substring-before($link-def, '['))"/> - <variable name="link-ref" select="normalize-space(substring-before(substring-after($link-def, '['), ']'))"/> - <choose> - <when test="boolean($link-ref)"> - <value-of select="concat($link-label, '|', $link-ref)"/> - </when> - <otherwise> - <value-of select="$link-def"/> - </otherwise> - </choose> - <value-of select="']'"/> - </template> - - - <!-- - == Paragraphs == - --> - <template match="text:p[string-length(.) > 0]"> - <variable name="style"> - <call-template name="mk-style-set"> - <with-param name="node" select="."/> - </call-template> - </variable> + <!-- + == Preformatted text == + --> + + <template match="text:s"> + <variable name="style"> + <call-template name="mk-style-set"> + <with-param name="node" select="."/> + </call-template> + </variable> - <variable name="code" - select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> - <variable name="center" - select="($style mod (2 * $CENTER_BIT)) - ($style mod ($CENTER_BIT)) != 0"/> - <variable name="right" - select="($style mod (2 * $RIGHT_BIT)) - ($style mod ($RIGHT_BIT)) != 0"/> - - <choose> - <when test="$center"> - </when> - <when test="$right"> - </when> - <when test="$code"> - <value-of select="' '"/> - </when> - </choose> - - <apply-templates/> + <variable name="code" + select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> + + <if test="$code"> + <choose> + <when test="@text:c"> + <call-template name="mk-token"> + <with-param name="level" select="@text:c"/> + <with-param name="char" select="' '"/> + </call-template> + </when> + <otherwise> + <value-of select="' '"/> + </otherwise> + </choose> + </if> + </template> + + <template match="text:line-break"> + <variable name="style"> + <call-template name="mk-style-set"> + <with-param name="node" select="."/> + </call-template> + </variable> - <choose> - <when test="$center"> - </when> - <when test="$right"> - </when> - </choose> + <variable name="code" + select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> + + <if test="$code"> + <value-of select="$NL"/> + <value-of select="' '"/> + </if> + </template> - <variable name="paragraph-right" - select="./following-sibling::*[1]/self::text:p"/> + <!-- + Footnotes + --> + + <template match="text:note-body"> + <variable name="note" select="./parent::text:note"/> + + <if test="$note/@text:note-class = 'footnote'"> + <text><ref name="</text> + <value-of select="$note/@text:id"/> + <text>"></text> + <apply-templates/> + <text></ref></text> + </if> + </template> + + <template match="text:note-ref[@text:note-class='footnote']"> + <text><ref name="</text> + <value-of select="@text:ref-name"/> + <text>"/></text> + </template> + + + <!-- + == Images == + --> + + <template match="draw:text-box[boolean(.//draw:image)]"> + <variable name="image" select=".//draw:image[1]"/> + + <variable name="image-description"> + <apply-templates/> + </variable> + + <text>[[</text> + <call-template name="mk-image-name"> + <with-param name="image" select="$image"/> + </call-template> + <text>|thumb|</text> + <value-of select="normalize-space($image-description)"/> + <text>]]</text> + </template> + + <template match="draw:image[not(boolean(ancestor::draw:text-box))]"> + <text>[[</text> + <call-template name="mk-image-name"> + <with-param name="image" select="."/> + </call-template> + <text>]]</text> + </template> - <choose> - <when test="boolean($paragraph-right)"> - <!-- - Insert end of line only if not within a list. Within wiki lists, - a line break leaves the current list item. - --> - <choose> - <when test="boolean(ancestor::text:list-item)"> - <text><br/> </text> - </when> - <when test="$code"> - <variable name="style-right"> - <call-template name="mk-style-set"> - <with-param name="node" select="$paragraph-right"/> - </call-template> - </variable> - - <variable name="code-right" - select="($style-right mod (2 * $CODE_BIT)) - ($style-right mod ($CODE_BIT)) != 0"/> - - <choose> - <when test="$code-right"> - <choose> - <when test="$CODE_JOIN_PARAGRAPHS"> - <value-of select="$NL"/> - </when> - - <otherwise> - <value-of select="$NL"/> - <value-of select="' '"/> - <value-of select="$NL"/> - </otherwise> - </choose> - </when> - <otherwise> - <value-of select="$NL"/> - <value-of select="$NL"/> - </otherwise> - </choose> - </when> - <otherwise> - <value-of select="$NL"/> - <value-of select="$NL"/> - </otherwise> - </choose> - </when> - <when test="boolean(./following-sibling::*[1]/self::text:h) or boolean(./following-sibling::*[1]/self::table:table) or boolean(./following-sibling::*[1]/self::text:bibliography)"> - <!-- Newline before following heading or table. --> - <value-of select="$NL"/> - <value-of select="$NL"/> - </when> - <when test="./following-sibling::*[1]/self::text:list and not(ancestor::text:list-item)"> - <value-of select="$NL"/> - <value-of select="$NL"/> - </when> - </choose> - </template> + <template name="mk-image-name"> + <param name="image"/> + + <variable name="base-name"> + <call-template name="mk-base-name"> + <with-param name="href" select="$image/@xlink:href"/> + </call-template> + </variable> + + <if test="not(starts-with($base-name, 'Image:'))"> + <value-of select="'Image:'"/> + </if> + <value-of select="$base-name"/> + </template> + + <template name="mk-base-name"> + <param name="href"/> + + <variable name="result" select="substring-after($href, '/')"/> + <choose> + <when test="boolean($result)"> + <call-template name="mk-base-name"> + <with-param name="href" select="$result"/> + </call-template> + </when> + <otherwise> + <value-of select="$href"/> + </otherwise> + </choose> + </template> + + + <!-- + References + --> + + <!-- TODO: text:bibliography-mark --> - <template match="text:p[string-length(.) = 0 and string-length(preceding-sibling::*[1]/self::text:p) > 0]"> - <value-of select="$NL"/> - </template> + <template match="text:reference-ref"> + <variable name="reference-mark" select="key('reference-resolution', @text:ref-name)"/> + + <choose> + <when test="boolean($reference-mark)"> + <!-- + In wiki syntax, only a local reference to a heading can be inserted. + If the link target is a descendant of a heading element, a link can be + inserted in the result. --> + <variable name="header-anchor" select="$reference-mark/ancestor::text:h[1]"/> + <if test="boolean($header-anchor)"> + <text>[[#</text> + <value-of select="string($header-anchor)"/> + <text>|</text> + </if> + + <variable name="reference-text" select="string(.)"/> + + <choose> + <!-- Check, whether the reference text is cached in the document. --> + <when test="string-length($reference-text) > 0"> + <value-of select="$reference-text"/> + </when> + + <otherwise> + <!-- + TODO: Evaluate the @text:reference-format attribute and + generate the replacement text (difficult).--> + <text>(REFERENCE TEXT UNAVAILABLE: "</text> + <value-of select="@text:ref-name"/> + <text>")</text> + </otherwise> + </choose> + + <if test="boolean($header-anchor)"> + <text>]]</text> + </if> + </when> + <otherwise> + <text>(UNDEFINED REFERENCE: "</text> + <value-of select="@text:ref-name"/> + <text>")</text> + </otherwise> + </choose> + </template> + + <template match="text:reference-mark"> + <!-- TODO: Output an anchor. --> + <apply-templates/> + </template> - <!-- - == Preformatted text == - --> - - <template match="text:s"> - <variable name="style"> - <call-template name="mk-style-set"> - <with-param name="node" select="."/> - </call-template> - </variable> + <template match="text:reference-mark-start"> + <!-- TODO: Output an anchor. --> + </template> - <variable name="code" - select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> - - <if test="$code"> - <choose> - <when test="@text:c"> - <call-template name="mk-token"> - <with-param name="level" select="@text:c"/> - <with-param name="char" select="' '"/> - </call-template> - </when> - <otherwise> - <value-of select="' '"/> - </otherwise> - </choose> - </if> - </template> - - <template match="text:tab"> - <variable name="style"> - <call-template name="mk-style-set"> - <with-param name="node" select="."/> - </call-template> - </variable> + <!-- + == Plain text == + --> + + <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()"> + <choose> + <when test="boolean(./ancestor::table:table-header-rows | ./ancestor::text:h)"> + <!-- + No explicit styles within table headings or section headings, + because those styles are consistently declared by the Wiki engine. --> + <value-of select="."/> + </when> + + <when test="string-length(.) > 0"> + <variable name="style"> + <call-template name="mk-style-set"> + <with-param name="node" select="."/> + </call-template> + </variable> + + <variable name="current-paragraph" + select="./ancestor::text:p[1]"/> + <variable name="paragraph-id" + select="generate-id($current-paragraph)"/> + <variable name="frames" + select="$current-paragraph/descendant::draw:frame"/> + <variable name="frame-count" + select="count($frames)"/> + + <!-- + The current style context consists of all text nodes that are + descendants of the paragraph ancestor of this text node but not + descendants of any frame nodes that are descendants of the current + text nodes paragraph. + --> + <variable name="context" + select="$current-paragraph//text()[not(boolean(./ancestor::draw:frame[1]) and count(./ancestor::draw:frame[1] | $frames) = $frame-count)]"/> + <variable name="context-size" select="count($context)"/> - <variable name="code" - select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> - - <if test="$code"> - <value-of select="$CODE_TAB_REPLACEMENT"/> - </if> - </template> - - <template match="text:line-break"> - <variable name="style"> - <call-template name="mk-style-set"> - <with-param name="node" select="."/> - </call-template> - </variable> + <variable name="context-index"> + <call-template name="mk-context-index"> + <with-param name="current-id" select="generate-id(.)"/> + <with-param name="context" select="$context"/> + <with-param name="test-index" select="1"/> + </call-template> + </variable> - <variable name="code" - select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> - - <if test="$code"> - <value-of select="$NL"/> - <value-of select="' '"/> - </if> - </template> + <variable name="style-left"> + <choose> + <when test="$context-index > 1"> + <variable name="left" select="$context[$context-index - 1]"/> + <!-- + The preceding text node is a child of this nodes topmost + styled ancestor. This means that the result of the + transformation will be directly concatenated. + --> + <call-template name="mk-style-set"> + <with-param name="node" select="$left"/> + </call-template> + </when> + <otherwise> + <value-of select="$NO_STYLE"/> + </otherwise> + </choose> + </variable> + <variable name="style-right"> + <choose> + <when test="$context-index < count($context)"> + <variable name="right" select="$context[$context-index + 1]"/> + <!-- + The preceding text node is a child of this nodes topmost + styled ancestor. This means that the result of the + transformation will be directly concatenated. + --> + <call-template name="mk-style-set"> + <with-param name="node" select="$right"/> + </call-template> + </when> + <otherwise> + <value-of select="$NO_STYLE"/> + </otherwise> + </choose> + </variable> - <!-- - Footnotes - --> - - <template match="text:note-body"> - <variable name="note" select="./parent::text:note"/> - - <if test="$note/@text:note-class = 'footnote'"> - <text><ref name="</text> - <value-of select="$note/@text:id"/> - <text>"></text> - <apply-templates/> - <text></ref></text> - </if> - </template> - - <template match="text:note-ref[@text:note-class='footnote']"> - <text><ref name="</text> - <value-of select="@text:ref-name"/> - <text>"/></text> - </template> - - - <!-- - == Images == - --> - - <template match="draw:text-box[boolean(.//draw:image)]"> - <variable name="image" select=".//draw:image[1]"/> - - <variable name="image-description"> - <apply-templates/> - </variable> - - <text>[[</text> - <call-template name="mk-image-name"> - <with-param name="image" select="$image"/> - </call-template> - <text>|thumb|</text> - <value-of select="normalize-space($image-description)"/> - <text>]]</text> - </template> - - <template match="draw:image[not(boolean(ancestor::draw:text-box))]"> - <text>[[</text> - <call-template name="mk-image-name"> - <with-param name="image" select="."/> - </call-template> - <text>]]</text> - </template> + <variable name="bold" + select="($style mod (2 * $BOLD_BIT)) != 0"/> + <variable name="italic" + select="($style mod (2 * $ITALIC_BIT)) - ($style mod ($ITALIC_BIT)) != 0"/> + <variable name="superscript" + select="($style mod (2 * $SUPERSCRIPT_BIT)) - ($style mod ($SUPERSCRIPT_BIT)) != 0"/> + <variable name="subscript" + select="($style mod (2 * $SUBSCRIPT_BIT)) - ($style mod ($SUBSCRIPT_BIT)) != 0"/> + <variable name="code" + select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> + <variable name="typewriter" + select="($style mod (2 * $TYPEWRITER_BIT)) - ($style mod ($TYPEWRITER_BIT)) != 0"/> - <template name="mk-image-name"> - <param name="image"/> - - <variable name="base-name"> - <call-template name="mk-base-name"> - <with-param name="href" select="$image/@xlink:href"/> - </call-template> - </variable> - - <if test="not(starts-with($base-name, 'Image:'))"> - <value-of select="'Image:'"/> - </if> - <value-of select="$base-name"/> - </template> - - <template name="mk-base-name"> - <param name="href"/> - - <variable name="result" select="substring-after($href, '/')"/> - <choose> - <when test="boolean($result)"> - <call-template name="mk-base-name"> - <with-param name="href" select="$result"/> - </call-template> - </when> - <otherwise> - <value-of select="$href"/> - </otherwise> - </choose> - </template> - - - <!-- - References - --> - - <!-- TODO: text:bibliography-mark --> + <variable name="bold-left" + select="($style-left mod (2 * $BOLD_BIT)) != 0"/> + <variable name="italic-left" + select="($style-left mod (2 * $ITALIC_BIT)) - ($style-left mod ($ITALIC_BIT)) != 0"/> + <variable name="superscript-left" + select="($style-left mod (2 * $SUPERSCRIPT_BIT)) - ($style-left mod ($SUPERSCRIPT_BIT)) != 0"/> + <variable name="subscript-left" + select="($style-left mod (2 * $SUBSCRIPT_BIT)) - ($style-left mod ($SUBSCRIPT_BIT)) != 0"/> + <variable name="typewriter-left" + select="($style-left mod (2 * $TYPEWRITER_BIT)) - ($style-left mod ($TYPEWRITER_BIT)) != 0"/> - <template match="text:reference-ref"> - <variable name="reference-mark" select="key('reference-resolution', @text:ref-name)"/> - - <choose> - <when test="boolean($reference-mark)"> - <!-- - In wiki syntax, only a local reference to a heading can be inserted. - If the link target is a descendant of a heading element, a link can be - inserted in the result. --> - <variable name="header-anchor" select="$reference-mark/ancestor::text:h[1]"/> - <if test="boolean($header-anchor)"> - <text>[[#</text> - <value-of select="string($header-anchor)"/> - <text>|</text> - </if> - - <variable name="reference-text" select="string(.)"/> - - <choose> - <!-- Check, whether the reference text is cached in the document. --> - <when test="string-length($reference-text) > 0"> - <value-of select="$reference-text"/> - </when> - - <otherwise> - <!-- - TODO: Evaluate the @text:reference-format attribute and - generate the replacement text (difficult).--> - <text>(REFERENCE TEXT UNAVAILABLE: "</text> - <value-of select="@text:ref-name"/> - <text>")</text> - </otherwise> - </choose> - - <if test="boolean($header-anchor)"> - <text>]]</text> - </if> - </when> + <variable name="bold-right" + select="($style-right mod (2 * $BOLD_BIT)) != 0"/> + <variable name="italic-right" + select="($style-right mod (2 * $ITALIC_BIT)) - ($style-right mod ($ITALIC_BIT)) != 0"/> + <variable name="superscript-right" + select="($style-right mod (2 * $SUPERSCRIPT_BIT)) - ($style-right mod ($SUPERSCRIPT_BIT)) != 0"/> + <variable name="subscript-right" + select="($style-right mod (2 * $SUBSCRIPT_BIT)) - ($style-right mod ($SUBSCRIPT_BIT)) != 0"/> + <variable name="typewriter-right" + select="($style-right mod (2 * $TYPEWRITER_BIT)) - ($style-right mod ($TYPEWRITER_BIT)) != 0"/> - <otherwise> - <text>(UNDEFINED REFERENCE: "</text> - <value-of select="@text:ref-name"/> - <text>")</text> - </otherwise> - </choose> - </template> - - <template match="text:reference-mark"> - <!-- TODO: Output an anchor. --> - <apply-templates/> - </template> + <!-- Debugging: Add style infos to the output. --> + <!-- + <value-of select="'{'"/> + <value-of select="$style-left"/> + <value-of select="'-'"/> + <value-of select="$style"/> + <value-of select="','"/> + <value-of select="$context-size"/> + <value-of select="'}'"/> + --> - <template match="text:reference-mark-start"> - <!-- TODO: Output an anchor. --> - </template> + <if test="$superscript and not($superscript-left)"> + <text>^^</text> + </if> + <if test="$subscript and not($subscript-left)"> + <text>,,</text> + </if> + <if test="not($code) and $typewriter and not($typewriter-left)"> + <text>##</text> + </if> + <if test="$bold and not($bold-left)"> + <text>**</text> + </if> + <if test="$italic and not($italic-left)"> + <text>//</text> + </if> - <!-- - == Plain text == - --> + <call-template name="render-quoted-text"> + <with-param name="text" select="."/> + </call-template> - <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()"> - <choose> - <when test="boolean(./ancestor::table:table-header-rows | ./ancestor::text:h)"> - <!-- - No explicit styles within table headings or section headings, - because those styles are consistently declared by the Wiki engine. --> - <value-of select="."/> - </when> - - <when test="string-length(.) > 0"> - <variable name="style"> - <call-template name="mk-style-set"> - <with-param name="node" select="."/> - </call-template> - </variable> - - <variable name="current-paragraph" - select="./ancestor::text:p[1]"/> - <variable name="paragraph-id" - select="generate-id($current-paragraph)"/> - <variable name="frames" - select="$current-paragraph/descendant::draw:frame"/> - <variable name="frame-count" - select="count($frames)"/> - - <!-- - The current style context consists of all text nodes that are - descendants of the paragraph ancestor of this text node but not - descendants of any frame nodes that are descendants of the current - text nodes paragraph. - --> - <variable name="context" - select="$current-paragraph//text()[not(boolean(./ancestor::draw:frame[1]) and count(./ancestor::draw:frame[1] | $frames) = $frame-count)]"/> - <variable name="context-size" select="count($context)"/> + <if test="$italic and not($italic-right)"> + <text>//</text> + </if> + <if test="$bold and not($bold-right)"> + <text>**</text> + </if> + <if test="not($code) and $typewriter and not($typewriter-right)"> + <text>##</text> + </if> + <if test="$subscript and not($subscript-right)"> + <text>,,</text> + </if> + <if test="$superscript and not($superscript-right)"> + <text>^^</text> + </if> - <variable name="context-index"> - <call-template name="mk-context-index"> - <with-param name="current-id" select="generate-id(.)"/> - <with-param name="context" select="$context"/> - <with-param name="test-index" select="1"/> - </call-template> - </variable> + <!-- Debugging: Add style details to the output. --> + <!-- + <value-of select="'{'"/> + <value-of select="$style"/> + <value-of select="'-'"/> + <value-of select="$style-right"/> + <value-of select="'}'"/> + --> - <variable name="style-left"> - <choose> - <when test="$context-index > 1"> - <variable name="left" select="$context[$context-index - 1]"/> - <!-- - The preceding text node is a child of this nodes topmost - styled ancestor. This means that the result of the - transformation will be directly concatenated. - --> - <call-template name="mk-style-set"> - <with-param name="node" select="$left"/> - </call-template> - </when> - <otherwise> - <value-of select="$NO_STYLE"/> - </otherwise> - </choose> - </variable> - <variable name="style-right"> - <choose> - <when test="$context-index < count($context)"> - <variable name="right" select="$context[$context-index + 1]"/> - <!-- - The preceding text node is a child of this nodes topmost - styled ancestor. This means that the result of the - transformation will be directly concatenated. - --> - <call-template name="mk-style-set"> - <with-param name="node" select="$right"/> - </call-template> - </when> - <otherwise> - <value-of select="$NO_STYLE"/> - </otherwise> - </choose> - </variable> + </when> + </choose> + </template> - <variable name="bold" - select="($style mod (2 * $BOLD_BIT)) != 0"/> - <variable name="italic" - select="($style mod (2 * $ITALIC_BIT)) - ($style mod ($ITALIC_BIT)) != 0"/> - <variable name="superscript" - select="($style mod (2 * $SUPERSCRIPT_BIT)) - ($style mod ($SUPERSCRIPT_BIT)) != 0"/> - <variable name="subscript" - select="($style mod (2 * $SUBSCRIPT_BIT)) - ($style mod ($SUBSCRIPT_BIT)) != 0"/> - <variable name="code" - select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> - <variable name="typewriter" - select="($style mod (2 * $TYPEWRITER_BIT)) - ($style mod ($TYPEWRITER_BIT)) != 0"/> + <!-- + Function for looking up the position of a node identified by the given + 'current-id' within a node set 'context'. + + The search starts with the the index 'test-index'. The search is recursive + in the 'test-index' argument. To save recursion depth, each recursive call + iteratively tests a fixed number of indexes (by loop unrolling). + --> + <template name="mk-context-index"> + <param name="current-id"/> + <param name="context"/> + <param name="test-index"/> + + <variable name="context-size" select="count($context)"/> + + <choose> + <when test="context-size < $test-index"> + </when> + <when test="$current-id = generate-id($context[$test-index])"> + <value-of select="$test-index"/> + </when> + <when test="context-size < ($test-index + 1)"> + </when> + <when test="$current-id = generate-id($context[$test-index + 1])"> + <value-of select="$test-index + 1"/> + </when> + <when test="context-size < ($test-index + 2)"> + </when> + <when test="$current-id = generate-id($context[$test-index + 2])"> + <value-of select="$test-index + 2"/> + </when> + <when test="context-size < ($test-index + 3)"> + </when> + <when test="$current-id = generate-id($context[$test-index + 3])"> + <value-of select="$test-index + 3"/> + </when> + <when test="context-size < ($test-index + 4)"> + </when> + <when test="$current-id = generate-id($context[$test-index + 4])"> + <value-of select="$test-index + 4"/> + </when> + <when test="context-size < ($test-index + 5)"> + </when> + <when test="$current-id = generate-id($context[$test-index + 5])"> + <value-of select="$test-index + 5"/> + </when> + <when test="context-size < ($test-index + 6)"> + </when> + <otherwise> + <call-template name="mk-context-index"> + <with-param name="current-id" select="$current-id"/> + <with-param name="context" select="$context"/> + <with-param name="test-index" select="$test-index + 6"/> + </call-template> + </otherwise> + </choose> + </template> + + <template name="render-quoted-text"> + <param name="text"/> + + <choose> + <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, '#')"> + <text><nowiki></text> + <choose> + <when test="contains($text, '</nowiki>')"> + <call-template name="render-escaped-text"> + <with-param name="text" select="$text"/> + </call-template> + </when> + <otherwise> + <value-of select="$text"/> + </otherwise> + </choose> + <text></nowiki></text> + </when> + <otherwise> + <value-of select="$text"/> + </otherwise> + </choose> + </template> - <variable name="bold-left" - select="($style-left mod (2 * $BOLD_BIT)) != 0"/> - <variable name="italic-left" - select="($style-left mod (2 * $ITALIC_BIT)) - ($style-left mod ($ITALIC_BIT)) != 0"/> - <variable name="superscript-left" - select="($style-left mod (2 * $SUPERSCRIPT_BIT)) - ($style-left mod ($SUPERSCRIPT_BIT)) != 0"/> - <variable name="subscript-left" - select="($style-left mod (2 * $SUBSCRIPT_BIT)) - ($style-left mod ($SUBSCRIPT_BIT)) != 0"/> - <variable name="typewriter-left" - select="($style-left mod (2 * $TYPEWRITER_BIT)) - ($style-left mod ($TYPEWRITER_BIT)) != 0"/> + <template name="render-escaped-text"> + <param name="text"/> + + <choose> + <when test="contains($text, '<')"> + <value-of select="substring-before($text, '<')"/> + <value-of select="'&'"/> + <value-of select="'lt;'"/> + <value-of select="substring-after($text, '<')"/> + </when> + <otherwise> + <value-of select="$text"/> + </otherwise> + </choose> + </template> - <variable name="bold-right" - select="($style-right mod (2 * $BOLD_BIT)) != 0"/> - <variable name="italic-right" - select="($style-right mod (2 * $ITALIC_BIT)) - ($style-right mod ($ITALIC_BIT)) != 0"/> - <variable name="superscript-right" - select="($style-right mod (2 * $SUPERSCRIPT_BIT)) - ($style-right mod ($SUPERSCRIPT_BIT)) != 0"/> - <variable name="subscript-right" - select="($style-right mod (2 * $SUBSCRIPT_BIT)) - ($style-right mod ($SUBSCRIPT_BIT)) != 0"/> - <variable name="typewriter-right" - select="($style-right mod (2 * $TYPEWRITER_BIT)) - ($style-right mod ($TYPEWRITER_BIT)) != 0"/> + <!-- + == Wiki styles: bold, italics, ... == + --> - <!-- Debugging: Add style infos to the output. --> - <!-- - <value-of select="'{'"/> - <value-of select="$style-left"/> - <value-of select="'-'"/> - <value-of select="$style"/> - <value-of select="','"/> - <value-of select="$context-size"/> - <value-of select="'}'"/> - --> + <template name="mk-style-set"> + <param name="node"/> + + <variable + name="context" + select="$node/ancestor-or-self::*[@text:style-name][1]" + /> + + <choose> + <when test="boolean($context)"> + <variable + name="style" + select="key('style-ref', $context/@text:style-name)" + /> - <if test="$superscript and not($superscript-left)"> - <text><sup></text> - </if> - <if test="$subscript and not($subscript-left)"> - <text><sub></text> - </if> - <if test="not($code) and $typewriter and not($typewriter-left)"> - <text><tt></text> - </if> - <if test="$bold and not($bold-left)"> - <text><b></text> - </if> - <if test="$italic and not($italic-left)"> - <text>''</text> - </if> + <!-- Debugging: Print inspected styles. --> + <!-- + <message> + <value-of select="'=== '"/> + <value-of select="$style/@style:name"/> + <value-of select="' ==='"/> + </message> + --> + + <call-template name="mk-style-set-internal"> + <with-param name="node" select="$context"/> + <with-param name="style" select="$style"/> + <with-param name="style-set" select="$NO_STYLE"/> + <with-param name="style-mask" select="$NO_STYLE"/> + </call-template> + </when> + <otherwise> + <value-of select="$NO_STYLE"/> + </otherwise> + </choose> + </template> + + <!-- + Compute the wiki style set that corresponds + to the given office style at the given context node. + + @param node + A node in which context the style is computed. If neither the given style + nor one of its linked styles does specify a style of the given type, + ancestor nodes of the given context node are considered. + @param style + A style:style element node. The style of the requested type is searched + in the given style and its linked styles. + @style-set + A bit set of styles already defined by the context. + @style-mask + A bit set of styles that must not be taken from the currently inspected + style, because those styles are already defined by the context. + + @return A bit set composed of the wiki style constants. + --> + <template name="mk-style-set-internal"> + <param name="node"/> + <param name="style"/> + <param name="style-set"/> + <param name="style-mask"/> + + <variable name="text-properties" select="$style/style:text-properties"/> + + <!-- Decompose style-mask into individual bits. --> + <variable name="bold-requested" + select="($style-mask mod (2 * $BOLD_BIT)) = 0"/> + <variable name="italic-requested" + select="($style-mask mod (2 * $ITALIC_BIT)) - ($style-mask mod ($ITALIC_BIT)) = 0"/> + <variable name="superscript-requested" + select="($style-mask mod (2 * $SUPERSCRIPT_BIT)) - ($style-mask mod ($SUPERSCRIPT_BIT)) = 0"/> + <variable name="subscript-requested" + select="($style-mask mod (2 * $SUBSCRIPT_BIT)) - ($style-mask mod ($SUBSCRIPT_BIT)) = 0"/> + <variable name="typewriter-requested" + select="($style-mask mod (2 * $TYPEWRITER_BIT)) - ($style-mask mod ($TYPEWRITER_BIT)) = 0"/> + <variable name="code-requested" + select="($style-mask mod (2 * $CODE_BIT)) - ($style-mask mod ($CODE_BIT)) = 0"/> + <variable name="center-requested" + select="($style-mask mod (2 * $CENTER_BIT)) - ($style-mask mod ($CENTER_BIT)) = 0"/> + <variable name="right-requested" + select="($style-mask mod (2 * $RIGHT_BIT)) - ($style-mask mod ($RIGHT_BIT)) = 0"/> + + <!-- Extract styles that are not already defined by the context. --> + <variable name="bold-style"> + <choose> + <when test="$bold-requested and boolean($text-properties/@fo:font-weight='bold')"> + <!-- Bold found in current style. --> + <value-of select="$BOLD_BIT"/> + </when> + <otherwise> + <value-of select="$NO_STYLE"/> + </otherwise> + </choose> + </variable> + <variable name="bold-mask"> + <choose> + <when test="$bold-requested and boolean($text-properties/@fo:font-weight)"> + <!-- + Other value than "bold" means that the character style is not + bold and no parent style must be considered. + --> + <value-of select="$BOLD_BIT"/> + </when> + <otherwise> + <value-of select="$NO_STYLE"... [truncated message content] |
From: <var...@us...> - 2009-07-08 09:20:34
|
Revision: 7009 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7009&view=rev Author: vargenau Date: 2009-07-08 09:20:32 +0000 (Wed, 08 Jul 2009) Log Message: ----------- Use Wikicreole line break instead of <br/> that is not recognized by Phpwiki Modified Paths: -------------- trunk/admin/odt2phpwiki.xsl Modified: trunk/admin/odt2phpwiki.xsl =================================================================== --- trunk/admin/odt2phpwiki.xsl 2009-07-08 08:25:12 UTC (rev 7008) +++ trunk/admin/odt2phpwiki.xsl 2009-07-08 09:20:32 UTC (rev 7009) @@ -426,7 +426,7 @@ --> <choose> <when test="boolean(ancestor::text:list-item)"> - <text><br/> </text> + <text> \\ </text> </when> <when test="$code"> <variable name="style-right"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2009-07-08 09:46:44
|
Revision: 7010 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7010&view=rev Author: vargenau Date: 2009-07-08 09:46:35 +0000 (Wed, 08 Jul 2009) Log Message: ----------- Add Id Modified Paths: -------------- trunk/admin/odt2phpwiki.xsl Property Changed: ---------------- trunk/admin/odt2phpwiki.xsl Modified: trunk/admin/odt2phpwiki.xsl =================================================================== --- trunk/admin/odt2phpwiki.xsl 2009-07-08 09:20:32 UTC (rev 7009) +++ trunk/admin/odt2phpwiki.xsl 2009-07-08 09:46:35 UTC (rev 7010) @@ -2,6 +2,7 @@ <!-- odt2phpwiki: OpenDocument to Phpwiki transformation + $Id$ Copyright (C) 2007 Bernhard Haumacher (haui at haumacher dot de) Copyright (C) 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent Property changes on: trunk/admin/odt2phpwiki.xsl ___________________________________________________________________ Added: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2015-12-14 10:03:53
|
Revision: 9747 http://sourceforge.net/p/phpwiki/code/9747 Author: vargenau Date: 2015-12-14 10:03:50 +0000 (Mon, 14 Dec 2015) Log Message: ----------- No space at end of line Modified Paths: -------------- trunk/admin/odt2phpwiki.xsl Modified: trunk/admin/odt2phpwiki.xsl =================================================================== --- trunk/admin/odt2phpwiki.xsl 2015-12-14 09:20:05 UTC (rev 9746) +++ trunk/admin/odt2phpwiki.xsl 2015-12-14 10:03:50 UTC (rev 9747) @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. This program is based on the OpenDocument to Mediawiki converter by Bernhard Haumacher. @@ -91,22 +91,22 @@ match="//text:list-style" use="@style:name" /> - + <key name="font-face-ref" match="//style:font-face" use="@style:name" /> - + <key name="reference-resolution" match="//text:reference-mark | //text:reference-mark-start" use="@text:name" /> - + <!-- Wiki style constants. --> - + <!-- Bold character style. --> <variable name="BOLD_BIT" select="1"/> @@ -121,7 +121,7 @@ <!-- Typewriter character style. --> <variable name="TYPEWRITER_BIT" select="16"/> - + <!-- Preformatted text paragraph style. --> <variable name="CODE_BIT" select="32"/> @@ -130,7 +130,7 @@ <!-- Right aligned paragraph style. --> <variable name="RIGHT_BIT" select="128"/> - + <!-- Constant defining the empty style. --> <variable name="NO_STYLE" select="0"/> @@ -169,11 +169,11 @@ <value-of select="$NL"/> </if> </template> - + <template name="mk-list-token"> <param name="list-style"/> <param name="level"/> - + <if test="$level > 1"> <call-template name="mk-list-token"> <with-param name="list-style" select="$list-style"/> @@ -223,7 +223,7 @@ <!-- Function generating a wiki heading prefix. - + @param level The heading level. The value must be between 1 and 5. --> @@ -247,7 +247,7 @@ <!-- Function generating a token consisting of the given character repeated 'level' times. - + @param level The lengh of the result. @param char @@ -264,8 +264,8 @@ </call-template> </if> </template> - - + + <!-- == Tables == --> @@ -346,7 +346,7 @@ <value-of select="$link-label"/> <text>]</text> </when> - + <otherwise> <apply-templates/> </otherwise> @@ -373,8 +373,8 @@ </choose> <value-of select="']]'"/> </template> - - + + <!-- == Paragraphs == --> @@ -392,7 +392,7 @@ select="($style mod (2 * $CENTER_BIT)) - ($style mod ($CENTER_BIT)) != 0"/> <variable name="right" select="($style mod (2 * $RIGHT_BIT)) - ($style mod ($RIGHT_BIT)) != 0"/> - + <choose> <when test="$center"> <text><div align="center"></text> @@ -404,7 +404,7 @@ <value-of select="' '"/> </when> </choose> - + <apply-templates/> <choose> @@ -434,10 +434,10 @@ <with-param name="node" select="$paragraph-right"/> </call-template> </variable> - + <variable name="code-right" select="($style-right mod (2 * $CODE_BIT)) - ($style-right mod ($CODE_BIT)) != 0"/> - + <value-of select="$NL"/> <if test="$code-right"> <value-of select="' '"/> @@ -460,7 +460,7 @@ <!-- == Preformatted text == --> - + <template match="text:s"> <variable name="style"> <call-template name="mk-style-set"> @@ -470,7 +470,7 @@ <variable name="code" select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> - + <if test="$code"> <choose> <when test="@text:c"> @@ -485,7 +485,7 @@ </choose> </if> </template> - + <template match="text:line-break"> <variable name="style"> <call-template name="mk-style-set"> @@ -495,7 +495,7 @@ <variable name="code" select="($style mod (2 * $CODE_BIT)) - ($style mod ($CODE_BIT)) != 0"/> - + <if test="$code"> <value-of select="$NL"/> <value-of select="' '"/> @@ -505,10 +505,10 @@ <!-- Footnotes --> - + <template match="text:note-body"> <variable name="note" select="./parent::text:note"/> - + <if test="$note/@text:note-class = 'footnote'"> <text><ref name="</text> <value-of select="$note/@text:id"/> @@ -517,140 +517,140 @@ <text></ref></text> </if> </template> - + <template match="text:note-ref[@text:note-class='footnote']"> <text><ref name="</text> <value-of select="@text:ref-name"/> <text>"/></text> </template> - - + + <!-- == Images == --> - - <template match="draw:text-box[boolean(.//draw:image)]"> - <variable name="image" select=".//draw:image[1]"/> - - <variable name="image-description"> - <apply-templates/> - </variable> - - <text>[[</text> + + <template match="draw:text-box[boolean(.//draw:image)]"> + <variable name="image" select=".//draw:image[1]"/> + + <variable name="image-description"> + <apply-templates/> + </variable> + + <text>[[</text> <call-template name="mk-image-name"> <with-param name="image" select="$image"/> </call-template> - <text>|thumb|</text> + <text>|thumb|</text> <value-of select="normalize-space($image-description)"/> - <text>]]</text> - </template> - - <template match="draw:image[not(boolean(ancestor::draw:text-box))]"> - <text>[[</text> + <text>]]</text> + </template> + + <template match="draw:image[not(boolean(ancestor::draw:text-box))]"> + <text>[[</text> <call-template name="mk-image-name"> <with-param name="image" select="."/> </call-template> - <text>]]</text> - </template> + <text>]]</text> + </template> <template name="mk-image-name"> <param name="image"/> - - <variable name="base-name"> - <call-template name="mk-base-name"> - <with-param name="href" select="$image/@xlink:href"/> - </call-template> - </variable> - + + <variable name="base-name"> + <call-template name="mk-base-name"> + <with-param name="href" select="$image/@xlink:href"/> + </call-template> + </variable> + <if test="not(starts-with($base-name, 'Image:'))"> <value-of select="'Image:'"/> </if> <value-of select="$base-name"/> - </template> - - <template name="mk-base-name"> - <param name="href"/> - - <variable name="result" select="substring-after($href, '/')"/> - <choose> - <when test="boolean($result)"> - <call-template name="mk-base-name"> - <with-param name="href" select="$result"/> - </call-template> - </when> - <otherwise> - <value-of select="$href"/> - </otherwise> - </choose> - </template> - - - <!-- - References - --> - + </template> + + <template name="mk-base-name"> + <param name="href"/> + + <variable name="result" select="substring-after($href, '/')"/> + <choose> + <when test="boolean($result)"> + <call-template name="mk-base-name"> + <with-param name="href" select="$result"/> + </call-template> + </when> + <otherwise> + <value-of select="$href"/> + </otherwise> + </choose> + </template> + + + <!-- + References + --> + <!-- TODO: text:bibliography-mark --> - <template match="text:reference-ref"> - <variable name="reference-mark" select="key('reference-resolution', @text:ref-name)"/> - - <choose> - <when test="boolean($reference-mark)"> - <!-- - In wiki syntax, only a local reference to a heading can be inserted. - If the link target is a descendant of a heading element, a link can be - inserted in the result. --> - <variable name="header-anchor" select="$reference-mark/ancestor::text:h[1]"/> - <if test="boolean($header-anchor)"> - <text>[[#</text> - <value-of select="string($header-anchor)"/> - <text>|</text> - </if> - - <variable name="reference-text" select="string(.)"/> - - <choose> - <!-- Check, whether the reference text is cached in the document. --> - <when test="string-length($reference-text) > 0"> - <value-of select="$reference-text"/> - </when> - - <otherwise> - <!-- - TODO: Evaluate the @text:reference-format attribute and - generate the replacement text (difficult).--> - <text>(REFERENCE TEXT UNAVAILABLE: "</text> - <value-of select="@text:ref-name"/> - <text>")</text> - </otherwise> - </choose> - - <if test="boolean($header-anchor)"> - <text>]]</text> - </if> - </when> + <template match="text:reference-ref"> + <variable name="reference-mark" select="key('reference-resolution', @text:ref-name)"/> - <otherwise> - <text>(UNDEFINED REFERENCE: "</text> - <value-of select="@text:ref-name"/> - <text>")</text> - </otherwise> - </choose> - </template> - - <template match="text:reference-mark"> - <!-- TODO: Output an anchor. --> - <apply-templates/> - </template> + <choose> + <when test="boolean($reference-mark)"> + <!-- + In wiki syntax, only a local reference to a heading can be inserted. + If the link target is a descendant of a heading element, a link can be + inserted in the result. --> + <variable name="header-anchor" select="$reference-mark/ancestor::text:h[1]"/> + <if test="boolean($header-anchor)"> + <text>[[#</text> + <value-of select="string($header-anchor)"/> + <text>|</text> + </if> - <template match="text:reference-mark-start"> - <!-- TODO: Output an anchor. --> - </template> + <variable name="reference-text" select="string(.)"/> + <choose> + <!-- Check, whether the reference text is cached in the document. --> + <when test="string-length($reference-text) > 0"> + <value-of select="$reference-text"/> + </when> + + <otherwise> + <!-- + TODO: Evaluate the @text:reference-format attribute and + generate the replacement text (difficult).--> + <text>(REFERENCE TEXT UNAVAILABLE: "</text> + <value-of select="@text:ref-name"/> + <text>")</text> + </otherwise> + </choose> + + <if test="boolean($header-anchor)"> + <text>]]</text> + </if> + </when> + + <otherwise> + <text>(UNDEFINED REFERENCE: "</text> + <value-of select="@text:ref-name"/> + <text>")</text> + </otherwise> + </choose> + </template> + + <template match="text:reference-mark"> + <!-- TODO: Output an anchor. --> + <apply-templates/> + </template> + + <template match="text:reference-mark-start"> + <!-- TODO: Output an anchor. --> + </template> + <!-- == Plain text == --> - + <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()"> <choose> <when test="boolean(./ancestor::table:table-header-rows | ./ancestor::text:h)"> @@ -659,14 +659,14 @@ because those styles are consistently declared by the Wiki engine. --> <value-of select="."/> </when> - + <when test="string-length(.) > 0"> <variable name="style"> <call-template name="mk-style-set"> <with-param name="node" select="."/> </call-template> </variable> - + <variable name="current-paragraph" select="./ancestor::text:p[1]"/> <variable name="paragraph-id" @@ -675,7 +675,7 @@ select="$current-paragraph/descendant::draw:frame"/> <variable name="frame-count" select="count($frames)"/> - + <!-- The current style context consists of all text nodes that are descendants of the paragraph ancestor of this text node but not @@ -829,7 +829,7 @@ <!-- Function for looking up the position of a node identified by the given 'current-id' within a node set 'context'. - + The search starts with the the index 'test-index'. The search is recursive in the 'test-index' argument. To save recursion depth, each recursive call iteratively tests a fixed number of indexes (by loop unrolling). @@ -838,9 +838,9 @@ <param name="current-id"/> <param name="context"/> <param name="test-index"/> - + <variable name="context-size" select="count($context)"/> - + <choose> <when test="context-size < $test-index"> </when> @@ -883,10 +883,10 @@ </otherwise> </choose> </template> - + <template name="render-quoted-text"> <param name="text"/> - + <choose> <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, '#')"> <text><nowiki></text> @@ -900,7 +900,7 @@ <value-of select="$text"/> </otherwise> </choose> - <text></nowiki></text> + <text></nowiki></text> </when> <otherwise> <value-of select="$text"/> @@ -910,7 +910,7 @@ <template name="render-escaped-text"> <param name="text"/> - + <choose> <when test="contains($text, '<')"> <value-of select="substring-before($text, '<')"/> @@ -930,12 +930,12 @@ <template name="mk-style-set"> <param name="node"/> - + <variable name="context" select="$node/ancestor-or-self::*[@text:style-name][1]" /> - + <choose> <when test="boolean($context)"> <variable @@ -943,7 +943,7 @@ select="key('style-ref', $context/@text:style-name)" /> - <!-- Debugging: Print inspected styles. --> + <!-- Debugging: Print inspected styles. --> <!-- <message> <value-of select="'=== '"/> @@ -951,7 +951,7 @@ <value-of select="' ==='"/> </message> --> - + <call-template name="mk-style-set-internal"> <with-param name="node" select="$context"/> <with-param name="style" select="$style"/> @@ -964,11 +964,11 @@ </otherwise> </choose> </template> - + <!-- Compute the wiki style set that corresponds to the given office style at the given context node. - + @param node A node in which context the style is computed. If neither the given style nor one of its linked styles does specify a style of the given type, @@ -981,7 +981,7 @@ @style-mask A bit set of styles that must not be taken from the currently inspected style, because those styles are already defined by the context. - + @return A bit set composed of the wiki style constants. --> <template name="mk-style-set-internal"> @@ -989,9 +989,9 @@ <param name="style"/> <param name="style-set"/> <param name="style-mask"/> - + <variable name="text-properties" select="$style/style:text-properties"/> - + <!-- Decompose style-mask into individual bits. --> <variable name="bold-requested" select="($style-mask mod (2 * $BOLD_BIT)) = 0"/> @@ -1009,7 +1009,7 @@ select="($style-mask mod (2 * $CENTER_BIT)) - ($style-mask mod ($CENTER_BIT)) = 0"/> <variable name="right-requested" select="($style-mask mod (2 * $RIGHT_BIT)) - ($style-mask mod ($RIGHT_BIT)) = 0"/> - + <!-- Extract styles that are not already defined by the context. --> <variable name="bold-style"> <choose> @@ -1036,7 +1036,7 @@ </otherwise> </choose> </variable> - + <variable name="italic-style"> <choose> <when test="$italic-requested and boolean($text-properties/@fo:font-style='italic')"> @@ -1165,7 +1165,7 @@ </otherwise> </choose> </variable> - + <variable name="center-style"> <choose> <when test="$center-requested and ($style/@style:family='paragraph') and boolean($style/style:paragraph-properties/@fo:text-align='center')"> @@ -1207,8 +1207,8 @@ </otherwise> </choose> </variable> - + <!-- Compute the updated styles and mask. --> <!-- Note: The bit masks style-mask, bold-style, italic-style,... are @@ -1232,7 +1232,7 @@ </when> <otherwise> <variable name="ancestors" select="$node/ancestor::*[@text:style-name][1]"/> - + <!-- Debugging: Print currently inspected style. --> <!-- <message> @@ -1250,7 +1250,7 @@ <value-of select="'}'"/> </message> --> - + <!-- If there is an ancestor that has a style, use that style, otherwise, a style is not found. --> @@ -1289,7 +1289,7 @@ <value-of select="$NL"/> </if> </template> - + <template match="office:document-content"> <apply-templates/> </template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |