[XML-SIG] 4xslt - passing parameters

Uche Ogbuji uche.ogbuji@fourthought.com
Mon, 11 Nov 2002 00:08:54 -0700


> > 
> > 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})
> 
> I'm not sure if this works, though it might (let me know if it does). 
> The problem is that the key in the dictionary must contain the namespace
> of the variable as well.  So assuming the variable is referenced as
> "$page" then the dictionary that is passed in must be:
> 
>   {('','page'),27}

No.  You don't have to pass in a namespace.  BTW, your example is wrong in 
either case because the empty namespace is None, not '' (I suggest always 
using xml.dom.EMPTY_NAMESPACE.

Anyway, Just as XSLT standard parameters default to no namespace if no prefix 
is used, so do 4XSLT's from the command line.

It has always been this way.


-- 
Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Python&XML column: 2. Introducing PyXML - http://www.xml.com/pub/a/2002/09/25/py.html
The Past, Present and Future of Web Services 1 - http://www.webservices.org/index.php/article/articleview/663/1/24/
The Past, Present and Future of Web Services 2 - 'http://www.webservices.org/index.php/article/articleview/679/1/24/
Serenity through markup - http://adtmag.com/article.asp?id=6807
Tip: Using generators for XML processing - http://www-106.ibm.com/developerworks/xml/library/x-tipgenr.html