cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r680435 - in /cxf/trunk/common/common/src: main/java/org/apache/cxf/staxutils/StaxUtils.java test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
Date Mon, 28 Jul 2008 18:28:44 GMT
Author: bimargulies
Date: Mon Jul 28 11:28:43 2008
New Revision: 680435

URL: http://svn.apache.org/viewvc?rev=680435&view=rev
Log:
Suppress PIs from Stax document copies if we're not writing the prolog.

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=680435&r1=680434&r2=680435&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Mon Jul
28 11:28:43 2008
@@ -447,7 +447,10 @@
         NodeList rootChildren = d.getChildNodes();
         for (int rcx = 0; rcx < rootChildren.getLength(); rcx++) {
             Node rootChild = rootChildren.item(rcx);
-            writeNode(rootChild, writer, repairing);
+            // don't write PIs if we're not writing a prolog.
+            if (writeProlog || rootChild.getNodeType() == Node.ELEMENT_NODE) {
+                writeNode(rootChild, writer, repairing);
+            }
         }
 
         if (writeProlog) {

Modified: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java?rev=680435&r1=680434&r2=680435&view=diff
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java (original)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java Mon
Jul 28 11:28:43 2008
@@ -236,4 +236,19 @@
         assertTrue(output.contains("<?pi in='the sky'?>"));
         assertTrue(output.contains("<?e excl='gads'?>"));
     }
+    
+    @Test
+    public void testRootPInoProlog() 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, false, false);
+        swriter.flush();
+        swriter.close();
+        String output = sw.toString();
+        assertFalse(output.contains("<?pi in='the sky'?>"));
+        assertFalse(output.contains("<?e excl='gads'?>"));
+    }
 }



Mime
View raw message