-local xml_escape = xml_escape;
-
-local function dostring(t, buf, self, xml_escape)
- local nsid, ns, attrk = 0;
- t_insert(buf, "<");
- t_insert(buf, t.name);
- for k, v in pairs(t.attr) do if type(k) == "string" then
- t_insert(buf, " ");
- ns, attrk = s_match(k, "^([^|]+)|(.+)$");
- if ns then
- nsid = (nsid or -1) + 1;
- t_insert(buf, "xmlns:ns"..nsid);
- t_insert(buf, "='");
- t_insert(buf, (xml_escape(tostring(ns))));
- t_insert(buf, "' ");
- t_insert(buf, "ns"..nsid..":"..attrk);
+local function _dostring(t, buf, self, xml_escape)
+ local nsid = 0;
+ local name = t.name
+ t_insert(buf, "<"..name);
+ for k, v in pairs(t.attr) do
+ if s_find(k, "|", 1, true) then
+ local ns, attrk = s_match(k, "^([^|]+)|(.+)$");
+ nsid = nsid + 1;
+ t_insert(buf, " xmlns:ns"..nsid.."='"..xml_escape(ns).."' ".."ns"..nsid..":"..attrk.."='"..xml_escape(v).."'");