Example for setting (multiple) parameters in Python LXML XSLT
Question: Looked for the solution to this problem for a while since [the
documentation](http://lxml.de/xpathxslt.html#xslt) isn't really clear on it.

I ended up using the method below, and thought I'd share back.


Answer: Apparently you can [chain parameter
arguments](https://docs.python.org/2/tutorial/controlflow.html#keyword-
arguments) when applying the XSLT to the original xml tree. I found the most
reliable way is to always use the _tree.XSLT.strparam()_ method for wrapping
the argument values. Not really needed I guess for simpler types like string
or integers. But this method works regardless.

    
    
    <xsl:stylesheet version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <xsl:output method="xml" omit-xml-declaration="no"/>
       <xsl:param name="var1"/>
       <xsl:param name="var2"/>
       <!-- actual sheet omitted because example -->
    </xsl:stylesheet>
    
    
    
    from lxml import etree
    
    var = "variable string"
    
    original_tree = etree.parse("original.xml")
    xslt_tree = etree.parse("transform.xsl")
    xslt = etree.XSLT(xslt_tree)
    lom_tree = xslt(original_tree, var1=etree.XSLT.strparam("str_example"), var2=etree.XSLT.strparam(var))
    
    print(etree.tostring(lom_tree, pretty_print=True))
    

