You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2008/07/25 00:45:21 UTC
svn commit: r679597 - in /cxf/trunk/common/common/src:
main/java/org/apache/cxf/staxutils/StaxUtils.java
test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml
Author: bimargulies
Date: Thu Jul 24 15:45:21 2008
New Revision: 679597
URL: http://svn.apache.org/viewvc?rev=679597&view=rev
Log:
Write PIs out when copying DOM to Stax. This should make people happy
who want to put stylesheets into their WSDL files.
Added:
cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml (with props)
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=679597&r1=679596&r2=679597&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 Thu Jul 24 15:45:21 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;
@@ -443,8 +444,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/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=679597&r1=679596&r2=679597&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 Thu Jul 24 15:45:21 2008
@@ -221,5 +221,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'?>"));
+ }
}
Added: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml?rev=679597&view=auto
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml (added)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml Thu Jul 24 15:45:21 2008
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<?pi in='the sky'?>
+<?e excl='gads'?>
+<rootMaterialTest xmlns="urn:org.apache.cxf:test">
+This is text inside the root.
+</rootMaterialTest>
Propchange: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/resources/rootMaterialTest.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml