Fix for namespaced attributes

Since we only store them by prefix right now (boo!) at least keep the
prefix definition as well.

(cherry picked from commit a770c7d60ab14d03d5569df4fa56d2cfb1e4661f)
This commit is contained in:
Stephen Paul Weber 2024-05-21 13:45:09 -05:00 committed by Arne
parent 5f15e851fa
commit baa7b50263

View file

@ -73,6 +73,12 @@ public class XmlReader implements Closeable {
}
tag.setAttribute(name,parser.getAttributeValue(i));
}
int nsStart = parser.getNamespaceCount(parser.getDepth()-1);
int nsEnd = parser.getNamespaceCount(parser.getDepth());
for (int i = nsStart; i < nsEnd; i++) {
final var prefix = parser.getNamespacePrefix(i);
tag.setAttribute("xmlns" + (prefix == null ? "" : ":" + prefix), parser.getNamespaceUri(i));
}
if (xmlns != null) {
tag.setAttribute("xmlns", xmlns);
}