[XML-SIG] 4xslt - passing parameters

Matt Gushee Matt Gushee <mgushee@havenrock.com>
Sat, 9 Nov 2002 22:31:53 -0700


On Sun, Nov 10, 2002 at 02:15:49PM +1100, Michael Hall wrote:
> 
> Anyway, I now have a working Python CGI script that will do most things I 
> need. I'm using PyXML, so I guess the XSLT processor is 4XSLT. The only thing 
> I can't determine (I'm reading 'Python & XML' by Jones and Drake) is whether 
> it is possible to pass parameters to an XSL stylesheet using 4XSLT in PyXML. I 
> need to pass one parameter (a page/section number) to an XSL stylesheet that 
> processes one large XML file and creates about 50 seperate HTML files from it.

Yes, you should be able to do that. How exactly are you invoking the
transformation? If you have a Processor instance proc, and you are calling,
e.g.
  
  proc.runStream(str)
  
then you can simply add the keyword argument topLevelParams with a
dictionary of parameters as its value. For example:

  result = proc.runStream(str, topLevelParams={'page': 27})

If that doesn't address your need, perhaps you could post a sample of
your code.

-- 
Matt Gushee                 When a nation follows the Way,
Englewood, Colorado, USA    Horses bear manure through
mgushee@havenrock.com           its fields;
http://www.havenrock.com/   When a nation ignores the Way,
                            Horses bear soldiers through
                                its streets.
                                
                            --Lao Tzu (Peter Merel, trans.)