cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1211188 - /cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
Date Tue, 06 Dec 2011 21:51:54 GMT
Author: dkulp
Date: Tue Dec  6 21:51:54 2011
New Revision: 1211188

URL: http://svn.apache.org/viewvc?rev=1211188&view=rev
Log:
[CXF-3958] Make sure namespaces are properly written where they need to
be

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java?rev=1211188&r1=1211187&r2=1211188&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
Tue Dec  6 21:51:54 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.staxutils.transform;
 
+import java.util.Deque;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -38,7 +39,7 @@ public class OutTransformWriter extends 
     private QNamesMap elementsMap;
     private Map<QName, QName> appendMap = new HashMap<QName, QName>(5);
     private Map<String, String> nsMap = new HashMap<String, String>(5);
-    private Set<String> writtenUris = new HashSet<String>(2);
+    private Deque<Set<String>> writtenUris = new LinkedList<Set<String>>();
     
     private Set<QName> dropElements;
     private List<Integer> droppingIndexes = new LinkedList<Integer>();
@@ -77,7 +78,7 @@ public class OutTransformWriter extends 
         
         uri = value != null ? value : uri;
         
-        if (writtenUris.contains(uri)) {
+        if (writtenUris.getFirst().contains(uri)) {
             return;
         }
         
@@ -89,13 +90,19 @@ public class OutTransformWriter extends 
             }
             super.writeNamespace(prefix, uri);
         }
-        writtenUris.add(uri);
-        
+        writtenUris.getFirst().add(uri);
     }
     
     @Override
     public void writeStartElement(String prefix, String local, String uri) throws XMLStreamException
{
         currentDepth++;
+        Set<String> s;
+        if (writtenUris.isEmpty()) {
+            s = new HashSet<String>();
+        } else {
+            s = new HashSet<String>(writtenUris.getFirst());
+        }
+        writtenUris.addFirst(s);
         QName currentQName = new QName(uri, local);
         
         QName appendQName = appendMap.get(currentQName);
@@ -119,6 +126,9 @@ public class OutTransformWriter extends 
     
     @Override
     public void writeEndElement() throws XMLStreamException {
+        if (!writtenUris.isEmpty()) {
+            writtenUris.removeFirst();
+        }
         --currentDepth;
         if (indexRemoved(droppingIndexes)) {
             return;



Mime
View raw message