import trac.util import libxml2, libxslt def execute(hdf, text, env): stylesheet = env.config.get('docbook', 'stylesheet') if not stylesheet: raise trac.util.TracError('DocBook stylesheet not configured.') else: style = libxslt.parseStylesheetDoc(libxml2.parseFile(stylesheet)) doc = libxml2.parseDoc(text) result = style.applyStylesheet(doc, None) html = style.saveResultToString(result) style.freeStylesheet() doc.freeDoc() result.freeDoc() return html[html.find('')+6:html.find('')].strip()