cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r761429 - in /cxf/trunk/tools/wsdlto: core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Date Thu, 02 Apr 2009 21:12:53 GMT
Author: dkulp
Date: Thu Apr  2 21:12:52 2009
New Revision: 761429

URL: http://svn.apache.org/viewvc?rev=761429&view=rev
Log:
Workaround a bug in xmlschema where namespaces are being mucked up a bit.
If the schema is a file, let JAXB parse it to get line numbers.

Modified:
    cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
    cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java

Modified: cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=761429&r1=761428&r2=761429&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++ cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Thu Apr  2 21:12:52 2009
@@ -146,6 +146,8 @@
                     // TODO: wsdl2.0 support
                 }
             }
+            context.put(ToolConstants.SERVICE_LIST, serviceList);
+            
             Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();
 
             ServiceInfo service0 = serviceList.get(0);
@@ -185,6 +187,7 @@
                     }
                 }
             }
+            context.remove(ToolConstants.SERVICE_LIST);
 
             // Build projects: compile classes and copy resources etc.
             if (context.optionSet(ToolConstants.CFG_COMPILE)) {

Modified: cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=761429&r1=761428&r2=761429&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Thu Apr  2 21:12:52 2009
@@ -72,6 +72,8 @@
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
@@ -196,9 +198,7 @@
             }
         }
         
-        
         addSchemas(opts, schemaCompiler, schemas);
-
         for (InputSource binding : jaxbBindings) {
             opts.addBindFile(binding);
         }
@@ -242,34 +242,70 @@
         initialized = true;
     }
 
-    private void addSchemas(Options opts, SchemaCompiler schemaCompiler,
+    @SuppressWarnings("unchecked")
+    private void addSchemas(Options opts, 
+                            SchemaCompiler schemaCompiler,
                             SchemaCollection schemaCollection) {
+        
+        Set<String> ids = new HashSet<String>();
+        List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
+        for (ServiceInfo si : serviceList) {
+            for (SchemaInfo sci : si.getSchemas()) {
+                String key = sci.getSystemId();
+                if (ids.contains(key)) {
+                    continue;
+                }
+                ids.add(key);
+                
+                Element ele = sci.getElement();
+                ele = removeImportElement(ele);
+                if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
+                    validateSchema(ele);
+                }           
+                InputSource is = new InputSource((InputStream)null);
+                //key = key.replaceFirst("#types[0-9]+$", "");
+                is.setSystemId(key);
+                is.setPublicId(key);
+                opts.addGrammar(is);
+                schemaCompiler.parseSchema(key, ele);
+            }
+        }
         for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
             if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(schema.getTargetNamespace())) {
                 continue;
             }
-                
             String key = schema.getSourceURI();
-            XmlSchemaSerializer xser = new XmlSchemaSerializer();
-            xser.setExtReg(schemaCollection.getExtReg());
-            Document[] docs;
-            try {
-                docs = xser.serializeSchema(schema, false);
-            } catch (XmlSchemaSerializerException e) {
-                throw new RuntimeException(e);
-            }
-            Element ele = docs[0].getDocumentElement();
-
-            ele = removeImportElement(ele);
-            if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
-                validateSchema(ele);
-            }           
-            InputSource is = new InputSource((InputStream)null);
-           // key = key.replaceFirst("#types[0-9]+$", "");
-            is.setSystemId(key);
-            is.setPublicId(key);
-            opts.addGrammar(is);
-            schemaCompiler.parseSchema(key, ele);
+            if (ids.contains(key)) {
+                continue;
+            }
+            
+            if (key.startsWith("file:")) {
+                InputSource is = new InputSource(key);
+                //key = key.replaceFirst("#types[0-9]+$", "");
+                opts.addGrammar(is);
+                schemaCompiler.parseSchema(is);
+            } else {
+                XmlSchemaSerializer xser = new XmlSchemaSerializer();
+                xser.setExtReg(schemaCollection.getExtReg());
+                Document[] docs;
+                try {
+                    docs = xser.serializeSchema(schema, false);
+                } catch (XmlSchemaSerializerException e) {
+                    throw new RuntimeException(e);
+                }
+                Element ele = docs[0].getDocumentElement();
+    
+                ele = removeImportElement(ele);
+                if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
+                    validateSchema(ele);
+                }           
+                InputSource is = new InputSource((InputStream)null);
+                //key = key.replaceFirst("#types[0-9]+$", "");
+                is.setSystemId(key);
+                is.setPublicId(key);
+                opts.addGrammar(is);
+                schemaCompiler.parseSchema(key, ele);
+            }
         }
     }
     private String getPluginUsageString(Options opts) {



Mime
View raw message