source: tracxmlrender/trunk/docbook.py @ 4

Last change on this file since 4 was 4, checked in by simon, 19 years ago

Initial import of Trac XML wiki processor (or a quickly hacked Docbook
processor).

File size: 592 bytes
Line 
1import trac.util
2import libxml2, libxslt
3
4def execute(hdf, text, env):
5    stylesheet = env.get_config('docbook', 'stylesheet')
6    if not stylesheet:
7        raise trac.util.TracError('DocBook stylesheet not configured.')
8    else:
9        style = libxslt.parseStylesheetDoc(libxml2.parseFile(stylesheet))
10        doc = libxml2.parseDoc(text)
11        result = style.applyStylesheet(doc, None)
12        html = style.saveResultToString(result)
13        style.freeStylesheet()
14        doc.freeDoc()
15        result.freeDoc()
16        return html[html.find('<body>')+6:html.find('</body>')].strip()
Note: See TracBrowser for help on using the repository browser.