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
commitdd37beeff9f229dee36da04d625d5200b69f945c (patch)
tree92b42e2b3bb371b3273c61157e86d553f20700a6 /util/xml.lua
parentbb0ad8d2a9da64ab00fa01b047031e8256554e89 (diff)
downloadprosody-dd37beeff9f229dee36da04d625d5200b69f945c.tar.gz
prosody-dd37beeff9f229dee36da04d625d5200b69f945c.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);