Author: dkulp
Date: Tue Aug 5 14:32:27 2008
New Revision: 682962
URL: http://svn.apache.org/viewvc?rev=682962&view=rev
Log:
Merged revisions 680435 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r680435 | bimargulies | 2008-07-28 14:28:43 -0400 (Mon, 28 Jul 2008) | 2 lines
Suppress PIs from Stax document copies if we're not writing the prolog.
........
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:32:27 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,679597
+/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,680435
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=682962&r1=682961&r2=682962&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:32:27 2008
@@ -441,7 +441,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/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=682962&r1=682961&r2=682962&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:32:27 2008
@@ -232,4 +232,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'?>"));
+ }
}