[XML-SIG] xslt/parameters

Daniel Veillard veillard at redhat.com
Sat Aug 14 11:17:12 CEST 2004

On Fri, Aug 13, 2004 at 09:49:20PM -0400, Matt Price wrote:
> Can someone out there tell me how I pass a parameter value to an xsl
> stylesheet in python?  Right now I have the following couple lines of
> code, more or less stolen from somewhere since I'm still pretty much at
> sea with xml:  
>     styledoc = libxml2.parseFile(xsl) 
>     style = libxslt.parseStylesheetDoc(styledoc) 
>     doc = libxml2.parseDoc(risxSet) 
>     result = style.applyStylesheet(doc, None) 
>     htmlString = style.saveResultToString(result) 
> xsl is of course a variable which references a stylesheet.  The
> stylesheet has a  parameter setting like this:
> <xsl: param name="mainTarget">http://localhost/refdb-client/index.py</xsl:param>
> I'd like to pass the parameter to the stylesheet in the above code.
> Can this be done in a straightforward way?  I get the impression I
> should use the class libxslt.xpathParserContext(), but I really don't
> understand how it's supposed to work!  I much appreciate any pointers.
> thanks,

  You're using libxml2/libxslt in that context, better as for help
in the right channel 

  the parameter to the transformation are passed as a dictionnary
to applyStylesheet(), instead of passing None, pass the dictionary
containing the (name, value) pairs for all parameters.


Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard at redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

More information about the XML-SIG mailing list