Skip to content

Commit 71d45aa

Browse files
committed
[bugfix] Make sure the null namespace of elements is correctly reset in the DOM Serializer
1 parent 4fa7119 commit 71d45aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

exist-core/src/main/java/org/exist/util/serializer/DOMSerializer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import java.util.Map;
5151
import java.util.Properties;
5252

53+
import javax.annotation.Nullable;
5354
import javax.xml.XMLConstants;
5455
import javax.xml.transform.TransformerException;
5556

@@ -124,7 +125,8 @@ protected void startNode(Node node) throws TransformerException {
124125
if (prefix == null) {
125126
prefix = XMLConstants.DEFAULT_NS_PREFIX;
126127
}
127-
if (nsSupport.getURI(prefix) == null) {
128+
@Nullable String prevNsForPrefix = nsSupport.getURI(prefix);
129+
if (prevNsForPrefix == null || !prevNsForPrefix.equals(uri)) {
128130
namespaceDecls.put(prefix, uri);
129131
nsSupport.declarePrefix(prefix, uri);
130132
}
@@ -155,7 +157,8 @@ protected void startNode(Node node) throws TransformerException {
155157
if (prefix == null){
156158
prefix = attrName.split(":")[0];
157159
}
158-
if (nsSupport.getURI(prefix) == null) {
160+
prevNsForPrefix = nsSupport.getURI(prefix);
161+
if (prevNsForPrefix == null || !prevNsForPrefix.equals(uri)) {
159162
namespaceDecls.put(prefix, uri);
160163
nsSupport.declarePrefix(prefix, uri);
161164
}

0 commit comments

Comments
 (0)