Difference between revisions of "Odt2Wiki"
From Apache OpenOffice Wiki
LouisSuarez (talk | contribs) |
(→Additional information: Added reference to feature page.) |
||
Line 143: | Line 143: | ||
== Additional information == | == Additional information == | ||
− | http://qa.openoffice.org/issues/show_bug.cgi?id=48409 | + | * [[Odt2Wiki/Features]] |
+ | * http://qa.openoffice.org/issues/show_bug.cgi?id=48409 | ||
== Alternatives == | == Alternatives == |
Revision as of 20:52, 29 May 2007
Converting OpenDocument/Text to WikiPedia/MediaWiki format
Odt2Wiki is an export filter for OpenOffice 2.0 by Bernhard Haumacher. It will let you convert OpenOffice.org Writer files (OpenDocument/Text) to MediaWiki (WikiPedia) text format.
Test it online
You can upload the odt and download the txt in MediaWiki format:
http://www.ipd.uni-karlsruhe.de/~hauma/odt2txt/
Odt2Wiki.xslt
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" exclude-result-prefixes="office text" > <xsl:output method="text" media-type="text/plain" encoding="UTF-8" /> <xsl:template match="office:document-content"> <xsl:apply-templates/> </xsl:template> <xsl:template match="office:body"> <xsl:apply-templates/> </xsl:template> <xsl:template match="draw:page"> <xsl:value-of select="concat(' <!-- Page ', @draw:name, '--> ')"/> <xsl:apply-templates/> <xsl:value-of select="' ---- '"/> </xsl:template> <xsl:template match="text:list-item"> <xsl:value-of select="'* '"/> <xsl:apply-templates/> </xsl:template> <xsl:template match="text:h[@text:outline-level = 1]"> <xsl:value-of select="'= '"/> <xsl:apply-templates/> <xsl:value-of select="' = '"/> </xsl:template> <xsl:template match="text:h[@text:outline-level = 2]"> <xsl:value-of select="'== '"/> <xsl:apply-templates/> <xsl:value-of select="' == '"/> </xsl:template> <xsl:template match="text:h[@text:outline-level = 3]"> <xsl:value-of select="'=== '"/> <xsl:apply-templates/> <xsl:value-of select="' === '"/> </xsl:template> <xsl:template match="text:span[@text:style-name='WikiMath']"> <xsl:value-of select="'<math>'"/> <xsl:apply-templates/> <xsl:value-of select="'</math>'"/> </xsl:template> <xsl:template match="text:span[@text:style-name='WikiLink']"> <xsl:value-of select="'[['"/> <xsl:variable name="link-def" select="string(.)"/> <xsl:variable name="link-label" select="normalize-space(substring-before($link-def, '['))"/> <xsl:variable name="link-ref" select="normalize-space(substring-before(substring-after($link-def, '['), ']'))"/> <xsl:choose> <xsl:when test="boolean($link-ref)"> <xsl:value-of select="concat($link-ref, '|', $link-label)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$link-def"/> </xsl:otherwise> </xsl:choose> <xsl:value-of select="']]'"/> </xsl:template> <xsl:template match="text:p[string-length(.) > 0]"> <xsl:apply-templates/> <xsl:value-of select="' '"/> <xsl:if test="position() < last()"> <xsl:value-of select="' '"/> </xsl:if> </xsl:template> <xsl:template match="text:p[string-length(.) = 0 and string-length(preceding-sibling::text:p[1]) > 0]"> <xsl:value-of select="' '"/> </xsl:template> <xsl:template match="text:p/text() | text:h/text() | text:span/text()"> <xsl:value-of select="."/> </xsl:template> <xsl:template match="office:* | text:* | draw:frame | draw:text-box"> <xsl:apply-templates/> </xsl:template> <xsl:template match="node()"> </xsl:template> </xsl:stylesheet> <!-- Local Variables: tab-width: 2 sgml-indent-step: 2 End: -->
Installation in OpenOffice.org 2.0
To install the export filter:
- Create the file Odt2Wiki.xslt:
- Go here #Odt2Wiki.xslt
- Select all
- Paste it to a new text file
- Save it as Odt2Wiki.xslt
- Start OpenOffice.org 2.0.
- From Tool choose XML Filter Settings.
- choose New and in General fill the form with the following data:
- Filter name: Odt2Wiki
- Application: OpenOffice.org Writer (.odt)
- Name of file type: Odt2Wiki
- File extention: txt
- Choose Transformation and fill the form with the following data:
- XSLT for Export: put the full path to Odt2Wiki.xslt
Convert Files
To export choose File -> Export and select Odt2Wiki (.txt) as file format.
Now you can paste the content of the file in the edit form of MediaWiki.
Additional information
Alternatives
- There is a similar alternative: http://www.activasoft.com/OpenOffice2MediaWiki . It is slower for long documents, but works better for bold and italics, and works different for tables, lists and images. Like Odt2Wiki, OpenOffice2MediaWiki is an XML filter (XSLT). It is based on OpenOffice2UniWakka.
- There also is an OpenOffice.org macro which will accomplish more or less the same: http://ooowiki.de/Writer2MediaWiki (german/english page).
- See also: 2UniWakka: http://uniwakka.sourceforge.net/OpenOffice2UniWakka