cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/2] git commit: If namespaces are part of the Attributes, make sure they are written out first and then NOT duplicated as part of writing out the namespace mappings
Date Fri, 28 Mar 2014 17:38:08 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 974526c29 -> 92f88c0e6


If namespaces are part of the Attributes, make sure they are written out first and then NOT
duplicated as part of writing out the namespace mappings


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/96c43325
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/96c43325
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/96c43325

Branch: refs/heads/master
Commit: 96c433250744a47a58fb276cff303aa731a8172f
Parents: 974526c
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Mar 28 13:14:53 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Mar 28 13:14:53 2014 -0400

----------------------------------------------------------------------
 .../staxutils/StreamWriterContentHandler.java   | 36 +++++++++++++++-----
 1 file changed, 28 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/96c43325/core/src/main/java/org/apache/cxf/staxutils/StreamWriterContentHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/StreamWriterContentHandler.java b/core/src/main/java/org/apache/cxf/staxutils/StreamWriterContentHandler.java
index 6ef3bce..22266b3 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/StreamWriterContentHandler.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/StreamWriterContentHandler.java
@@ -215,6 +215,24 @@ public class StreamWriterContentHandler implements ContentHandler, LexicalHandle
             } else {
                 writer.writeStartElement(prefix, localName, namespaceURI);
             }
+            if (!mapping.isEmpty() && atts != null) {
+                int attCount = atts.getLength();
+                for (int i = 0; i < attCount; i++) {
+                    if (!StringUtils.isEmpty(atts.getURI(i))
+                        && atts.getQName(i).startsWith("xmlns")) {
+                        String pfx = atts.getQName(i);
+                        int idx = pfx.indexOf(':');
+                        if (idx == -1) {
+                            mapping.remove("");
+                            writer.writeDefaultNamespace(atts.getValue(i));
+                        } else {
+                            pfx = pfx.substring(idx + 1);
+                            mapping.remove(pfx);
+                            writer.writeNamespace(pfx, atts.getValue(i));
+                        }
+                    }
+                }
+            }
             for (Map.Entry<String, String> e : mapping.entrySet()) {
                 if ("".equals(e.getKey())) {
                     writer.writeDefaultNamespace(e.getValue());
@@ -235,16 +253,18 @@ public class StreamWriterContentHandler implements ContentHandler, LexicalHandle
                                               atts.getValue(i));
                     } else {
                         String pfx = atts.getQName(i);
-                        if (pfx.indexOf(':') != -1) {
-                            pfx = pfx.substring(0, pfx.indexOf(':'));
-                            writer.writeAttribute(pfx,
-                                                  atts.getURI(i),
+                        if (!pfx.startsWith("xmlns")) {
+                            if (pfx.indexOf(':') != -1) {
+                                pfx = pfx.substring(0, pfx.indexOf(':'));
+                                writer.writeAttribute(pfx,
+                                                      atts.getURI(i),
+                                                      atts.getLocalName(i),
+                                                      atts.getValue(i));
+                            } else {
+                                writer.writeAttribute(atts.getURI(i),
                                                   atts.getLocalName(i),
                                                   atts.getValue(i));
-                        } else {
-                            writer.writeAttribute(atts.getURI(i),
-                                              atts.getLocalName(i),
-                                              atts.getValue(i));
+                            }
                         }
                     }
                 }


Mime
View raw message