aboutsummaryrefslogtreecommitdiffstats
path: root/util/datamapper.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/datamapper.lua')
-rw-r--r--util/datamapper.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/util/datamapper.lua b/util/datamapper.lua
index 65524279..a0c11166 100644
--- a/util/datamapper.lua
+++ b/util/datamapper.lua
@@ -1,5 +1,7 @@
local st = require("util.stanza");
+local schema_t = {}
+
local function toboolean(s)
if s == "true" or s == "1" then
return true
@@ -181,7 +183,7 @@ local function parse(schema, s)
end
end
-local function unparse(schema, t, current_name, current_ns)
+local function unparse(schema, t, current_name, current_ns, ctx)
if schema.xml then
if schema.xml.name then
@@ -193,7 +195,7 @@ local function unparse(schema, t, current_name, current_ns)
end
- local out = st.stanza(current_name, {xmlns = current_ns})
+ local out = ctx or st.stanza(current_name, {xmlns = current_ns})
if schema.type == "object" then
@@ -268,15 +270,13 @@ local function unparse(schema, t, current_name, current_ns)
out:add_direct_child(c);
end
elseif proptype == "array" and type(propschema) == "table" and type(v) == "table" then
- local c = unparse(propschema, v, name, namespace);
- if c then
- if value_where == "in_wrapper" then
- local w = st.stanza(propschema.xml.name or name, {xmlns = propschema.xml.namespace or namespace})
- w:add_direct_child(c);
- out:add_direct_child(w);
- else
+ if value_where == "in_wrapper" then
+ local c = unparse(propschema, v, name, namespace);
+ if c then
out:add_direct_child(c);
end
+ else
+ unparse(propschema, v, name, namespace, out);
end
else
error("NYI")