diff --git a/src/main/java/com/xmlcalabash/util/S9apiUtils.java b/src/main/java/com/xmlcalabash/util/S9apiUtils.java index c15c49fc..3248e9ad 100644 --- a/src/main/java/com/xmlcalabash/util/S9apiUtils.java +++ b/src/main/java/com/xmlcalabash/util/S9apiUtils.java @@ -323,32 +323,20 @@ private static void removeNamespacesWriter(TreeWriter tree, XdmNode node, HashSe changed = changed || delete; - if (!delete) { + // Never put the xml namespace in the NamespaceMap + if (!delete && !"xml".equals(pfx)) { newNS.add(new NamespaceBinding(pfx, uri)); } } NodeInfo inode = node.getUnderlyingNode(); AttributeMap attrs = inode.attributes(); - ArrayList attrList = new ArrayList<> (); NodeName newName = NameOfNode.makeName(inode); if (!preserveUsed) { NamespaceBinding binding = newName.getNamespaceBinding(); if (excludeNS.contains(binding.getURI())) { newName = new FingerprintedQName("", "", newName.getLocalPart()); } - - // In this case, we may need to change some attributes too - for (AttributeInfo attr : attrs.asList()) { - String attrns = attr.getNodeName().getURI(); - if (excludeNS.contains(attrns)) { - FingerprintedQName newAttrName = new FingerprintedQName("", "", attr.getNodeName().getLocalPart()); - AttributeInfo newAttr = new AttributeInfo(newAttrName, attr.getType(), attr.getValue(), attr.getLocation(), attr.getProperties()); - attrList.add(newAttr); - } else { - attrList.add(attr); - } - } } tree.addStartElement(newName, attrs, inode.getSchemaType(), new NamespaceMap(newNS));