cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1303011 - /cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Date Tue, 20 Mar 2012 17:14:31 GMT
Author: dkulp
Date: Tue Mar 20 17:14:31 2012
New Revision: 1303011

URL: http://svn.apache.org/viewvc?rev=1303011&view=rev
Log:
Merged revisions 1302997 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1302997 | dkulp | 2012-03-20 13:01:42 -0400 (Tue, 20 Mar 2012) | 2 lines

  [CXF-4183] Use our own DOM writer to avoid issues with Sun's.

........

Modified:
    cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java

Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=1303011&r1=1303010&r2=1303011&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Tue Mar 20 17:14:31 2012
@@ -52,6 +52,7 @@ import javax.xml.stream.events.StartElem
 import javax.xml.stream.events.XMLEvent;
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stream.StreamSource;
@@ -248,6 +249,19 @@ public final class StaxUtils {
     }
     
     public static XMLStreamWriter createXMLStreamWriter(Result r) {
+        if (r instanceof DOMResult) {
+            //use our own DOM writer to avoid issues with Sun's 
+            //version that doesn't support getNamespaceContext
+            DOMResult dr = (DOMResult)r;
+            Node nd = dr.getNode();
+            if (nd instanceof Document) {
+                return new W3CDOMStreamWriter((Document)nd);
+            } else if (nd instanceof Element) {
+                return new W3CDOMStreamWriter((Element)nd);
+            } else if (nd instanceof DocumentFragment) {
+                return new W3CDOMStreamWriter((DocumentFragment)nd);
+            }
+        }
         XMLOutputFactory factory = getXMLOutputFactory();
         try {
             return factory.createXMLStreamWriter(r);



Mime
View raw message