You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/12/23 16:35:42 UTC
svn commit: r1896322 - /xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Saver.java
Author: fanningpj
Date: Thu Dec 23 16:35:41 2021
New Revision: 1896322
URL: http://svn.apache.org/viewvc?rev=1896322&view=rev
Log:
[XMLBEANS-583] try to not emit multiple namespace entries with the same prefix on the same element
Modified:
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Saver.java
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Saver.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Saver.java?rev=1896322&r1=1896321&r2=1896322&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Saver.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Saver.java Thu Dec 23 16:35:41 2021
@@ -538,7 +538,7 @@ abstract class Saver {
}
private void addNewFrameMapping(String prefix, String uri, boolean ensureDefaultEmpty) {
- // If the prefix maps to "", this don't include this mapping 'cause it's not well formed.
+ // If the prefix maps to "", then don't include this mapping 'cause it's not well formed.
// Also, if we want to make sure that the default namespace is always "", then check that
// here as well.
@@ -942,9 +942,22 @@ abstract class Saver {
}
private void emitNamespacesHelper() {
+ LinkedHashMap<String, String> nsMap = new LinkedHashMap<>();
for (iterateMappings(); hasMapping(); nextMapping()) {
+ String prefix = mappingPrefix();
+ String uri = mappingUri();
+ if (nsMap.containsKey(prefix)) {
+ //only overwrite the nsMap entry for the prefix if the stored entry has prefix="" and uri=""
+ if (prefix.length() == 0 && nsMap.get(prefix).length() == 0) {
+ nsMap.put(prefix, uri);
+ }
+ } else {
+ nsMap.put(prefix, uri);
+ }
+ }
+ for (Map.Entry<String, String> nsEntry : nsMap.entrySet()) {
emit(' ');
- emitXmlns(mappingPrefix(), mappingUri());
+ emitXmlns(nsEntry.getKey(), nsEntry.getValue());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org