From: CinnamonDonkey on
Hi All,

I could not find a dedicated libxml2/libxlst group so I thought I
would see if anyone here could help.

I have a system which captures the stdout from various sources and
writes it into a generic xml file. This file then needs to be
transformed to get the correct html format for rendering in a
webserver.

I am using the following code to perform the translation:

styledoc = libxml2.parseFile('stdout.xsl')
style = libxslt.parseStylesheetDoc(styledoc)

doc = libxml2.parseFile('stdout.xml')
result = style.applyStylesheet(doc, None)

style.saveResultToFilename('stdout.html'), result, 0)

style.freeStylesheet()
doc.freeDoc()
result.freeDoc()

Given the following stdout.xml sample:

<report>
<stdout>some app spew...</stdout>
<stdout>laa laaa laa...</stdout>
<stdout>something interesting &lt;badthinghappening&gt;</stdout>
</report>

It seems that the resultant 'stdout.html' file shows the final stdout
message translated too:

<stdout>something interesting <badthinghappening></stdout>

which of course results in a badly formed file with a missing tag :(

How do I get libxml2/libxlst to not touch the '&lt;' and '&gt;'

Cheers
-Shaun
From: CinnamonDonkey on
My mistake! *doh*

I had an 'disable-output-escape="YES"' when it should have been "NO".

-Shaun

On 10 June, 10:17, CinnamonDonkey <cinnamondon...(a)googlemail.com>
wrote:
> Hi All,
>
> I could not find a dedicated libxml2/libxlst group so I thought I
> would see if anyone here could help.
>
> I have a system which captures the stdout from various sources and
> writes it into a generic xml file. This file then needs to be
> transformed to get the correct html format for rendering in a
> webserver.
>
> I am using the following code to perform the translation:
>
>   styledoc = libxml2.parseFile('stdout.xsl')
>   style = libxslt.parseStylesheetDoc(styledoc)
>
>   doc = libxml2.parseFile('stdout.xml')
>   result = style.applyStylesheet(doc, None)
>
>   style.saveResultToFilename('stdout.html'), result, 0)
>
>   style.freeStylesheet()
>   doc.freeDoc()
>   result.freeDoc()
>
> Given the following stdout.xml sample:
>
> <report>
>   <stdout>some app spew...</stdout>
>   <stdout>laa laaa laa...</stdout>
>   <stdout>something interesting &lt;badthinghappening&gt;</stdout>
> </report>
>
> It seems that the resultant 'stdout.html' file shows the final stdout
> message translated too:
>
>   <stdout>something interesting <badthinghappening></stdout>
>
> which of course results in a badly formed file with a missing tag :(
>
> How do I get libxml2/libxlst to not touch the '&lt;' and '&gt;'
>
> Cheers
> -Shaun

From: Stephen Hansen on
On 6/10/10 7:47 AM, CinnamonDonkey wrote:
> My mistake! *doh*
>
> I had an 'disable-output-escape="YES"' when it should have been "NO".
>
> -Shaun
>

Eeeeven though you figured out your problem: have you checked out lxml?
Its extremely capable and ISTM much easier to use then whatever direct
wrapper you seem to be using.

Check out: http://codespeak.net/lxml/xpathxslt.html#xslt

--

Stephen Hansen
... me+list/python (AT) ixokai (DOT) io

 | 
Pages: 1
Prev: regarding the dimensions in gui
Next: gui related