[XML-SIG] using xslt with python

Paul Tremblay phthenry at earthlink.net
Sat Jun 14 21:06:43 EDT 2003

On Sat, Jun 14, 2003 at 03:14:32AM -0400, Paul Tremblay wrote:
> On Thu, Jun 12, 2003 at 07:40:26PM -0400, Daniel Veillard wrote:
> Could you pleae give me an example of how to pass params using the
> bindings? I have tried in vain for an hour.

Okay, I finally got it about 3:00 am last night. I found the answer in
the section of your tutorial on writing your own extensions. This is
what I have:

    def __transform_xmllint(self, file, xsl_file, output, params = {}):
        import libxml2
        import libxslt

        new_params = {}
        keys = params.keys()
        for key in keys:
            new_params[key] = '"%s"' % params[key]
        params = new_params

        xml_doc = file
        # parse stylesheet
        styledoc = libxml2.parseFile(xsl_file)
        style = libxslt.parseStylesheetDoc(styledoc)
        # parse doc
        doc = libxml2.parseFile(xml_doc)
        result = style.applyStylesheet(doc, params)
        style.saveResultToFilename(output, result, 0)

Would it be possible for you to make this more explicit in your
otherwise very clear tutorial? I was unclear on two things:

1. where to pass the params option

2. the form of the params option. Now I realize it is a dictionary. You
wrote that you have to escape the value in the dictinary pair, but
escaping can mean different things to different people. (For example,

Thaks for your efforts



*Paul Tremblay         *
*phthenry at earthlink.net*

More information about the XML-SIG mailing list