Extension:Collection/XML Bridge/Examples

= Example using MWXHTML =

http://localhost:8000/mwxhtml/mediawiki.org/w/Extension:XML_Bridge

Introduction Wiki syntax, due to its lack of formalization and &#8220;ad hoc&#8221; nature, is not well- suited for text transformation to other formats. It is desirable to implement support for an intermediate format based on XML, which will make it possible to use standard XML parsing and transformation libraries on the source content. While MediaWiki's native parser exports to XHTML- transitional, the conversion from wiki syntax to XHTML is a lossy one: information about the templates used, the parameters for extensions and images, and so on, is not preserved. This makes many conversions impossible, because the information needed for the conversion is not present. It is therefore planned to develop software that converts MediaWiki-articles to an XHTML-based representation. XHTML is well suited to derive other formats like PDF or ODF. As much semantic information from the wiki source text as possible will be preserved by using XHTML features such as namespaces. The transformation to an XHTML-based format that preserves semantic information will enable a vast number of uses by programmers, and will also allow a long-term transition to XML as a backend storage format for wiki articles.

Development is assigned to  PediaPress and funded by the  Commonwealth of Learning Current Status An initial alpha code release is available as part of the  mwlib python MediaWiki library. (see  xhtmlwriter.py). Feel free to use and comment on it. Although this code is still lacking some features it may be a good starting point to develop alternative XML output formats.

There is a  google group for support and discussion of mwlib and derived applications. See  this page for installation instructions. Current Implementation The initial implementation is based on XHTML1.0 transitional extended by  Microformats where necessary. This is to support the  presentational HTML4.01 Elements allowed in wikitext by MediaWiki. A future implementation could be based on XHTML1.1 strict plus MathML.

You may want to have a look at the proposed XML-Format Extension:XML Bridge/MWXHTML</a> The XML is generated based on the parse-tree generated by the  mwlib</a> MediaWiki-markup parsing library. Development &amp; Evaluation

The xhtmlwriter.py is part of the  mwlib python library</a>. See  this page</a> for installation instructions. There is a xml-server app in the sandbox directory, which acts as a Mediawiki (which must support the new API) proxy, converting wikitext to xhtml as you browse. Long Term Goal ... is to have a solid XML-Export/Import that allows to replace the MediaWiki-Markup with a XML-representation, this may coincide with WYSIWIG-editing in MediaWiki.

Steps toward this goal: <ul> <li> initial release of XML-Exporter code </li> <li> develop XML-&gt;mw-markup converter so one can convert back and forth </li> <li> discuss and incrementally improve the xml-markup </li>

<li> discuss whether usage of certain html-styling and template usage can be labeled deprecated</li> <li> check edits and notify users if using wrong or deprecated markup </li> <li> fix or remove all broken/deprecated markup,html-styling,inappropriate template usage</li> <li> switch to xml</li> </ul>

Other considered Implementation Options MediaWiki specific XML Language  Don&#8217;t Invent XML Languages</a> - at least for now.

DocBook DocBook is a very large markup language. A more abbreviated version, Simplified DocBook, removes a number of redundant elements. DocBook NG schema (customizable namespaces) is under development. Conclusion: DocBook is overly complicated while still lacking features in order to fully support a lossless representation of MW markup. XHTML XHTML is well supported by many applications and libraries. XHTML can be mixed with other namespaces (xhtml remains if stripped). Currently MW-markup allows to mix in HTML and even css styles. Therefore a lossless XML representation would need to support a subset of the XHTML specification.

MW-markup expresses semantics (e.g. sections) which are not supported by XHTML1.0. Hence pure XHTML is not sufficient. XHTML + Additional namespace We considered to combine XHTML with a proprietary MediaWiki specific namesspace (xmlns:mwx) using the best of two worlds (compatibility with existing tools and lossless representation). For e.g. a category-link could be written as:

Other suitable namespaces can be included like  MathML</a> This still requires to invent and add a new XML-Language which is considered harmful(see above). XHTML + Microformats Use Microformats to semantically annotate generated XHTML.

 Discussion on microformats in MediaWikis</a> See the planned implementation: Extension:XML_Bridge/MWXHTML</a>

Open Issues Templates <ul> <li> Currently it seem impossible to correctly mark all uses of templates within the XML output.</li> </ul>

Related Projects <ul> <li> Extension:Wiki2xml</a> (abandoned)</li><li> DocBook_XML_export</a> (never started)</li><li>

Extension:Open_Office_Export</a> (abandoned)</li><li> Extension:Data Transfer</a> </li><li>  Connexions XML Language</a> </li><li>  WikiXML: XML format</a>

