You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/08/05 23:31:24 UTC

svn commit: r682961 - in /cxf/branches/2.0.x-fixes: ./ common/common/src/main/java/org/apache/cxf/staxutils/ common/common/src/test/java/org/apache/cxf/staxutils/ common/common/src/test/java/org/apache/cxf/staxutils/resources/

Author: dkulp
Date: Tue Aug  5 14:31:22 2008
New Revision: 682961

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

........
  r679597 | bimargulies | 2008-07-24 18:45:21 -0400 (Thu, 24 Jul 2008) | 3 lines
  
  Write PIs out when copying DOM to Stax. This should make people happy 
  who want to put stylesheets into their WSDL files.
........

Added:
    cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml
      - copied unchanged from r679597, cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml
Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug  5 14:31:22 2008
@@ -1 +1 @@
-/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248
+/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248,679597

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

Modified: cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=682961&r1=682960&r2=682961&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Tue Aug  5 14:31:22 2008
@@ -57,6 +57,7 @@
 import org.w3c.dom.EntityReference;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 import org.w3c.dom.ProcessingInstruction;
 import org.w3c.dom.Text;
 
@@ -437,8 +438,11 @@
             writer.writeStartDocument();
         }
 
-        Element root = d.getDocumentElement();
-        writeElement(root, writer, repairing);
+        NodeList rootChildren = d.getChildNodes();
+        for (int rcx = 0; rcx < rootChildren.getLength(); rcx++) {
+            Node rootChild = rootChildren.item(rcx);
+            writeNode(rootChild, writer, repairing);
+        }
 
         if (writeProlog) {
             writer.writeEndDocument();

Modified: cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java?rev=682961&r1=682960&r2=682961&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java (original)
+++ cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java Tue Aug  5 14:31:22 2008
@@ -217,5 +217,19 @@
         output = XMLUtils.toString(domwriter.getDocument().getDocumentElement());
         assertEquals(orig, output);
     }
-
+    
+    @Test
+    public void testRootPI() throws Exception {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        Document doc = dbf.newDocumentBuilder().parse(getTestStream("./resources/rootMaterialTest.xml"));
+        StringWriter sw = new StringWriter();
+        XMLStreamWriter swriter = StaxUtils.createXMLStreamWriter(sw);
+        StaxUtils.writeDocument(doc, swriter, true, false);
+        swriter.flush();
+        swriter.close();
+        String output = sw.toString();
+        assertTrue(output.contains("<?pi in='the sky'?>"));
+        assertTrue(output.contains("<?e excl='gads'?>"));
+    }
 }