cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r690289 - in /cxf/trunk: api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java rt/testsupport/pom.xml tools/javato/ws/pom.xml
Date Fri, 29 Aug 2008 15:14:22 GMT
Author: dkulp
Date: Fri Aug 29 08:14:21 2008
New Revision: 690289

URL: http://svn.apache.org/viewvc?rev=690289&view=rev
Log:
[CXF-1769] Hack a workaround for a bug in JAXB
Fix a couple poms

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
    cxf/trunk/rt/testsupport/pom.xml
    cxf/trunk/tools/javato/ws/pom.xml

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java?rev=690289&r1=690288&r2=690289&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java Fri Aug
29 08:14:21 2008
@@ -35,6 +35,7 @@
 
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -55,6 +56,7 @@
     
     private Collection<DOMSource> schemas;
     private Map<String, String> namespaceMap;
+    private boolean hackAroundEmptyNamespaceIssue;
 
     public Collection<DOMSource> getSchemas() {
         return schemas;
@@ -68,12 +70,19 @@
                                           String systemId) {
         String ns = d.getDocumentElement().getAttribute("targetNamespace");
         if (StringUtils.isEmpty(ns)) {
+            if (DOMUtils.getFirstElement(d.getDocumentElement()) == null) {
+                hackAroundEmptyNamespaceIssue = true;
+                return null;
+            }
             //create a copy of the dom so we 
             //can modify it.
             d = copy(d);
             ns = serviceInfo.getInterface().getName().getNamespaceURI();
             d.getDocumentElement().setAttribute("targetNamespace", ns);
         }
+        if (hackAroundEmptyNamespaceIssue) {
+            d = doEmptyNamespaceHack(d);            
+        }
 
         Node n = d.getDocumentElement().getFirstChild();
         while (n != null) { 
@@ -96,6 +105,36 @@
         serviceInfo.addSchema(schema);
         return xmlSchema;
     }
+    private Document doEmptyNamespaceHack(Document d) {
+        boolean hasStuffToRemove = false;
+        Element el = DOMUtils.getFirstElement(d.getDocumentElement());
+        while (el != null) {
+            if ("import".equals(el.getLocalName())
+                && StringUtils.isEmpty(el.getAttribute("targetNamespace"))) {
+                hasStuffToRemove = true;
+                break;
+            }
+            el = DOMUtils.getNextElement(el);
+        }
+        if (hasStuffToRemove) {
+            //create a copy of the dom so we 
+            //can modify it.
+            d = copy(d);
+            el = DOMUtils.getFirstElement(d.getDocumentElement());
+            while (el != null) {
+                if ("import".equals(el.getLocalName())
+                    && StringUtils.isEmpty(el.getAttribute("targetNamespace"))) {
+                    d.getDocumentElement().removeChild(el);
+                    el = DOMUtils.getFirstElement(d.getDocumentElement());
+                } else {
+                    el = DOMUtils.getNextElement(el);
+                }
+            }
+        }
+            
+        return d;
+    }
+
     private Document copy(Document doc) {
         try {
             return StaxUtils.copy(doc);

Modified: cxf/trunk/rt/testsupport/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/testsupport/pom.xml?rev=690289&r1=690288&r2=690289&view=diff
==============================================================================
--- cxf/trunk/rt/testsupport/pom.xml (original)
+++ cxf/trunk/rt/testsupport/pom.xml Fri Aug 29 08:14:21 2008
@@ -11,7 +11,7 @@
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-parent</artifactId>
         <version>2.2-SNAPSHOT</version>
-        <relativePath>../parent/pom.xml</relativePath>
+        <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 
     <dependencies>

Modified: cxf/trunk/tools/javato/ws/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/pom.xml?rev=690289&r1=690288&r2=690289&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/pom.xml (original)
+++ cxf/trunk/tools/javato/ws/pom.xml Fri Aug 29 08:14:21 2008
@@ -29,7 +29,7 @@
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-parent</artifactId>
         <version>2.2-SNAPSHOT</version>
-        <relativePath>../../parent/pom.xml</relativePath>
+        <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 
     <dependencies>    



Mime
View raw message