Closed evandrofisico closed 3 years ago
It's just a printing issue, right?
Because the lua table will always have _attr
fields if the XML has tag attributes.
The generated table does have the _attr field, but it is moved and appears as a child node instead. So just reading a file, parsing it as a table and outputting it produces a different (and invalid) xml from the original. I believe the expected behavior would be that reading, parsing and outputting should produce the same data as the input, right? Attached are a sample program and xml file showing the behaviour. bug.tar.gz
You're right. I'll take a look at it. Thanks for reporting.
I used a smaller XML to make it easier to debug.
<?xml version="1.0"?>
<domain type="xen">
<on_crash>restart</on_crash>
<clock offset="utc" adjustment="reset"/>
<memory unit="KiB">16777216</memory>
</domain>
Indeed, it's just an issue with the xml2lua.toXml()
method.
Reading a existing XML file, parsing and outputting it sometimes still results in adding <_attr> instead of adding the attributes to the tag. Example: local xml = xml2lua.loadFile(xmlfile) local parser = xml2lua.parser(handler) parser:parse(xml) print(xml2lua.toXml(handler.root))
In the input XML:
In the output XML:
vm.xml.gz