1 # Due to a shocking number of bugs and incompatibilities between PyXML and 4Suite,
2 # this actually seems to be the easiest way to convert a XML document to HTML!
5 from xml
.dom
.html
import HTMLDocument
6 from Ft
.Xml
.cDomlette
import implementation
7 from Ft
.Xml
.Xslt
.Processor
import Processor
8 from Ft
.Xml
import InputSource
9 doc
= implementation
.createDocument(None, 'root', None)
11 from cStringIO
import StringIO
13 # The HTML writer adds some header fields, so strip any existing ones out or we'll get
17 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:h="http://www.w3.org/1999/xhtml">
19 <xsl:output method="html"/>
21 <xsl:template match='/h:html/h:head/h:meta[@name="generator"]' priority='2'/>
22 <xsl:template match='/h:html/h:head/h:meta[@http-equiv="Content-Type"]'/>
24 <xsl:template match='@*|node()'>
26 <xsl:apply-templates select='@*'/>
27 <xsl:apply-templates/>
33 proc
.appendStylesheet(InputSource
.InputSource(stream
))
36 return proc
.runNode(doc
, None, ignorePis
= 1)