[python-win32] Properly encoded HTML from MSXML XLST processor into python string (via IStream) ?

Tim Roberts timr at probo.com
Mon Sep 10 23:05:21 CEST 2007


Andreas Neubauer wrote:
>
> Dear all,
> Using the Microsoft XML core services (MSXML 4.0) as an XSLT-processor
> for python
> i got into a trap when trying to generate properly unicode(UTF-8)
> encoded HTML:
>   The encoding statement gets lost in the HTML header, and
> white-spaces UTF-8: HEX code C2 A0 convert to A0.
>
> Testing and reading the Microsoft doku I found this working fine if
> the target output is of type IStream ...
> Can I somehow use a Microsoft IStream object or implement it in a
> suitable manner ?
> ...
>
> -----------------------------------------------------------------------------------
>
> If I use a custom output like this:
> -----------------------------------------------------------------------------------
>
>    xmlData=""
>    xslProc.transform()
>    xslProc.output(xmlData)
> -----------------------------------------------------------------------------------
>
> MSXML com object returns an error:
>   " Exception during xslt transformation: 'unicode' object is not
> callable "
>

"output" is a property, not a method.  That statement will fetch the
value of the property (a string) and try to call it like a function. 
You probably want this:
    xslProc.output = xmlData
but xmlData has to be something that supports IStream.  Python strings
do not.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list