cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r677607 - in /cxf/trunk/rt/databinding/xmlbeans/src: main/java/org/apache/cxf/xmlbeans/ test/java/org/apache/cxf/xmlbeans/ test/xsd/
Date Thu, 17 Jul 2008 15:20:31 GMT
Author: dkulp
Date: Thu Jul 17 08:20:30 2008
New Revision: 677607

URL: http://svn.apache.org/viewvc?rev=677607&view=rev
Log:
[CXF-1700] Add support for xsd:include to xmlbeans databinding

Added:
    cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/included.xsd   (with props)
    cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/sample.xsd   (with props)
Modified:
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
    cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/MultipleSchemaInNSTest.java
    cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TestService.java

Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java?rev=677607&r1=677606&r2=677607&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
Thu Jul 17 08:20:30 2008
@@ -37,6 +37,8 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.xml.sax.InputSource;
+
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
@@ -48,6 +50,7 @@
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.resolver.URIResolver;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.SchemaTypeSystem;
 import org.apache.xmlbeans.XmlAnySimpleType;
@@ -58,6 +61,8 @@
  * Walks the service model and sets up the element/type names.
  */
 class XmlBeansSchemaInitializer extends ServiceModelVisitor {
+
+
     private static final Logger LOG = LogUtils.getLogger(XmlBeansSchemaInitializer.class);
     private static final Map<Class<?>, Class<? extends XmlAnySimpleType>>
CLASS_MAP 
         = new HashMap<Class<?>, Class<? extends XmlAnySimpleType>>();
@@ -97,6 +102,20 @@
         dataBinding = db;
     }
     
+    public class XMLSchemaResolver implements URIResolver {
+        final SchemaTypeSystem sts;
+        public XMLSchemaResolver(SchemaTypeSystem sts) {
+            this.sts = sts;
+        }
+        
+        public InputSource resolveEntity(String targetNamespace, String schemaLocation, String
baseUri) {
+            InputStream ins = sts.getSourceAsStream(schemaLocation);
+            if (ins != null) {
+                return new InputSource(ins);
+            }
+            return null;
+        }
+    }
 
     XmlSchema getSchema(SchemaTypeSystem sts, String file) {
         if (schemaMap.containsKey(file)) {
@@ -122,7 +141,6 @@
                     }
                 }
             }            
-            
             XmlSchema schema = dataBinding.addSchemaDocument(serviceInfo,
                                                              schemas, 
                                                              doc, 
@@ -177,6 +195,8 @@
             part.setProperty(SchemaType.class.getName(), st);
             
             SchemaTypeSystem sts = st.getTypeSystem();
+            schemas.getXmlSchemaCollection().setSchemaResolver(new XMLSchemaResolver(sts));
+
             XmlSchema schema = getSchema(sts, st.getSourceName());
 
             if (st.isDocumentType()) {
@@ -195,8 +215,10 @@
                 part.setXmlSchema(sct);
                 part.setElement(false);
             }
+        } catch (RuntimeException ex) {
+            throw ex;
         } catch (Exception ex) {
-            ex.printStackTrace();
+            throw new RuntimeException(ex);
         }        
     }
     

Modified: cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/MultipleSchemaInNSTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/MultipleSchemaInNSTest.java?rev=677607&r1=677606&r2=677607&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/MultipleSchemaInNSTest.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/MultipleSchemaInNSTest.java
Thu Jul 17 08:20:30 2008
@@ -24,6 +24,7 @@
 import org.w3c.dom.NodeList;
 
 import org.apache.cxf.common.util.SOAPConstants;
+import org.apache.cxf.helpers.XMLUtils;
 import org.junit.Before;
 import org.junit.Test;
   
@@ -51,7 +52,7 @@
 
         addNamespace("xsd", SOAPConstants.XSD);
         NodeList list = assertValid("//xsd:schema[@targetNamespace='" + ns + "']", wsdl);
-        assertEquals(3, list.getLength());
+        assertEquals(XMLUtils.toString(wsdl), 3, list.getLength());
         assertValid("//xsd:import[@namespace='" + ns + "']",
                     list.item(0));
         assertValid("//xsd:import[@namespace='" + ns + "']", list.item(0));

Modified: cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TestService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TestService.java?rev=677607&r1=677606&r2=677607&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TestService.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TestService.java
Thu Jul 17 08:20:30 2008
@@ -18,12 +18,16 @@
  */
 package org.apache.cxf.xmlbeans;
 
+
 import javax.jws.WebMethod;
 import javax.jws.WebParam;
 import javax.jws.WebService;
 
 import junit.framework.Assert;
 
+import com.sample.procure.PurchaseOrderDocument;
+
+
 @WebService(targetNamespace = "urn:TestService", 
             serviceName = "TestService")
 public class TestService {
@@ -43,7 +47,7 @@
         fault.setFaultInfo("extra");
         throw fault;
     }
-
+    
     @WebMethod
     public ResponseDocument mixedRequest(
                                          @WebParam(name = "string") String string,
@@ -55,4 +59,9 @@
         response.addNewResponse().addNewForm();
         return response;
     }
+    
+    @WebMethod
+    public void submitPO(PurchaseOrderDocument doc) {
+        
+    }
 }

Added: cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/included.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/included.xsd?rev=677607&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/included.xsd (added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/included.xsd Thu Jul 17 08:20:30 2008
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://sample.com/procure"
targetNamespace="http://sample.com/procure" elementFormDefault="qualified" attributeFormDefault="unqualified">
+   <xs:complexType name="customer">
+       <xs:sequence>
+           <xs:element name="name" type="xs:string"/>
+           <xs:element name="address" type="xs:string"/>
+       </xs:sequence>
+   </xs:complexType>
+   <xs:complexType name="shipper">
+       <xs:sequence>
+           <xs:element name="name" type="xs:string"/>
+           <xs:element name="per-ounce-rate" type="xs:decimal"/>
+       </xs:sequence>
+   </xs:complexType>
+</xs:schema>

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/included.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/included.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/included.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/sample.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/sample.xsd?rev=677607&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/sample.xsd (added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/sample.xsd Thu Jul 17 08:20:30 2008
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema     
+   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+   targetNamespace="http://sample.com/procure"
+   xmlns:po="http://sample.com/procure"
+   elementFormDefault="qualified">
+   <xs:include schemaLocation="included.xsd"/>
+   <xs:element name="purchase-order">
+       <xs:complexType>
+           <xs:sequence>
+               <xs:element name="customer" type="po:customer"/>
+               <xs:element name="shipper" type="po:shipper" minOccurs="0"/>
+           </xs:sequence>
+       </xs:complexType>
+   </xs:element>
+</xs:schema>

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/sample.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/sample.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/sample.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message