Re: [lxml-dev] Transform parameter variables
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@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
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
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!
Try transform(doc, **{'area':"3751"}) Note the two stars, read up on python syntax on function calling and keyword parameters. -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
<jholg <at> gmx.de> writes:
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 parameterThe 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 ora dict_variable I can think of!
Try
transform(doc, **{'area':"3751"})
Note the two stars, read up on python syntax on function calling and keyword parameters.
-- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal
für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
_______________________________________________ lxml-dev mailing list lxml-dev <at> codespeak.net http://codespeak.net/mailman/listinfo/lxml-dev
Resolved! Thank You
participants (3)
-
jholg@gmx.de
-
Niels Bjerre
-
Stefan Behnel