Hi all,

For those who are using DocBook XSL to generate HTML or XHTML content
you might be interested in the DocBook extension called
adjustColumnWidths.

This extension makes the table column width work in the generated HTML
output. Without this extension the width information is lost during
the transformation.

Refer to: http://www.sagehill.net/docbookxsl/ColumnWidths.html

To use the extension one must use Python and Python's libxml2 and
libxslt instead of xsltproc.exe to do the XSL transformation.

The code for that can be found in the file docbook-xsl-1.75.2/
extensions/xslt.py file but it needs some adjustment. I am using the
Python function processXslT below containing these adjustments to do
the XSLT transformation.

Regards

Henrik

-------------------------
import sys, libxml2, libxslt
DOCBOOK_XSL_DIR = 'c:\docbook\docbook-xsl-1.75.2'
xsltParams = {}

sys.path.append(os.path.join(DOCBOOK_XSL_DIR, 'extensions'))
from docbook import adjustColumnWidths


def processXslT(infile, xslfile, outfile):
    """Function borrowed from extension directory of DocBook XSL.
       Added XML_PARSE_NONET and PARSER_SUBST_ENTITIES flags.
       Added catalog file loading. APP_DIR is the local script
directory.
       DOCBOOK_XSL_DIR points to the DocBook XSL directory eg. /
docbook-xsl-1.75.2.
       Catalog directories must be absolute paths!
       adjustColumnWidths is only required for HTML output.
    """
    # Add catalog files
    libxml2.loadCatalog(os.path.join(DOCBOOK_XSL_DIR, 'catalog.xml'))

    # Setup environment
    libxml2.lineNumbersDefault(1)
    libxml2.substituteEntitiesDefault(1)

    # Run adjustColumnWidths extension
    # Refer to DocBookXSL-TheCompleteGuide/ColumnWidths.html
    xsltParams['use.extensions'] = "'1'"
    xsltParams['tablecolumns.extension'] = "'1'"
    libxslt.registerExtModuleFunction("adjustColumnWidths",
                                      "http://nwalsh.com/xslt/ext/
xsltproc/python/Table",
                                      adjustColumnWidths)

    # Initialize and run
    styledoc = libxml2.readFile(xslfile, None,
libxml2.XML_PARSE_NONET)
    style = libxslt.parseStylesheetDoc(styledoc)
    doc = libxml2.readFile(infile, None, libxml2.XML_PARSE_NONET |
libxml2.PARSER_SUBST_ENTITIES)
    result = style.applyStylesheet(doc, xsltParams)

    # Save the result
    if outfile:
        style.saveResultToFilename(outfile, result, 0)
    else:
        print result
        sys.exit(1)

    # Free things up
    style.freeStylesheet()
    doc.freeDoc()
    result.freeDoc()

------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/asciidoc?hl=en.

Reply via email to