From 9b85cdb610eb4050764821c2f9bce07b8d84a53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Sat, 23 Dec 2023 11:55:31 +0100 Subject: [PATCH] Don't serialize namespaced attributes into XML --- luamml-xmlwriter.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/luamml-xmlwriter.lua b/luamml-xmlwriter.lua index 78a692c..a2b5abe 100644 --- a/luamml-xmlwriter.lua +++ b/luamml-xmlwriter.lua @@ -20,9 +20,12 @@ local function write_elem(tree, indent) if not tree[0] then print('ERR', require'inspect'(tree)) end local escaped_name = escape_name(assert(tree[0])) local i = 0 - for attr, val in next, tree do if type(attr) == 'string' and string.byte(attr) ~= 0x3A then - i = i + 1 - attrs[i] = string.format(' %s="%s"', escape_name(attr), escape_text(val)) + for attr, val in next, tree do if type(attr) == 'string' then + if not string.find(attr, ':', 1, true) then + -- if string.byte(attr) ~= 0x3A then + i = i + 1 + attrs[i] = string.format(' %s="%s"', escape_name(attr), escape_text(val)) + end end end table.sort(attrs) local out = string.format('%s<%s%s', indent or '', escaped_name, table.concat(attrs))