[lxml-dev] Transform parameter variables

Niels Bjerre niels at bjerre.net
Tue Aug 5 16:50:14 CEST 2008


Stefan Behnel <stefan_ml <at> behnel.de> writes:

> 
> Hi,
> 
> it's good practice to
> 
> a) reply to the list,
> b) avoid top-posting and
> c) read what people post.
> 
> Niels Bjerre wrote:
> > Thank You for your response
> >
> > But I have problem with the_dict:
> > These 2 statements don't give the same result.
> >
> >    1. newdoc = transform(places.myplaces, area="'3751'")
> >    2. newdoc = transform(places.myplaces, {'area':'\"\'3751\'\"'})
> >
> > 1. is passed to xslt: <xsl:param name="area" select="'ost'"/>
> > 2. is ignored
> >
> > I have tried with
> > {'area':'\'3751\''} and others
> 
> The last line will work, but as I wrote before:
> 
> > 2008/7/28 Stefan Behnel <stefan_ml <at> behnel.de>
> >> You can pass more than one kayword parameter, as everywhere in Python.
> >> If you want to pass them from a dictionary, do the usual
> >>
> >>   result = transform(xml_tree, **the_dict)
> >>
> >> trick.
> 
> Note the two stars before "the_dict". This is standard Python syntax for
> expanding a mapping into keyword arguments.
> 
> Stefan
> 

I'm Sorry - still no luck passing a dictionary as extentions parameter
The stylesheet has a parameter: 
<xsl:param name="area" select="'ost'"/>

The parameter is picked up in the transformation if I use:
transform(doc, area="'3751'")
but not when I use the_dict 
transform(doc, {'area':'\"\'3751\'\"'}) or any other variant of a dictionary or
a dict_variable I can think of!

Any suggestions is most welcome

Niels





More information about the lxml-dev mailing list