Open chrisaga opened 1 year ago
I couldn't reproduce the behavior.
Use this lua table to achieve the xml result.
local xml2lua = require("xml2lua")
local tagtable = { tag = { tag1 = { [1] = 'A', [2] = 'B' } } }
print(xml2lua.toXml(tagtable))
<tag>
<tag1>A</tag1>
<tag1>B</tag1>
</tag>
I have a similar bug:
local initstr = [[<grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="pl-PL" version="1.0" root="transcribe">
<meta name="model" content="default"/>
<tag name="language000" content="pl-PL"/>
<rule id="transcribe">
<one-of>
<item>item1</item>
<item>item2</item>
</one-of>
</rule>
</grammar>]]
xmlParser:parse(initstr)
print(initstr)
print("===")
print(xml2lua.toXml(xmlHandler.root))
so I try to load xml and the convert it back to xml, the response I get is:
<grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="pl-PL" version="1.0" root="transcribe">
<meta name="model" content="default"/>
<tag name="language000" content="pl-PL"/>
<rule id="transcribe">
<one-of>
<item>item1</item>
<item>item2</item>
</one-of>
</rule>
</grammar>
===
<grammar root="transcribe" xmlns="http://www.w3.org/2001/06/grammar" version="1.0" xml:lang="pl-PL">
<rule id="transcribe">
<one-of>
<item>
<item>item1</item>
<item>item2</item>
</item>
</one-of>
</rule>
<meta content="default" name="model">
</meta>
<tag content="pl-PL" name="language000">
</tag>
</grammar>
as you see one-of
part looks in a different way:
<one-of>
<item>
<item>item1</item>
<item>item2</item>
</item>
</one-of>
instead of this
<one-of>
<item>item1</item>
<item>item2</item>
</one-of>
UPD: I found out this problem happening on v.1.5-2 (the latest version that is currently available on luarocks
)
Everything is working correctly on v.1.5-1 version. I'm not sure about v.1.6-1 as it is not available yet (for today) in luarocks
@mbabloapifonica
Use case : create a lua table and convert it to XML with duplicated tags
based on
xml2lua/example3.lua
we could expect :would give :
but it gives insead :
The easyest way to test it is to append the following line at the end of
xml2lua/example3.lua
(select the 3rd test by uncommenting line 18) :