aboutsummaryrefslogtreecommitdiffstats
path: root/util/xml.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-12-08 23:15:42 +0000
committerMatthew Wild <mwild1@gmail.com>2015-12-08 23:15:42 +0000
commit60a27e378108dfaf2cfec678eaed357f79ced051 (patch)
tree92b42e2b3bb371b3273c61157e86d553f20700a6 /util/xml.lua
parentc4c602c47ff1aebd6475729fb9c2ac52c8d60034 (diff)
downloadprosody-60a27e378108dfaf2cfec678eaed357f79ced051.tar.gz
prosody-60a27e378108dfaf2cfec678eaed357f79ced051.zip
util.stanza, util.xml, util.xmppstream: Add support for tracking defined namespaces and their prefix (stanza.namespaces), knowing/preserving prefix names is required for some applications (thanks daurnimator)
Diffstat (limited to 'util/xml.lua')
-rw-r--r--util/xml.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/util/xml.lua b/util/xml.lua
index 733d821a..9e12f0df 100644
--- a/util/xml.lua
+++ b/util/xml.lua
@@ -14,6 +14,17 @@ local parse_xml = (function()
--luacheck: ignore 212/self
local handler = {};
local stanza = st.stanza("root");
+ local namespaces = {}
+ function handler:StartNamespaceDecl(prefix, url)
+ if prefix ~= nil then
+ namespaces[prefix] = url
+ end
+ end
+ function handler:EndNamespaceDecl(prefix)
+ if prefix ~= nil then
+ namespaces[prefix] = nil
+ end
+ end
function handler:StartElement(tagname, attr)
local curr_ns,name = tagname:match(ns_pattern);
if name == "" then
@@ -34,7 +45,11 @@ local parse_xml = (function()
end
end
end
- stanza:tag(name, attr);
+ local n = {}
+ for prefix, url in pairs(namespaces) do
+ n[prefix] = url
+ end
+ stanza:tag(name, attr, n);
end
function handler:CharacterData(data)
stanza:text(data);