From: Norman Walsh Date: Fri, 15 Nov 2002 14:04:17 +0000 (+0000) Subject: Updated driver to use docbook.py X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d66ca48470342bd7a3ad37d382072e1f4e332a02;p=docbook-dsssl Updated driver to use docbook.py --- diff --git a/xsl/extensions/xsltproc/python/xslt.py b/xsl/extensions/xsltproc/python/xslt.py index c3bb446b9..b593fa8d4 100644 --- a/xsl/extensions/xsltproc/python/xslt.py +++ b/xsl/extensions/xsltproc/python/xslt.py @@ -1,11 +1,12 @@ #!/usr/bin/python -u -# THIS IS PRE-ALPHA CODE AND DOES NOT WORK! +# THIS IS ALPHA CODE AND MAY NOT WORK CORRECTLY! import sys import string import libxml2 import libxslt +from docbook import adjustColumnWidths # Check the arguments @@ -44,58 +45,33 @@ try: except IndexError: pass -# Memory debug specific -libxml2.debugMemory(1) - -nodeName = None - -# ====================================================================== - -def adjustColumnWidths(ctx, nodeset): - global nodeName - - # - # Small check to verify the context is correcly accessed - # - try: - pctxt = libxslt.xpathParserContext(_obj=ctx) - ctxt = pctxt.context() - tctxt = ctxt.transformContext() - nodeName = tctxt.insertNode().name - node = tctxt.insertNode(); - except: - pass - - print "called with nodeset: " - print nodeset - print "name=" + nodeName - - return "" - # ====================================================================== +# Memory debug specific +# libxml2.debugMemory(1) +# Setup environment libxml2.lineNumbersDefault(1) libxml2.substituteEntitiesDefault(1) libxslt.registerExtModuleFunction("adjustColumnWidths", "http://nwalsh.com/xslt/ext/xsltproc/python/Table", adjustColumnWidths) - +# Initialize and run styledoc = libxml2.parseFile(xslfile) style = libxslt.parseStylesheetDoc(styledoc) - doc = libxml2.parseFile(xmlfile) - result = style.applyStylesheet(doc, params) +# Save the result style.saveResultToFilename(outfile, result, 0) +# Free things up style.freeStylesheet() doc.freeDoc() result.freeDoc() # Memory debug specific -libxslt.cleanup() -if libxml2.debugMemory(1) != 0: - print "Memory leak %d bytes" % (libxml2.debugMemory(1)) - libxml2.dumpMemory() +#libxslt.cleanup() +#if libxml2.debugMemory(1) != 0: +# print "Memory leak %d bytes" % (libxml2.debugMemory(1)) +# libxml2.dumpMemory()