Murga-Projects Forums

Full Version: Weaknesses in exportXml
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Found out some weaknesses in exportXml
* it does not support io.stdout or io.stderr. Besides it would be nice to be able to export to a xml-string to, for example to insert XSL/DTD/... stuff, and not having to read it out of the file again

* It doesn't take care of keys with spaces in the tables, the first word will appear as the tag, the following ones as attributes. As a side effect this borkes the reading in by loadFromXml() as it gets <word1 word2 ...>...</word1 word2> as tags.
As a temporary workaround, replaces spaces in keys with __ :

function prepTable (tab,unprep)
local newTab={}
local pat = unprep and '__' or '%s+'
local rep = unprep and ' ' or '__'
for k,v in pairs(tab) do
newTab[(k:gsub(pat,rep))]= type(v)=="table" and prepTable(v,unprep) or v
return newTab


On the list to fix for this weekend release ...

Thanks for reporting
Found out another flaw in loadFromXml(): it doesn't load empty tables from the xml-file like in this one:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<LuaVariables luaType="5">
<_t luaType="5">
<_a luaType="5" />
<_b luaType="5" />
<_c luaType="4">boegawoega</_c>

after loading this, I get this from murgaLua.debug.printTable():

[t] => table
[c] => boegawoega

so the empty tables a and b just disappear.

This is fixed in the new RC ...

And you have the new functionality you requested.
Thanks a lot!
Reference URL's