Problem with libxml2/libxlst

CinnamonDonkey cinnamondonkey at googlemail.com
Thu Jun 10 05:17:57 EDT 2010


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 <badthinghappening></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 '<' and '>'

Cheers
-Shaun



More information about the Python-list mailing list