</li><li>  An XML Interchange Format for Wiki Creole 1.0</a> </li><li>  DocBook Wiki</a> </li><li> <a class="mwx.link.external" href="http://meta.wikimedia.org/wiki/XHTML"> about XHTML produced by MediaWiki</a>

</li><li> <a class="mwx.link.external" href="http://meta.wikimedia.org/wiki/Wikitext_standard"> Wikitext Standard</a> ... describe and formalize a 1.0 version of the Wikitext language, based on what is used currently. (last edit: 29 June 2007)</li><li> <a class="mwx.link.external" href="http://www.usemod.com/cgi-bin/mb.pl?WikiMarkupStandard"> WikiMarkup Standard</a> discusses ways to allow visitors from one wiki engine to edit pages on other wikis without having to learn their WikiSyntax. (last edit: May 10, 2008 active discussion )</li><li> <a class="mwx.link.external" href="http://web.archive.org/web/20060716015316/http://hula-project.org/Wiki_Conversion"> page collecting info on "wiki conversion"</a> (last modified 15:40, 21 Jun 2006.)</li><li>

<a class="mwx.link.article" href="Wikipedia_DTD">Wikipedia DTD</a> (last real edit 9 April 2006) </li> </ul> See also <ul>

<li> <a class="mwx.link.external" href="http://en.wikipedia.org/wiki/MediaWiki#Limitations"> MediaWiki Limitations</a> </li><li> <a class="mwx.link.article" href="Alternative parsers">Alternative parsers</a> </li><li> <a class="mwx.link.external" href="http://blogs.sun.com/lebo/entry/who_isn_t_using_a"> Can you roundtrip OpenOffice.org to MediaWiki and back again?</a>

</li><li> <a class="mwx.link.external" href="http://code.pediapress.com/">http://code.pediapress.com/</a> </li><li> <a class="mwx.link.external" href="http://www.tbray.org/ongoing/When/200x/2006/01/08/No-New-XML-Languages"> Don&#8217;t Invent XML Languages</a> </li><li> <a class="mwx.link.external" href="http://www.codinghorror.com/blog/archives/001116.html"> Is HTML a Humane Markup Language?</a>

</li><li> <a class="mwx.link.external" href="http://freshmeat.net/projects/xmldiff/"> XML Diff</a> </li><li> <a class="mwx.link.article" href="WYSIWYG_editor">WYSIWYG_editor</a> </li> </ul>

