source: tracxmlrender/trunk/docbook.py @ 47

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

Change env.get_config to env.config.get. Fixes #9.

File size: 592 bytes
Line 
1import trac.util
2import libxml2, libxslt
3
4def execute(hdf, text, env):
5    stylesheet = env.config.get('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.