Closed groupmsl closed 4 years ago
I managed to fix this by specifying the ET.tostring() method uses HTML mode, rather than XML (https://lxml.de/api/lxml.etree-module.html#tostring)
So the code that works is as below (change in last line):
import lxml.etree as ET
dom = etree.parse("src/xsd/config.xsd")
xslt = etree.parse("dependencies/src/xsd2html2xml-3.3/xsd2html2xml.xsl")
transform = etree.XSLT(xslt)
newdom = transform(dom)
print(ET.tostring(newdom, method="html"))
Thanks!
Hello,
I'm trying to use this great library from Python using the lxml library (which is just bindings to the C libxml2 and libxslt libraries). The output is an HTML page with all of the components I'd expect but arranged very strangly. All of the components are shown on page load.
Running my XSD through the tool at https://www.linguadata.nl creates a good page (different from when I create it)
The code I'm using to generate this is very simple:
(Code from here: https://stackoverflow.com/questions/16698935/how-to-transform-an-xml-file-using-xslt-in-python)
I haven't modified
config.xsl
in any way.I've attached my XSD (which I know is far from perfect..I'm new!), the html from linguadata and html that I have generated.
I've seen other issues on this project where it was suggested that libxslt was supported and working with this library.
Does anyone know what I'm doing wrong?
Thanks!