redirecting cgi error to browser

Brian Quinlan brian at sweetapp.com
Mon Nov 18 16:02:54 EST 2002


Barghest wrote:

> import Pyana
> def formatRef():
>     return "Hello <b> %s </b>" % 'foo'
> ...
> Pyana.installGlobalExtension( 'pyNS', formatRef, 'formatRef' )
> data = Pyana.transform2String( source = readData( "fichier.xml" ),
style =
> readData( "test3.xsl" ) )

> => Hello <b> foo </b>

> Just a simple question.
> Why all my tags returned from my functions are always converted to
> entities ?? How can I obtain "Hello <b> foo </b>"  ?

Sorry for the delayed reply but I just found this post today.

The problem is that you are returning a string from your extension
function. So the XSLT processor is going its job and converting into a
safe XML string. 

What you probably want to return is a result tree fragment.
Unfortunately, Pyana does not currently support extension functions
returning result tree fragments.

In the example that you gave, you could modify your XSL and extension
function to get the results that you expect:


test3.xsl
---------

...
Hello
<b><xsl:value-of select="formatRef()"/></b>
...

test.py
-------

...
def formatRef():
    return 'foo'
...

Of course, you may not be able to do what you want to do in a
non-trivial example. 

If this is really hurting your development, let me know and I might be
able to help you devise a work-around.

Cheers,
Brian






More information about the Python-list mailing list