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': {u'float': u'right', u'min-width': u'20%', u'background-color': u'white'}, u'class': u'ext-infobox ext-status-unstable'}: 4 children Caption '' {}: 4 children u' ' Strong '': 1 children Link '': 1 children u'Manual on MediaWiki Extensions' BreakingReturn u'br': 0 children Strong '': 1 children Link '': 1 children u'List of MediaWiki Extensions' Row '' {u'class': u'ext-header'}: 1 children Cell '' {u'colspan': 2, 'style': {u'padding-top': u'0.5em'}}: 5 children ImageLink '': 1 children u'Crystal Clear app error.png' Span u'span': 1 children u'XML Bridge' BreakingReturn u'br': 0 children u' Release status: unstable ' CategoryLink '': 1 children u'unstable extensions' Row '' {}: 2 children Cell '' {'style': {u'vertical-align': u'top'}}: 1 children SpecialLink '': 1 children Strong '': 1 children u'Description' Cell '' {}: 1 children u' Converts MediaWiki markup to XHTML ' Row '' {}: 2 children Cell '' {'style': {u'vertical-align': u'top'}}: 1 children SpecialLink '': 1 children Strong '': 1 children u'Download' Cell '' {}: 1 children URL u'http://code.pediapress.com/wiki/wiki/mwlib': 0 children Paragraph '': 1 children CategoryLink '': 1 children u'All extensions' Section '': 5 children Paragraph '': 1 children u"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 u'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 u'As much semantic information from the wiki source text as possible will be preserved by using XHTML features such as namespaces.' Paragraph '': 1 children u'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 u'Development is assigned to ' NamedURL u'http://pediapress.com': 1 children u' PediaPress' u' and funded by the ' NamedURL u'http://col.org': 1 children u' Commonwealth of Learning' Section '': 4 children Paragraph '': 5 children u'An initial alpha code release is available as part of the ' NamedURL u'http://code.pediapress.com': 1 children u' mwlib' u' python MediaWiki library. (see '            NamedURL u'http://code.pediapress.com/hg/mwlib/file/tip/mwlib/xhtmlwriter.py': 1 children                 u' xhtmlwriter.py'             u'). Feel free to use and comment on it.' Paragraph '': 1 children u'Although this code is still lacking some features it may be a good starting point to develop alternative XML output formats.' Paragraph '': 3 children u'There is a ' NamedURL u'http://groups.google.com/group/mwlib': 1 children u' google group' u' for support and discussion of mwlib and derived applications.' Paragraph '': 3 children u'See ' NamedURL u'http://code.pediapress.com/wiki/wiki/mwlib': 1 children u' this page for installation instructions' u'.' Section '': 5 children Paragraph '': 3 children u'The initial implementation is based on XHTML1.0 transitional extended by ' NamedURL u'http://en.wikipedia.org/wiki/Microformats': 1 children u' Microformats' u' where necessary. '        Paragraph '': 3 children u'This is to support the ' NamedURL u'http://meta.wikimedia.org/wiki/Help:HTML_in_wikitext': 1 children u' presentational HTML4.01 Elements allowed in wikitext' u' by MediaWiki.' Paragraph '': 1 children u'A future implementation could be based on XHTML1.1 strict plus MathML.' Paragraph '': 2 children u'You may want to have a look at the proposed XML-Format ' Link '': 1 children u'Extension:XML Bridge/MWXHTML' Paragraph '': 3 children u'The XML is generated based on the parse-tree generated by the ' NamedURL u'http://code.pediapress.com': 1 children u' mwlib' u' MediaWiki-markup parsing library.' Section '': 2 children Paragraph '': 5 children u'The xhtmlwriter.py is part of the ' NamedURL u'http://code.pediapress.com': 1 children u' mwlib python library' u'. See ' NamedURL u'http://code.pediapress.com': 1 children u' this page' u' for installation instructions.' Paragraph '': 1 children u'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 u'... 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 u'Steps toward this goal: ' ItemList '': 7 children Item '': 1 children u' initial release of XML-Exporter code ' Item '': 1 children u' develop XML-&gt;mw-markup converter so one can convert back and forth ' Item '': 1 children u' discuss and incrementally improve the xml-markup ' Item '': 1 children u' discuss whether usage of certain html-styling and template usage can be labeled deprecated' Item '': 1 children u' check edits and notify users if using wrong or deprecated markup ' Item '': 1 children u' fix or remove all broken/deprecated markup,html-styling,inappropriate template usage' Item '': 1 children u' switch to xml' Paragraph '': 0 children Section '': 5 children Section '': 1 children Paragraph '': 2 children NamedURL u'http://www.tbray.org/ongoing/When/200x/2006/01/08/No-New-XML-Languages': 1 children u' Don\u2019t Invent XML Languages' u' - at least for now.' Section '': 2 children Paragraph '': 1 children u'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 u'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 u'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 u'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 u'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 u'For e.g. a category-link could be written as:' Paragraph '': 1 children Source u'source': 1 children u'&lt;a href="Kategorie:Extensions" mwx:linktype="category"&gt;Extensions&lt;/a&gt;' Paragraph '': 2 children u'Other suitable namespaces can be included like ' NamedURL u'http://www.w3.org/Math/': 1 children u' MathML' Paragraph '': 1 children u'This still requires to invent and add a new XML-Language which is considered harmful(see above).' Section '': 4 children Paragraph '': 1 children u'Use Microformats to semantically annotate generated XHTML.' Paragraph '': 1 children Source u'source': 1 children u'\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 u'http://microformats.org/wiki?title=mediawiki-mark-up-issues&amp;redirect=no': 1 children u' Discussion on microformats in MediaWikis' Paragraph '': 2 children u'See the planned implementation: ' Link '': 1 children u'Extension:XML_Bridge/MWXHTML' Section '': 1 children Section '': 1 children ItemList '': 1 children Item '': 1 children u' 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 u'Extension:Wiki2xml' u' (abandoned)' Item '': 2 children Link '': 1 children u'DocBook_XML_export' u' (never started)' Item '': 2 children Link '': 1 children u'Extension:Open_Office_Export' u' (abandoned)' Item '': 1 children Link '': 1 children u'Extension:Data Transfer' Item '': 1 children NamedURL u'http://cnx.org/help/CNXMLLanguage': 1 children u' Connexions XML Language' Item '': 1 children NamedURL u'http://ilps.science.uva.nl/WikiXML/xmlformat.php': 1 children u' WikiXML: XML format' Item '': 1 children NamedURL u'http://www.riehle.org/wp-content/uploads/2008/01/a5-junghans.pdf': 1 children u' An XML Interchange Format for Wiki Creole 1.0' Item '': 1 children NamedURL u'http://web.archive.org/web/20060704163408/doc-book.sourceforge.net/homepage/': 1 children u' DocBook Wiki' Item '': 1 children NamedURL u'http://meta.wikimedia.org/wiki/XHTML': 1 children u' about XHTML produced by MediaWiki' Item '': 2 children NamedURL u'http://meta.wikimedia.org/wiki/Wikitext_standard': 1 children u' Wikitext Standard' u' ... 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 u'http://www.usemod.com/cgi-bin/mb.pl?WikiMarkupStandard': 1 children u' WikiMarkup Standard' u' 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                     u'active discussion'                 u')' Item '': 2 children NamedURL u'http://web.archive.org/web/20060716015316/http://hula-project.org/Wiki_Conversion': 1 children u' page collecting info on "wiki conversion"' u' (last modified 15:40, 21 Jun 2006.)' Item '': 1 children Strong '': 2 children Link '': 1 children u'Wikipedia DTD' u' (last real edit 9 April 2006)' Section '': 2 children ItemList '': 8 children Item '': 1 children NamedURL u'http://en.wikipedia.org/wiki/MediaWiki#Limitations': 1 children u' MediaWiki Limitations' Item '': 1 children Link '': 1 children u'Alternative parsers' Item '': 1 children NamedURL u'http://blogs.sun.com/lebo/entry/who_isn_t_using_a': 1 children u' Can you roundtrip OpenOffice.org to MediaWiki and back again?' Item '': 1 children URL u'http://code.pediapress.com/': 0 children Item '': 1 children NamedURL u'http://www.tbray.org/ongoing/When/200x/2006/01/08/No-New-XML-Languages': 1 children u' Don\u2019t Invent XML Languages' Item '': 1 children NamedURL u'http://www.codinghorror.com/blog/archives/001116.html': 1 children u' Is HTML a Humane Markup Language?' Item '': 1 children NamedURL u'http://freshmeat.net/projects/xmldiff/': 1 children u' XML Diff' Item '': 1 children Link '': 1 children u'WYSIWYG_editor' Paragraph '': 1 children CategoryLink '': 1 children u'Data_extraction_extensions' -->