cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1399344 - in /cxf/branches/2.6.x-fixes: ./ api/src/main/java/org/apache/cxf/staxutils/transform/ api/src/test/java/org/apache/cxf/staxutils/transform/
Date Wed, 17 Oct 2012 16:57:13 GMT
Author: ay
Date: Wed Oct 17 16:57:12 2012
New Revision: 1399344

URL: http://svn.apache.org/viewvc?rev=1399344&view=rev
Log:
Merged revisions 1398860 via  svn merge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1398860 | ay | 2012-10-16 17:55:50 +0200 (Tue, 16 Oct 2012) | 1 line
  
  [CXF-4566] StaxTransformFeature outTransformElements does not work when coverting namespaces
........

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
    cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java?rev=1399344&r1=1399343&r2=1399344&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
Wed Oct 17 16:57:12 2012
@@ -82,7 +82,9 @@ class DelegatingNamespaceContext impleme
             }
         }
         String ns = nc.getNamespaceURI(prefix);
-        addPrefix(prefix, ns);
+        if (ns != null) {
+            addPrefix(prefix, ns);
+        }
         return ns;
     }
 
@@ -100,7 +102,9 @@ class DelegatingNamespaceContext impleme
             return prefixes.get(0).get(actualNs);
         }
         String prefix = nc.getPrefix(actualNs);
-        addPrefix(prefix, actualNs);
+        if (prefix != null) {
+            addPrefix(prefix, actualNs);
+        }
         return prefix;
     }
 

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java?rev=1399344&r1=1399343&r2=1399344&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
Wed Oct 17 16:57:12 2012
@@ -306,6 +306,8 @@ public class InTransformReader extends D
         String actualNs = nsMap.get(ns);
         if (actualNs != null) {
             return actualNs;
+        } else if (ns.equals(reader.getNamespaceURI())) {
+            return getNamespaceURI();
         } else {
             return ns;
         }
@@ -320,6 +322,8 @@ public class InTransformReader extends D
             } else {
                 return "";
             }
+        } else if (ns.equals(reader.getNamespaceURI())) {
+            return getPrefix();
         } else {
             return namespaceContext.getPrefix(ns);
         }

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java?rev=1399344&r1=1399343&r2=1399344&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
Wed Oct 17 16:57:12 2012
@@ -49,6 +49,7 @@ public class OutTransformWriter extends 
     private Set<QName> dropElements;
     private Stack<List<ParsingEvent>> pushedAheadEvents = new Stack<List<ParsingEvent>>();
     private Stack<QName> elementsStack = new Stack<QName>();
+    private String replaceNamespace;
     private String replaceText;
     private int currentDepth;
     private int dropDepth;
@@ -95,7 +96,8 @@ public class OutTransformWriter extends 
             return;
         }
         String value = nsMap.get(uri);
-        if (value != null && value.length() == 0) {
+        if ((value != null && value.length() == 0)
+            || uri.equals(replaceNamespace)) {
             return;
         }
         
@@ -108,11 +110,13 @@ public class OutTransformWriter extends 
         
         if (defaultNamespace != null && defaultNamespace.equals(uri)) {
             super.writeDefaultNamespace(uri);
+            namespaceContext.addPrefix("", uri);
         } else {
             if (prefix.length() == 0) {
                 prefix = namespaceContext.findUniquePrefix(uri);
             }
             super.writeNamespace(prefix, uri);
+            namespaceContext.addPrefix(prefix, uri);
         }
         writtenUris.get(0).add(uri);
     }
@@ -125,7 +129,8 @@ public class OutTransformWriter extends 
         }
         String value = nsMap.get(uri);
         if ((value != null && value.length() == 0) 
-            || (isDefaultNamespaceRedefined() && !isDefaultNamespaceRedefined(uri)))
{
+            || (isDefaultNamespaceRedefined() && !isDefaultNamespaceRedefined(uri))
+            || uri.equals(replaceNamespace)) {
             return;
         }
         
@@ -135,7 +140,7 @@ public class OutTransformWriter extends 
             return;
         }
         super.writeDefaultNamespace(uri);
-
+        namespaceContext.addPrefix("", uri);
         writtenUris.get(0).add(uri);
     }
 
@@ -252,6 +257,8 @@ public class OutTransformWriter extends 
         }
         pushedAheadEvents.push(pe);
         elementsStack.push(expected);
+        replaceNamespace = expected.getNamespaceURI().equals(theName.getNamespaceURI()) 
+            ? null : theName.getNamespaceURI();
 
         if (appendProp != null && !replaceContent && appendProp.isChild())
{
             // ap-post-*
@@ -360,16 +367,15 @@ public class OutTransformWriter extends 
                 }
             } else {
                 prefix = qname.getPrefix();
-                namespaceContext.addPrefix(prefix, qname.getNamespaceURI());    
             }
             
-        }
+        } 
         if (isDefaultNamespaceRedefined(qname.getNamespaceURI())) {
             prefix = "";
         }
-        
         super.writeStartElement(prefix, qname.getLocalPart(), qname.getNamespaceURI());
-        if (writeNs) {
+        if (writeNs 
+            || !qname.getNamespaceURI().equals(namespaceContext.getNamespaceURI(prefix)))
{
             this.writeNamespace(prefix, qname.getNamespaceURI());
         }
     }

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java?rev=1399344&r1=1399343&r2=1399344&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
Wed Oct 17 16:57:12 2012
@@ -97,7 +97,8 @@ public final class TransformUtils {
                 QName lname = XMLUtils.convertStringToQName(entry.getKey());
                 QName rname = XMLUtils.convertStringToQName(entry.getValue());
                 elementsMap.put(lname, rname);
-                if (nsMap != null && !isEmptyQName(rname)) {
+                if (nsMap != null && !isEmptyQName(rname)
+                    && ("*".equals(lname.getLocalPart()) && "*".equals(rname.getLocalPart())))
{
                     nsMap.put(lname.getNamespaceURI(), rname.getNamespaceURI());
                 }
             }

Modified: cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java?rev=1399344&r1=1399343&r2=1399344&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java
Wed Oct 17 16:57:12 2012
@@ -115,9 +115,9 @@ public class OutTransformWriterTest exte
         String xmlPI = "<?xml version='1.0' encoding='UTF-8'?>";
         String start = "<testBean xmlns=\"http://testbeans.com/v2\"";
         String expected1 = xmlPI + start
-            + " xmlns:ps2=\"http://testbeans.com/v3\"><ps2:bean/></testBean>";
+            + " xmlns:ps1=\"http://testbeans.com/v3\"><ps1:bean/></testBean>";
         String expected2 = xmlPI + start
-            + "><ps2:bean xmlns:ps2=\"http://testbeans.com/v3\"/></testBean>";
+            + "><ps1:bean xmlns:ps1=\"http://testbeans.com/v3\"/></testBean>";
         String out = os.toString();
         assertTrue("Output \"" + out + "\" does not match expected values",
                 expected1.equals(out) || expected2.equals(out));



Mime
View raw message