<!-- Article 'Extension:XML_Bridge': 12 children Paragraph '': 0 children Table '' {'style': {'float': 'right', 'min-width': '20%', 'background-color': 'white'}, 'class': 'ext-infobox ext-status-unstable'}: 4 children Caption '' {}: 4 children ' '            Strong '': 1 children Link '': 1 children 'Manual on MediaWiki Extensions' BreakingReturn 'br': 0 children Strong '': 1 children Link '': 1 children 'List of MediaWiki Extensions' Row '' {'class': 'ext-header'}: 1 children Cell '' {'colspan': 2, 'style': {'padding-top': '0.5em'}}: 5 children ImageLink '': 1 children 'Crystal Clear app error.png' Span 'span': 1 children 'XML Bridge' BreakingReturn 'br': 0 children ' Release status: unstable ' CategoryLink '': 1 children 'unstable extensions' Row '' {}: 2 children Cell '' {'style': {'vertical-align': 'top'}}: 1 children SpecialLink '': 1 children Strong '': 1 children 'Description' Cell '' {}: 1 children ' Converts MediaWiki markup to XHTML ' Row '' {}: 2 children Cell '' {'style': {'vertical-align': 'top'}}: 1 children SpecialLink '': 1 children Strong '': 1 children 'Download' Cell '' {}: 1 children URL 'http://code.pediapress.com/wiki/wiki/mwlib': 0 children Paragraph '': 1 children CategoryLink '': 1 children 'All extensions' Section '': 5 children Paragraph '': 1 children "Wiki syntax, due to its lack of formalization and \u201cad hoc\u201d nature, is not well- suited for text transformation to other formats. It is desirable to implement support for an intermediate format based on XML, which will make it possible to use standard XML parsing and transformation libraries on the source content. While MediaWiki's native parser exports to XHTML- transitional, the conversion from wiki syntax to XHTML is a lossy one: information about the templates used, the parameters for extensions and images, and so on, is not preserved. This makes many conversions impossible, because the information needed for the conversion is not present." Paragraph '': 1 children 'It is therefore planned to develop software that converts MediaWiki-articles to an XHTML-based representation. XHTML is well suited to derive other formats like PDF or ODF.' Paragraph '': 1 children 'As much semantic information from the wiki source text as possible will be preserved by using XHTML features such as namespaces.' Paragraph '': 1 children 'The transformation to an XHTML-based format that preserves semantic information will enable a vast number of uses by programmers, and will also allow a long-term transition to XML as a backend storage format for wiki articles.' Paragraph '': 4 children 'Development is assigned to ' NamedURL 'http://pediapress.com': 1 children ' PediaPress' ' and funded by the ' NamedURL 'http://col.org': 1 children ' Commonwealth of Learning' Section '': 4 children Paragraph '': 5 children 'An initial alpha code release is available as part of the ' NamedURL 'http://code.pediapress.com': 1 children ' mwlib' ' python MediaWiki library. (see '            NamedURL 'http://code.pediapress.com/hg/mwlib/file/tip/mwlib/xhtmlwriter.py': 1 children                 ' xhtmlwriter.py'             '). Feel free to use and comment on it.' Paragraph '': 1 children 'Although this code is still lacking some features it may be a good starting point to develop alternative XML output formats.' Paragraph '': 3 children 'There is a ' NamedURL 'http://groups.google.com/group/mwlib': 1 children ' google group' ' for support and discussion of mwlib and derived applications.' Paragraph '': 3 children 'See ' NamedURL 'http://code.pediapress.com/wiki/wiki/mwlib': 1 children ' this page for installation instructions' '.'    Section '': 5 children Paragraph '': 3 children 'The initial implementation is based on XHTML1.0 transitional extended by ' NamedURL 'http://en.wikipedia.org/wiki/Microformats': 1 children ' Microformats' ' where necessary. '        Paragraph '': 3 children 'This is to support the ' NamedURL 'http://meta.wikimedia.org/wiki/Help:HTML_in_wikitext': 1 children ' presentational HTML4.01 Elements allowed in wikitext' ' by MediaWiki.' Paragraph '': 1 children 'A future implementation could be based on XHTML1.1 strict plus MathML.' Paragraph '': 2 children 'You may want to have a look at the proposed XML-Format ' Link '': 1 children 'Extension:XML Bridge/MWXHTML' Paragraph '': 3 children 'The XML is generated based on the parse-tree generated by the ' NamedURL 'http://code.pediapress.com': 1 children ' mwlib' ' MediaWiki-markup parsing library.' Section '': 2 children Paragraph '': 5 children 'The xhtmlwriter.py is part of the ' NamedURL 'http://code.pediapress.com': 1 children ' mwlib python library' '. See ' NamedURL 'http://code.pediapress.com': 1 children ' this page' ' for installation instructions.' Paragraph '': 1 children 'There is a xml-server app in the sandbox directory, which acts as a Mediawiki (which must support the new API) proxy, converting wikitext to xhtml as you browse.' Section '': 4 children Paragraph '': 1 children '... is to have a solid XML-Export/Import that allows to replace the MediaWiki-Markup with a XML-representation, this may coincide with WYSIWIG-editing in MediaWiki.' Paragraph '': 1 children 'Steps toward this goal: ' ItemList '': 7 children Item '': 1 children ' initial release of XML-Exporter code ' Item '': 1 children ' develop XML-&gt;mw-markup converter so one can convert back and forth ' Item '': 1 children ' discuss and incrementally improve the xml-markup ' Item '': 1 children ' discuss whether usage of certain html-styling and template usage can be labeled deprecated' Item '': 1 children ' check edits and notify users if using wrong or deprecated markup ' Item '': 1 children ' fix or remove all broken/deprecated markup,html-styling,inappropriate template usage' Item '': 1 children ' switch to xml' Paragraph '': 0 children Section '': 5 children Section '': 1 children Paragraph '': 2 children NamedURL 'http://www.tbray.org/ongoing/When/200x/2006/01/08/No-New-XML-Languages': 1 children ' Don\u2019t Invent XML Languages' ' - at least for now.' Section '': 2 children Paragraph '': 1 children 'DocBook is a very large markup language. A more abbreviated version, Simplified DocBook, removes a number of redundant elements. DocBook NG schema (customizable namespaces) is under development. '            Paragraph '': 1 children 'Conclusion: DocBook is overly complicated while still lacking features in order to fully support a lossless representation of MW markup.' Section '': 2 children Paragraph '': 1 children 'XHTML is well supported by many applications and libraries. XHTML can be mixed with other namespaces (xhtml remains if stripped). Currently MW-markup allows to mix in HTML and even css styles. Therefore a lossless XML representation would need to support a subset of the XHTML specification.' Paragraph '': 1 children 'MW-markup expresses semantics (e.g. sections) which are not supported by XHTML1.0. Hence pure XHTML is not sufficient. '        Section '': 5 children Paragraph '': 1 children 'We considered to combine XHTML with a proprietary MediaWiki specific namesspace (xmlns:mwx) using the best of two worlds (compatibility with existing tools and lossless representation).' Paragraph '': 1 children 'For e.g. a category-link could be written as:' Paragraph '': 1 children Source 'source': 1 children '&lt;a href="Kategorie:Extensions" mwx:linktype="category"&gt;Extensions&lt;/a&gt;' Paragraph '': 2 children 'Other suitable namespaces can be included like ' NamedURL 'http://www.w3.org/Math/': 1 children ' MathML' Paragraph '': 1 children 'This still requires to invent and add a new XML-Language which is considered harmful(see above).' Section '': 4 children Paragraph '': 1 children 'Use Microformats to semantically annotate generated XHTML.' Paragraph '': 1 children Source 'source': 1 children '\n &lt;div class="mwx.section" title="some heading"&gt;\n &lt;h2&gt;some heading&lt;/h2&gt;\n  \n    &lt;a href="SomePage" class="mwx.link.internal"&gt;some page within the same wiki&lt;/a&gt;\n    \n &lt;/div&gt;\n' Paragraph '': 1 children NamedURL 'http://microformats.org/wiki?title=mediawiki-mark-up-issues&amp;redirect=no': 1 children ' Discussion on microformats in MediaWikis' Paragraph '': 2 children 'See the planned implementation: ' Link '': 1 children 'Extension:XML_Bridge/MWXHTML' Section '': 1 children Section '': 1 children ItemList '': 1 children Item '': 1 children ' Currently it seem impossible to correctly mark all uses of templates within the XML output.' Section '': 1 children ItemList '': 13 children Item '': 2 children Link '': 1 children 'Extension:Wiki2xml' ' (abandoned)' Item '': 2 children Link '': 1 children 'DocBook_XML_export' ' (never started)' Item '': 2 children Link '': 1 children 'Extension:Open_Office_Export' ' (abandoned)' Item '': 1 children Link '': 1 children 'Extension:Data Transfer' Item '': 1 children NamedURL 'http://cnx.org/help/CNXMLLanguage': 1 children ' Connexions XML Language' Item '': 1 children NamedURL 'http://ilps.science.uva.nl/WikiXML/xmlformat.php': 1 children ' WikiXML: XML format' Item '': 1 children NamedURL 'http://www.riehle.org/wp-content/uploads/2008/01/a5-junghans.pdf': 1 children ' An XML Interchange Format for Wiki Creole 1.0' Item '': 1 children NamedURL 'http://web.archive.org/web/20060704163408/doc-book.sourceforge.net/homepage/': 1 children ' DocBook Wiki' Item '': 1 children NamedURL 'http://meta.wikimedia.org/wiki/XHTML': 1 children ' about XHTML produced by MediaWiki' Item '': 2 children NamedURL 'http://meta.wikimedia.org/wiki/Wikitext_standard': 1 children ' Wikitext Standard' ' ... describe and formalize a 1.0 version of the Wikitext language, based on what is used currently. (last edit: 29 June 2007)' Item '': 4 children NamedURL 'http://www.usemod.com/cgi-bin/mb.pl?WikiMarkupStandard': 1 children ' WikiMarkup Standard' ' discusses ways to allow visitors from one wiki engine to edit pages on other wikis without having to learn their WikiSyntax. (last edit: May 10, 2008 '                Strong '': 1 children                     'active discussion'                 ')' Item '': 2 children NamedURL 'http://web.archive.org/web/20060716015316/http://hula-project.org/Wiki_Conversion': 1 children ' page collecting info on "wiki conversion"' ' (last modified 15:40, 21 Jun 2006.)' Item '': 1 children Strong '': 2 children Link '': 1 children 'Wikipedia DTD' ' (last real edit 9 April 2006)' Section '': 2 children ItemList '': 8 children Item '': 1 children NamedURL 'http://en.wikipedia.org/wiki/MediaWiki#Limitations': 1 children ' MediaWiki Limitations' Item '': 1 children Link '': 1 children 'Alternative parsers' Item '': 1 children NamedURL 'http://blogs.sun.com/lebo/entry/who_isn_t_using_a': 1 children ' Can you roundtrip OpenOffice.org to MediaWiki and back again?' Item '': 1 children URL 'http://code.pediapress.com/': 0 children Item '': 1 children NamedURL 'http://www.tbray.org/ongoing/When/200x/2006/01/08/No-New-XML-Languages': 1 children ' Don\u2019t Invent XML Languages' Item '': 1 children NamedURL 'http://www.codinghorror.com/blog/archives/001116.html': 1 children ' Is HTML a Humane Markup Language?' Item '': 1 children NamedURL 'http://freshmeat.net/projects/xmldiff/': 1 children ' XML Diff' Item '': 1 children Link '': 1 children 'WYSIWYG_editor' Paragraph '': 1 children CategoryLink '': 1 children 'Data_extraction_extensions' -->