Software /
code /
prosody
Comparison
util/xmppstream.lua @ 4484:0da4e0f0f0ef
util.xmppstream: Optimize attribute processing.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Wed, 25 Jan 2012 11:54:12 +0500 |
parent | 4483:1dbd06eedaa4 |
child | 5311:86fe6e2fa5ae |
comparison
equal
deleted
inserted
replaced
4483:1dbd06eedaa4 | 4484:0da4e0f0f0ef |
---|---|
23 | 23 |
24 module "xmppstream" | 24 module "xmppstream" |
25 | 25 |
26 local new_parser = lxp.new; | 26 local new_parser = lxp.new; |
27 | 27 |
28 local ns_prefixes = { | 28 local xml_namespace = { |
29 ["http://www.w3.org/XML/1998/namespace"] = "xml"; | 29 ["http://www.w3.org/XML/1998/namespace\1lang"] = "xml:lang"; |
30 ["http://www.w3.org/XML/1998/namespace\1space"] = "xml:space"; | |
31 ["http://www.w3.org/XML/1998/namespace\1base"] = "xml:base"; | |
32 ["http://www.w3.org/XML/1998/namespace\1id"] = "xml:id"; | |
30 }; | 33 }; |
31 | 34 |
32 local xmlns_streams = "http://etherx.jabber.org/streams"; | 35 local xmlns_streams = "http://etherx.jabber.org/streams"; |
33 | 36 |
34 local ns_separator = "\1"; | 37 local ns_separator = "\1"; |
71 if curr_ns ~= stream_default_ns or non_streamns_depth > 0 then | 74 if curr_ns ~= stream_default_ns or non_streamns_depth > 0 then |
72 attr.xmlns = curr_ns; | 75 attr.xmlns = curr_ns; |
73 non_streamns_depth = non_streamns_depth + 1; | 76 non_streamns_depth = non_streamns_depth + 1; |
74 end | 77 end |
75 | 78 |
76 -- FIXME !!!!! | |
77 for i=1,#attr do | 79 for i=1,#attr do |
78 local k = attr[i]; | 80 local k = attr[i]; |
79 attr[i] = nil; | 81 attr[i] = nil; |
80 local ns, nm = k:match(ns_pattern); | 82 local xmlk = xml_namespace[k]; |
81 if nm ~= "" then | 83 if xmlk then |
82 ns = ns_prefixes[ns]; | 84 attr[xmlk] = attr[k]; |
83 if ns then | 85 attr[k] = nil; |
84 attr[ns..":"..nm] = attr[k]; | |
85 attr[k] = nil; | |
86 end | |
87 end | 86 end |
88 end | 87 end |
89 | 88 |
90 if not stanza then --if we are not currently inside a stanza | 89 if not stanza then --if we are not currently inside a stanza |
91 if session.notopen then | 90 if session.notopen then |