XML Pages & XSLT Processing

If you have Python4Suite installed in your system, it is possible to save XML documents as pages. It's important to start those pages with an XML declaration "<?xml ...>" in the very first line. Also, you have to specify the stylesheet that is to be used to process the XML document to HTML. This is done using a standard "xml-stylesheet" processing instruction, with the name of a page containing the stylesheet as the "href" parameter.

Do no forget to enable XSLT processing, see HelpOnConfiguration.

See the following example for details, which can also be found on the XsltVersion page.

Example

<?xml version="1.0" encoding="ISO-8859-1"?>

<?xml-stylesheet href="XsltVersion" type="text/xml"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:output method="html" omit-xml-declaration="yes" indent="no"/>

   <xsl:template match="/">
     This Wiki is running an XSLT engine by
     <xsl:value-of select="system-property('xsl:vendor')"/>
     (<a href="{system-property('xsl:vendor-url')}"><xsl:value-of select="system-property('xsl:vendor-url')"/></a>)
     implementing XSLT v<xsl:value-of select="system-property('xsl:version')"/>
   </xsl:template>

</xsl:stylesheet>

Rendering DocBook

In order to let MoinMoin render DocBook pages, you will need to follow the steps described below. Afterwards, you will be able to write DocBook files in MoinMoin and see them as rendered HTML. Note that rendering DocBook pages may take some seconds of processing time (this is done after the page is saved).

Installing the DocBook support

  1. Install 4suite and enable XSLT processing, see above.
  2. Go to DocBook files at SourceForge and download the latest archive. It contains the XSLT files necessary for HTML generation.

  3. Extract the archive and copy the whole directory html into another directory that is writable to MoinMoin (e.g. the data directory).

    • After you have upgraded 4suite, you have to delete the file db_compiled.dat in this directory.

  4. Edit your wiki configuration, the attribute docbook_html_dir has to point to the directory (which contains e.g. the file docbook.xsl) you created in the last step.

  5. You should be able to use the DocBook parser now.

Using DocBook

Just write your DocBook file like you would have done in a different environment as well. If you want to insert links to other wiki pages, be sure to simply write the WikiName into the text. Note that pages that would need ["..."] links in ordinary wiki markup cannot be linked to directly, yet.

DocBook markup is either marked by #format docbook in the first line of the page or in a wiki page like this: --> -->

ExpatError

syntax error: line 2, column 0

If you want to report a bug, please save this page and attach it to your bug report.

