Software /
code /
prosody
Comparison
core/xmlhandlers.lua @ 2493:ec09d16a51e1
xmlhandlers: Rearranged a little code.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 23 Jan 2010 18:41:20 +0500 |
parent | 2492:b5e2d1919ec3 |
child | 2505:0849e349992d |
comparison
equal
deleted
inserted
replaced
2492:b5e2d1919ec3 | 2493:ec09d16a51e1 |
---|---|
114 function xml_handlers:EndElement(tagname) | 114 function xml_handlers:EndElement(tagname) |
115 local curr_ns,name = tagname:match(ns_pattern); | 115 local curr_ns,name = tagname:match(ns_pattern); |
116 if name == "" then | 116 if name == "" then |
117 curr_ns, name = "", curr_ns; | 117 curr_ns, name = "", curr_ns; |
118 end | 118 end |
119 if not stanza then | 119 if stanza then |
120 if #chardata > 0 then | |
121 -- We have some character data in the buffer | |
122 stanza:text(t_concat(chardata)); | |
123 chardata = {}; | |
124 end | |
125 -- Complete stanza | |
126 if #stanza.last_add == 0 then | |
127 if tagname ~= stream_error_tag then | |
128 cb_handlestanza(session, stanza); | |
129 else | |
130 cb_error(session, "stream-error", stanza); | |
131 end | |
132 stanza = nil; | |
133 else | |
134 stanza:up(); | |
135 end | |
136 else | |
120 if tagname == stream_tag then | 137 if tagname == stream_tag then |
121 if cb_streamclosed then | 138 if cb_streamclosed then |
122 cb_streamclosed(session); | 139 cb_streamclosed(session); |
123 end | 140 end |
124 else | 141 else |
125 cb_error(session, "parse-error", "unexpected-element-close", name); | 142 cb_error(session, "parse-error", "unexpected-element-close", name); |
126 end | 143 end |
127 stanza, chardata = nil, {}; | 144 stanza, chardata = nil, {}; |
128 return; | |
129 end | |
130 if #chardata > 0 then | |
131 -- We have some character data in the buffer | |
132 stanza:text(t_concat(chardata)); | |
133 chardata = {}; | |
134 end | |
135 -- Complete stanza | |
136 if #stanza.last_add == 0 then | |
137 if tagname ~= stream_error_tag then | |
138 cb_handlestanza(session, stanza); | |
139 else | |
140 cb_error(session, "stream-error", stanza); | |
141 end | |
142 stanza = nil; | |
143 else | |
144 stanza:up(); | |
145 end | 145 end |
146 end | 146 end |
147 return xml_handlers; | 147 return xml_handlers; |
148 end | 148 end |
149 | 149 |