local stanza_mt = { __type = "stanza" };
stanza_mt.__index = stanza_mt;
- local function stanza(name, attr, namespaces)
-local function new_stanza(name, attr)
- local stanza = { name = name, attr = attr or {}, tags = {} };
++local function new_stanza(name, attr, namespaces)
+ local stanza = { name = name, attr = attr or {}, namespaces = namespaces, tags = {} };
return setmetatable(stanza, stanza_mt);
end
- local stanza = stanza;
function stanza_mt:query(xmlns)
return self:tag("query", { xmlns = xmlns });
return self:tag("body", attr):text(text);
end
-function stanza_mt:tag(name, attrs)
- local s = new_stanza(name, attrs);
+function stanza_mt:tag(name, attr, namespaces)
- local s = stanza(name, attr, namespaces);
++ local s = new_stanza(name, attr, namespaces);
local last_add = self.last_add;
if not last_add then last_add = {}; self.last_add = last_add; end
(last_add[#last_add] or self):add_direct_child(s);