Traceback

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

  1. /opt/moinmoin/built/moin/MoinMoin/request.py in run (self=<MoinMoin.request.RequestFastCGI object>)

    1. 1209 self.page.send_page(self, msg=msg)
    2. 1210 else:
    3. 1211 handler(self.page.page_name, self)
    4. 1212
    5. 1213 # generate page footer (actions that do not want this footer use
    • handler = <function do_show>
    • self = <MoinMoin.request.RequestFastCGI object>
    • self.page = <MoinMoin.Page.Page instance>
    • self.page.page_name = u'HelpOnXmlPages'
  2. /opt/moinmoin/built/moin/MoinMoin/wikiaction.py in do_show (pagename=u'HelpOnXmlPages', request=<MoinMoin.request.RequestFastCGI object>)

    1. 466 else:
    2. 467 request.cacheable = 1
    3. 468 Page(request, pagename).send_page(request, count_hit=1)
    4. 469
    5. 470
    • global Page = <class MoinMoin.Page.Page>
    • request = <MoinMoin.request.RequestFastCGI object>
    • pagename = u'HelpOnXmlPages'
    • ).send_page undefined
    • count_hit undefined
  3. /opt/moinmoin/built/moin/MoinMoin/Page.py in send_page (self=<MoinMoin.Page.Page instance>, request=<MoinMoin.request.RequestFastCGI object>, msg='', **keywords={'count_hit': 1})

    1. 1254 format_args=pi_formatargs,
    2. 1255 do_cache=do_cache,
    3. 1256 start_line=pi_lines)
    4. 1257
    5. 1258 # check for pending footnotes
    • start_line undefined
    • pi_lines = 7
  4. /opt/moinmoin/built/moin/MoinMoin/Page.py in send_page_content (self=<MoinMoin.Page.Page instance>, request=<MoinMoin.request.RequestFastCGI object>, Parser=<class MoinMoin.parser.wiki.Parser>, body=u'\n[[TableOfContents(1)]]\n\n= XML Pages & XSLT Proc... like described above to make this example work.\n', format_args=u'', do_cache=1, **kw={'start_line': 7})

    1. 1345 try:
    2. 1346 code = self.loadCache(request)
    3. 1347 self.execute(request, parser, code)
    4. 1348 except Exception, e:
    5. 1349 if not is_cache_exception(e):
    • self = <MoinMoin.Page.Page instance>
    • self.execute = <bound method Page.execute of <MoinMoin.Page.Page instance>>
    • request = <MoinMoin.request.RequestFastCGI object>
    • parser = <MoinMoin.parser.wiki.Parser instance>
    • code = <code object ? at 0xf5553460, file "HelpOnXmlPages", line 2>
  5. /opt/moinmoin/built/moin/MoinMoin/Page.py in execute (self=<MoinMoin.Page.Page instance>, request=<MoinMoin.request.RequestFastCGI object>, parser=<MoinMoin.parser.wiki.Parser instance>, code=<code object ? at 0xf5553460, file "HelpOnXmlPages", line 2>)

    1. 1374 __file__ = os.path.join(MoinMoin.__loader__.archive, 'dummy')
    2. 1375 try:
    3. 1376 exec code
    4. 1377 except 'CacheNeedsUpdate':
    5. 1378 raise Exception('CacheNeedsUpdate')
    • code = <code object ? at 0xf5553460, file "HelpOnXmlPages", line 2>
  6. /opt/moinmoin-ic/config/site/HelpOnXmlPages in ?

  7. /opt/moinmoin/built/moin/MoinMoin/formatter/base.py in processor (self=<MoinMoin.formatter.text_html.Formatter instance>, processor_name=u'docbook', lines=[u'<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML...w.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">', u'<book>', u'<bookinfo>', u'<author>', u'<firstname>Bernd</firstname>', u'<surname>Le Pain</surname>', u'</author>', u'<copyright>', u'<year>2005</year>', u'</copyright>', u'</bookinfo>', u'<chapter>', u'<title>This is a title of a chapter</title>', u'<sect1>', u'<title>This is a title of a section</title>', u'<para>This is a paragraph.</para>', u'<para>', u'<emphasis role="bold">', u'This is a paragraph in bold.', u'</emphasis>', ...], is_parser=1)

    1. 315 lines = lines[1:]
    2. 316 p = parser('\n'.join(lines), self.request, format_args=args)
    3. 317 p.format(self)
    4. 318 del p
    5. 319 return ''
    • p = <moindocbook.parsers.xalan.XalanDocbookParser instance>
    • p.format = <bound method XalanDocbookParser.format of <moindocbook.parsers.xalan.XalanDocbookParser instance>>
    • self = <MoinMoin.formatter.text_html.Formatter instance>
  8. /opt/moinmoin/built/moin/moindocbook/parsers/xalan.py in format (self=<moindocbook.parsers.xalan.XalanDocbookParser instance>, formatter=<MoinMoin.formatter.text_html.Formatter instance>)

    1. 461
    2. 462 try:
    3. 463 self._format(formatter)
    4. 464 except:
    5. 465 if not gen_locked and os.path.exists(gen_lockfile):
    • self = <moindocbook.parsers.xalan.XalanDocbookParser instance>
    • self._format = <bound method XalanDocbookParser._format of <moindocbook.parsers.xalan.XalanDocbookParser instance>>
    • formatter = <MoinMoin.formatter.text_html.Formatter instance>
  9. /opt/moinmoin/built/moin/moindocbook/parsers/xalan.py in _format (self=<moindocbook.parsers.xalan.XalanDocbookParser instance>, formatter=<MoinMoin.formatter.text_html.Formatter instance>)

    1. 559 check_newer_xincludes = False
    2. 560 if not self.pagelist:
    3. 561 self.pagelist = self.getXIncludeDocuments(self.formatter.page.page_name)
    4. 562
    5. 563 for pn in self.pagelist:
    • self = <moindocbook.parsers.xalan.XalanDocbookParser instance>
    • self.pagelist = None
    • self.getXIncludeDocuments = <bound method XalanDocbookParser.getXIncludeDocu...cbook.parsers.xalan.XalanDocbookParser instance>>
    • self.formatter = <MoinMoin.formatter.text_html.Formatter instance>
    • self.formatter.page = <MoinMoin.Page.Page instance>
    • self.formatter.page.page_name = u'HelpOnXmlPages'
  10. /opt/moinmoin/built/moin/moindocbook/parsers/xalan.py in getXIncludeDocuments (self=<moindocbook.parsers.xalan.XalanDocbookParser instance>, page_name=u'HelpOnXmlPages', pagelist=[u'HelpOnXmlPages'])

    1. 429 p = xml.parsers.expat.ParserCreate('UTF-8', ' ')
    2. 430 p.StartElementHandler = start_element
    3. 431 p.Parse(newraw)
    4. 432
    5. 433 # resolve names
    • p = <pyexpat.xmlparser object>
    • p.Parse = <built-in method Parse of pyexpat.xmlparser object>
    • newraw = '\n[[TableOfContents(1)]]\n\n= XML Pages & XSLT Proc... like described above to make this example work.\n'

ExpatError

syntax error: line 2, column 0

  • args = ('syntax error: line 2, column 0',)
  • code = 2
  • lineno = 2
  • offset = 0

System Details

  • Date: Sun, 20 May 2012 04:41:56 +0000
  • Platform: Linux osnv.client.reno.sqi 2.6.24-23-xen #1 SMP Wed Apr 1 23:47:10 UTC 2009 x86_64
  • Python: Python 2.4.4c1 (/opt/moinmoin-ic/config/site/)
  • MoinMoin: Release 1.5.8 (release)