cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r529375 - in /incubator/cxf/trunk: common/common/ common/common/src/main/java/org/apache/cxf/helpers/ common/common/src/main/java/org/apache/cxf/staxutils/ common/common/src/test/java/org/apache/cxf/staxutils/ integration/jbi/src/main/java/...
Date Mon, 16 Apr 2007 19:30:48 GMT
Author: dkulp
Date: Mon Apr 16 12:30:47 2007
New Revision: 529375

URL: http://svn.apache.org/viewvc?view=rev&rev=529375
Log:
Fix for CXF-536 (patch from Jeff Genender)


Added:
    incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/W3CDOMStreamReaderTest.java
  (with props)
Modified:
    incubator/cxf/trunk/common/common/pom.xml
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
    incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBIDestinationOutputStream.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/xml/DocumentType.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/jaxws/TypesGenerator.java
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java

Modified: incubator/cxf/trunk/common/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/pom.xml?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/common/common/pom.xml (original)
+++ incubator/cxf/trunk/common/common/pom.xml Mon Apr 16 12:30:47 2007
@@ -116,6 +116,17 @@
             <artifactId>wstx-asl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>com.sun.xml.messaging.saaj</groupId>
+            <artifactId>saaj-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-activation_1.1_spec</artifactId>
+            <scope>test</scope>
+        </dependency>
 
     </dependencies>
 

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java (original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java Mon
Apr 16 12:30:47 2007
@@ -59,6 +59,7 @@
     
     private static synchronized DocumentBuilder getBuilder() throws ParserConfigurationException
{
         if (builder == null) {
+            FACTORY.setNamespaceAware(true);
             builder = FACTORY.newDocumentBuilder();
         }
         return builder;

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Mon Apr 16 12:30:47 2007
@@ -19,7 +19,10 @@
 
 package org.apache.cxf.staxutils;
 
-import java.io.*;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
 import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
@@ -35,11 +38,23 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.dom.DOMSource;
 
-import org.w3c.dom.*;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+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;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.XMLUtils;
 
+
 public final class StaxUtils {
 
     private static final Logger LOG = Logger.getLogger(StaxUtils.class.getName());
@@ -278,8 +293,7 @@
 
         // Write out the element name
         if (uri != null) {
-            if (prefix.length() == 0) {
-
+            if (prefix.length() == 0 && StringUtils.isEmpty(uri)) {
                 writer.writeStartElement(local);
                 writer.setDefaultNamespace(uri);
 

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
Mon Apr 16 12:30:47 2007
@@ -312,6 +312,16 @@
     }
 
     public String getNamespaceURI() {
+        String ln = getCurrentElement().getLocalName();
+        if (ln == null) {
+            ln = getCurrentElement().getNodeName();
+            if (ln.indexOf(":") == -1) {
+                ln = getNamespaceURI("");
+            } else {
+                ln = getNamespaceURI(ln.substring(0, ln.indexOf(":")));
+            }
+            return ln;
+        }
         return getCurrentElement().getNamespaceURI();
     }
 

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
Mon Apr 16 12:30:47 2007
@@ -42,7 +42,9 @@
     private Map properties = Collections.EMPTY_MAP;
 
     public W3CDOMStreamWriter() throws ParserConfigurationException {
-        this(DocumentBuilderFactory.newInstance().newDocumentBuilder());
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        document = factory.newDocumentBuilder().newDocument();
     }
 
     public W3CDOMStreamWriter(DocumentBuilder builder) {

Added: incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/W3CDOMStreamReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/W3CDOMStreamReaderTest.java?view=auto&rev=529375
==============================================================================
--- incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/W3CDOMStreamReaderTest.java
(added)
+++ incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/W3CDOMStreamReaderTest.java
Mon Apr 16 12:30:47 2007
@@ -0,0 +1,75 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.staxutils;
+
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+
+import com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl;
+import com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl;
+import com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl;
+
+import org.apache.cxf.helpers.XMLUtils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class W3CDOMStreamReaderTest extends Assert {
+    
+    private static final String RESULT = 
+        "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+        + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+        + "<SOAP-ENV:Header/><SOAP-ENV:Body/>"
+        + "<Test xmlns=\"http://example.org/types\">"
+        + "<argument>foobar</argument></Test></SOAP-ENV:Envelope>";
+
+    @Test
+    public void testReader() throws Exception {
+        ByteArrayInputStream is = new ByteArrayInputStream(
+                "<Test xmlns=\"http://example.org/types\"><argument>foobar</argument></Test>".getBytes());
+        DocumentBuilderFactory docBuilderFactory =
+                DocumentBuilderFactory.newInstance();
+        docBuilderFactory.setNamespaceAware(true);
+        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+
+        SOAPMessageFactory1_1Impl factory = new SOAPMessageFactory1_1Impl();
+        Message1_1Impl msg = (Message1_1Impl)factory.createMessage();
+        SOAPPart1_1Impl part = new SOAPPart1_1Impl(msg);
+
+        Document doc = docBuilder.parse(is);
+
+        W3CDOMStreamWriter writer = new W3CDOMStreamWriter(part.getEnvelope());
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(new DOMSource(doc));
+
+
+        StaxUtils.copy(reader, writer);
+        assertEquals(RESULT, XMLUtils.toString(writer.getDocument()));
+
+    }
+
+}
\ No newline at end of file

Propchange: incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/W3CDOMStreamReaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/W3CDOMStreamReaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBIDestinationOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBIDestinationOutputStream.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBIDestinationOutputStream.java
(original)
+++ incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBIDestinationOutputStream.java
Mon Apr 16 12:30:47 2007
@@ -77,6 +77,7 @@
                 LOG.finest(new org.apache.cxf.common.i18n.Message(
                     "BUILDING.DOCUMENT", LOG).toString());
                 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+                docBuilderFactory.setNamespaceAware(true);
                 DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
                 Document doc = builder.parse(bais);
             

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
Mon Apr 16 12:30:47 2007
@@ -93,8 +93,9 @@
                 try {
                     Element detail = fault.getDetail(); 
                     if (detail == null) {
-                        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
-                            .newDocument();
+                        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+                        factory.setNamespaceAware(true);
+                        Document doc = factory.newDocumentBuilder().newDocument();
                         Element stackTrace = doc.createElementNS(Soap11.SOAP_NAMESPACE, Fault.STACKTRACE);
                         stackTrace.setTextContent(sb.toString());
                         detail = doc.createElementNS(Soap11.SOAP_NAMESPACE, "detail");

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/xml/DocumentType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/xml/DocumentType.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/xml/DocumentType.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/xml/DocumentType.java
Mon Apr 16 12:30:47 2007
@@ -46,6 +46,7 @@
 
     public DocumentType() {
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
         try {
             builder = factory.newDocumentBuilder();
         } catch (ParserConfigurationException e) {

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
Mon Apr 16 12:30:47 2007
@@ -93,7 +93,9 @@
         Document resultDoc = null;
 
         try {
-            resultDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            factory.setNamespaceAware(true);
+            resultDoc = factory.newDocumentBuilder().newDocument();
         } catch (Exception ex) {
             LOG.log(Level.SEVERE, "FAIL_CREATE_DOM_MSG");
         }

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/jaxws/TypesGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/jaxws/TypesGenerator.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/jaxws/TypesGenerator.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/jaxws/TypesGenerator.java
Mon Apr 16 12:30:47 2007
@@ -86,7 +86,9 @@
                                                                          "schema"));
 
             DocumentBuilder docBuilder;
-            docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            factory.setNamespaceAware(true);
+            docBuilder = factory.newDocumentBuilder();
             Document doc = docBuilder.newDocument();
             Element element = doc.createElement("xsd:schema");
             Map<String, String> schemafileMap = wmodel.getSchemaNSFileMap();

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java?view=diff&rev=529375&r1=529374&r2=529375
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
Mon Apr 16 12:30:47 2007
@@ -45,6 +45,7 @@
     public Document getDocument(XMLEventReader xmlEventReader) throws ToolException {
 
         DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+        builderFactory.setNamespaceAware(true);
         DocumentBuilder builder = null;
         try {
             builder = builderFactory.newDocumentBuilder();



Mime
View raw message