News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Weaknesses in exportXml
Author Message
jpjacobs
Member
***


Posts: 113
Group: Registered
Joined: Jul 2007
Status: Offline
Reputation: 0
Post: #1
Weaknesses in exportXml

Hi!

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
end
return newTab
end

Greetz,

Jan-Pieter

This post was last modified: 04-30-2010 10:45 AM by jpjacobs.

04-30-2010 09:54 AM
Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #2
RE: Weaknesses in exportXml

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

Thanks for reporting

04-30-2010 08:00 PM
Visit this user's website Find all posts by this user Quote this message in a reply
jpjacobs
Member
***


Posts: 113
Group: Registered
Joined: Jul 2007
Status: Offline
Reputation: 0
Post: #3
RE: Weaknesses in exportXml

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>
</_t>
</LuaVariables>

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

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

so the empty tables a and b just disappear.

JP

05-01-2010 05:44 AM
Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #4
RE: Weaknesses in exportXml

This is fixed in the new RC ...

And you have the new functionality you requested.

10-13-2010 05:04 AM
Visit this user's website Find all posts by this user Quote this message in a reply
jpjacobs
Member
***


Posts: 113
Group: Registered
Joined: Jul 2007
Status: Offline
Reputation: 0
Post: #5
RE: Weaknesses in exportXml

Thanks a lot!

10-13-2010 06:14 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: