cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r663658 - in /cxf/trunk: api/src/main/java/org/apache/cxf/wsdl/ rt/databinding/xmlbeans/ rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/ rt/databinding/xmlbeans/src/main/resources/ rt/databinding/xmlbeans/src/main/resou...
Date Thu, 05 Jun 2008 16:58:15 GMT
Author: dkulp
Date: Thu Jun  5 09:58:15 2008
New Revision: 663658

URL: http://svn.apache.org/viewvc?rev=663658&view=rev
Log:
Start of XMLBeans tooling
More validation fixes

Added:
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
  (with props)
    cxf/trunk/rt/databinding/xmlbeans/src/main/resources/
    cxf/trunk/rt/databinding/xmlbeans/src/main/resources/META-INF/
    cxf/trunk/rt/databinding/xmlbeans/src/main/resources/META-INF/tools-plugin.xml   (with
props)
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
    cxf/trunk/rt/databinding/xmlbeans/pom.xml

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?rev=663658&r1=663657&r2=663658&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java Thu Jun  5
09:58:15 2008
@@ -19,10 +19,13 @@
 
 package org.apache.cxf.wsdl;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -60,7 +63,6 @@
 import org.w3c.dom.ls.LSResourceResolver;
 
 import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.i18n.Message;
@@ -101,14 +103,14 @@
      * the code in here.
      */
     private static final class SchemaLSResourceResolver implements LSResourceResolver {
-        private final ServiceInfo si;
+        private final Map<String, DOMSource> schemas;
         private final ExtendedURIResolver resolver = new ExtendedURIResolver();
-        private SchemaLSResourceResolver(ServiceInfo serviceInfo) {
-            this.si = serviceInfo;
+        
+        private SchemaLSResourceResolver(Map<String, DOMSource> schemas) {
+            this.schemas = schemas;
         }
         
-        private Reader getSchemaAsStream(Element schemaElement) {
-            DOMSource source = new DOMSource(schemaElement);
+        private Reader getSchemaAsStream(DOMSource source) {
             StringWriter writer = new StringWriter();
             StreamResult result = new StreamResult(writer);
             try {
@@ -121,35 +123,37 @@
 
         public LSInput resolveResource(String type, String namespaceURI, String publicId,
                                        String systemId, String baseURI) {
-            for (SchemaInfo schemaInfo : si.getSchemas()) {
-                XmlSchema sch = schemaInfo.getSchema();
-                if (namespaceURI.equals(sch.getTargetNamespace())) {
+
+            String newId = systemId;
+            if (baseURI != null) {
+                try {
+                    URI uri = new URI(baseURI);
+                    uri = uri.resolve(systemId);
+                    newId = uri.toString();
+                } catch (URISyntaxException e) {
+                    //ignore
+                }
+            }
+            if (schemas.containsKey(newId + ":" + namespaceURI)) {
+                DOMSource ds = schemas.remove(newId + ":" + namespaceURI);
+                LSInputImpl impl = new LSInputImpl();
+                impl.setSystemId(newId);
+                impl.setBaseURI(newId);
+                impl.setCharacterStream(getSchemaAsStream(ds));
+                return impl;
+            }
+            
+            for (Map.Entry<String, DOMSource> ent : schemas.entrySet()) {
+                if (ent.getKey().endsWith(namespaceURI)) {
+                    schemas.remove(ent.getKey());
                     LSInputImpl impl = new LSInputImpl();
-                    Element schemaAsDom = schemaInfo.getElement();
-                    if (schemaAsDom != null) {
-                        impl.setCharacterStream(getSchemaAsStream(schemaAsDom));
-                        return impl;
-                    }
-                    // otherwise, go ahead and assume it's out there somewhere.
-                    // this needs catalog support, does it not?
-                    InputStream ins = null;
-                    try {
-                        URL url = new URL(sch.getSourceURI());
-                        ins = url.openStream();
-                    } catch (Exception e) {
-                        //ignore, we'll just use what we have.  (though
-                        //bugs in XmlSchema could make this less useful)
-                    }
-                    
-                    if (ins == null) {
-                        LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
-                        sch.write(out);
-                        ins = out.createInputStream();
-                    }
-                    impl.setByteStream(ins);
+                    impl.setSystemId(newId);
+                    impl.setBaseURI(newId);
+                    impl.setCharacterStream(getSchemaAsStream(ent.getValue()));
                     return impl;
                 }
             }
+                
             //REVIST - we need to get catalogs in here somehow  :-(
             if (systemId == null) {
                 systemId = publicId;
@@ -569,7 +573,7 @@
         Schema schema = serviceInfo.getProperty(Schema.class.getName(), Schema.class);
         if (schema == null) {
             SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-            Map<String, Source> schemaSourcesMap = new LinkedHashMap<String, Source>();
+            Map<String, DOMSource> schemaSourcesMap = new LinkedHashMap<String,
DOMSource>();
             for (SchemaInfo si : serviceInfo.getSchemas()) {
                 Element el = si.getElement();
                 String baseURI = el.getBaseURI();
@@ -580,36 +584,43 @@
                 schemaSourcesMap.put(si.getSystemId() + ":" + si.getNamespaceURI(), ds);
             }
 
-            for (XmlSchema sch : serviceInfo.getXmlSchemaCollection().getXmlSchemas()) {
-                if (sch.getSourceURI() != null
-                    && !schemaSourcesMap.containsKey(sch.getSourceURI() + ":" 
-                                                     + sch.getTargetNamespace())) { 
-                    
-                    InputStream ins = null;
-                    try {
-                        URL url = new URL(sch.getSourceURI());
-                        ins = url.openStream();
-                    } catch (Exception e) {
-                        //ignore, we'll just use what we have.  (though
-                        //bugs in XmlSchema could make this less useful)
-                    }
-                    
-                    if (ins == null) {
-                        LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
-                        sch.write(out);
-                        ins = out.createInputStream();
+            try {
+                for (XmlSchema sch : serviceInfo.getXmlSchemaCollection().getXmlSchemas())
{
+                    if (sch.getSourceURI() != null
+                        && !schemaSourcesMap.containsKey(sch.getSourceURI() + ":"

+                                                         + sch.getTargetNamespace())) { 
+                        
+                        InputStream ins = null;
+                        try {
+                            URL url = new URL(sch.getSourceURI());
+                            ins = url.openStream();
+                        } catch (Exception e) {
+                            //ignore, we'll just use what we have.  (though
+                            //bugs in XmlSchema could make this less useful)
+                        }
+                        
+                        if (ins == null) {
+                            LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
+                            sch.write(out);
+                            ins = out.createInputStream();
+                        }
+                        Document doc = XMLUtils.parse(ins);
+                        try {
+                            ins.close();
+                        } catch (IOException ex) {
+                            //ignore
+                        }
+                        
+                        DOMSource ss = new DOMSource(doc, sch.getSourceURI());
+                        schemaSourcesMap.put(sch.getSourceURI() + ":" 
+                                             + sch.getTargetNamespace(), ss);
                     }
-                    StreamSource ss = new StreamSource(ins, sch.getSourceURI());
-                    schemaSourcesMap.put(sch.getSourceURI() + ":" 
-                                         + sch.getTargetNamespace(), ss);
-                }
-            } 
+                } 
 
-            try {
-                factory.setResourceResolver(new SchemaLSResourceResolver(serviceInfo));
+                factory.setResourceResolver(new SchemaLSResourceResolver(schemaSourcesMap));
                 schema = factory.newSchema(schemaSourcesMap.values()
                                            .toArray(new Source[schemaSourcesMap.size()]));
-            } catch (SAXException ex) {
+            } catch (Exception ex) {
                 // Something not right with the schema from the wsdl.
                 LOG.log(Level.WARNING, "SAXException for newSchema() on ", ex);
                 for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {

Modified: cxf/trunk/rt/databinding/xmlbeans/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/pom.xml?rev=663658&r1=663657&r2=663658&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/pom.xml (original)
+++ cxf/trunk/rt/databinding/xmlbeans/pom.xml Thu Jun  5 09:58:15 2008
@@ -60,6 +60,13 @@
             <artifactId>cxf-tools-common</artifactId>
             <version>${project.version}</version>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-wsdlto-core</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
 
 
         <dependency>

Added: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java?rev=663658&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
(added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
Thu Jun  5 09:58:15 2008
@@ -0,0 +1,420 @@
+/**
+ * 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.xmlbeans.tools;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.xml.sax.EntityResolver;
+
+import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.tools.common.ToolContext;
+import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.common.model.DefaultValueWriter;
+import org.apache.cxf.tools.util.ClassCollector;
+import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.SchemaTypeLoader;
+import org.apache.xmlbeans.SchemaTypeSystem;
+import org.apache.xmlbeans.SimpleValue;
+import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlErrorCodes;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.common.ResolverUtil;
+import org.apache.xmlbeans.impl.common.XmlErrorWatcher;
+import org.apache.xmlbeans.impl.config.BindingConfigImpl;
+import org.apache.xmlbeans.impl.schema.PathResourceLoader;
+import org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl;
+import org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler;
+import org.apache.xmlbeans.impl.schema.StscState;
+import org.apache.xmlbeans.impl.tool.CodeGenUtil;
+import org.apache.xmlbeans.impl.util.FilerImpl;
+import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument;
+import org.apache.xmlbeans.impl.xb.xmlconfig.Extensionconfig;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+
+/**
+ * 
+ */
+public class XMLBeansToolingDataBinding implements DataBindingProfile {
+    private static final String CONFIG_URI = "http://xml.apache.org/xmlbeans/2004/02/xbean/config";
+    private static final String COMPATIBILITY_CONFIG_URI = "http://www.bea.com/2002/09/xbean/config";
+    private static final Map<String, String> MAP_COMPATIBILITY_CONFIG_URIS;
+    static {
+        MAP_COMPATIBILITY_CONFIG_URIS = new HashMap<String, String>();
+        MAP_COMPATIBILITY_CONFIG_URIS.put(COMPATIBILITY_CONFIG_URI, CONFIG_URI);
+    }
+
+    
+    
+    SchemaTypeSystem typeSystem;
+    Map<String, String> sourcesToCopyMap = new HashMap<String, String>();
+    XmlErrorWatcher errorListener = new XmlErrorWatcher(null);
+    PathResourceLoader cpResourceLoader = new PathResourceLoader(CodeGenUtil.systemClasspath());
+
+    public void initialize(ToolContext context) throws ToolException {
+        // TODO Auto-generated method stub
+        String wsdl = (String)context.get(ToolConstants.CFG_WSDLLOCATION);
+        String catalog = (String)context.get(ToolConstants.CFG_CATALOG);
+        Object o = context.get(ToolConstants.CFG_BINDING);
+        String bindingFiles[]; 
+        if (o instanceof String) {
+            bindingFiles = new String[] {o.toString()};
+        } else {
+            bindingFiles = (String[])o;
+        }
+
+        // build the in-memory type system
+        EntityResolver cmdLineEntRes = ResolverUtil.resolverForCatalog(catalog);
+        typeSystem = loadTypeSystem(wsdl, 
+                                     bindingFiles, 
+                                     null, 
+                                     null, 
+                                     null, 
+                                     cmdLineEntRes);
+        
+    }
+
+    public DefaultValueWriter createDefaultValueWriter(QName qn, boolean element) {
+        return null;
+    }
+
+    public DefaultValueWriter createDefaultValueWriterForWrappedElement(QName wrapperElement,
QName qn) {
+        return null;
+    }
+
+    public String getType(QName qn, boolean element) {
+        String ret;
+        if (element) {
+            ret = typeSystem.findElement(qn).getType().getFullJavaName();
+            if (ret.contains("$")) {
+                ret = ret.substring(0, ret.indexOf('$'));
+            }
+            return ret;
+        }
+        ret = typeSystem.findType(qn).getFullJavaName();
+        return ret.replace('$', '.');
+    }
+
+    public String getWrappedElementType(QName wrapperElement, QName item) {
+        SchemaType st = typeSystem.findElement(wrapperElement).getType();
+        return st.getElementProperty(item).getType().getFullJavaName().replace('$', '.');
+    }
+
+    public void generate(ToolContext context) throws ToolException {
+        String srcd = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
+        String classesd = (String)context.get(ToolConstants.CFG_CLASSDIR);
+        boolean verbose = context.optionSet(ToolConstants.CFG_VERBOSE);
+
+        boolean result = true;
+        if (errorListener.hasError()) {
+            result = false;
+        }
+        
+        File srcDir;
+        File classesDir;
+        if (srcd == null) {
+            String wsdl = (String)context.get(ToolConstants.CFG_WSDLLOCATION);
+            try {
+                srcd = new File(new URI(wsdl)).getAbsolutePath();
+            } catch (URISyntaxException e) {
+                srcd = new File(".").getAbsolutePath();
+            } 
+        }
+        srcDir = new File(srcd);
+        srcDir.mkdirs();
+
+        if (classesd == null) {
+            classesDir = srcDir;
+        } else {
+            classesDir = new File(classesd);
+            classesDir.mkdirs();
+        }
+
+        // now code generate and compile the JAR
+        if (result) {
+            // filer implementation writes binary .xsd and generated source to disk
+            final ClassCollector classCollector = context.get(ClassCollector.class);
+
+            FilerImpl filer = new FilerImpl(classesDir, srcDir,
+                                            null, verbose, false) {
+                public Writer createSourceFile(String typename) throws IOException {
+                    String tn = typename;
+                    if (tn.contains("$")) {
+                        tn = tn.substring(0, tn.indexOf('$'));
+                    }
+                    String pkg = tn.substring(0, tn.lastIndexOf('.'));
+                    tn = tn.substring(tn.lastIndexOf('.') + 1);
+                    classCollector.addTypesClassName(pkg, tn, pkg + "." + tn);
+                    return super.createSourceFile(typename);
+                }
+            };
+
+            // currently just for schemaCodePrinter
+            XmlOptions options = new XmlOptions();
+            /*
+            if (codePrinter != null) {
+                options.setSchemaCodePrinter(codePrinter);
+            }
+            */
+            options.setGenerateJavaVersion("1.5");
+
+            // save .xsb files
+            typeSystem.save(filer);
+
+            // gen source files
+            result &= SchemaTypeSystemCompiler.generateTypes(typeSystem, filer, options);
+            /*
+            for (String s : classCollector.getGeneratedFileInfo()) {
+                System.out.println(s);
+            }
+            */
+        }
+
+        if (!result && verbose) {
+            System.out.println("BUILD FAILED");
+        }
+
+        if (cpResourceLoader != null) {
+            cpResourceLoader.close();
+        }
+
+    }
+
+    
+    private SchemaTypeSystem loadTypeSystem(String wsdlFile, 
+                                           String[] configFiles,
+                                           Set mdefNamespaces, 
+                                           File baseDir, 
+                                           File schemasDir,
+                                           EntityResolver entResolver) {
+
+        // construct the state (have to initialize early in case of errors)
+        StscState state = StscState.start();
+        state.setErrorListener(errorListener);
+
+        SchemaTypeLoader loader = XmlBeans.typeLoaderForClassLoader(SchemaDocument.class.getClassLoader());
+
+        // parse all the XSD files.
+        List<SchemaDocument.Schema> scontentlist = new ArrayList<SchemaDocument.Schema>();
+        try {
+            URL url = new URL(wsdlFile);
+            XmlOptions options = new XmlOptions();
+            options.setLoadLineNumbers();
+            options.setLoadSubstituteNamespaces(Collections
+                .singletonMap("http://schemas.xmlsoap.org/wsdl/",
+                              "http://www.apache.org/internal/xmlbeans/wsdlsubst"));
+            options.setEntityResolver(entResolver);
+
+            XmlObject urldoc = loader.parse(url, null, options);
+
+            if (urldoc instanceof org.apache.xmlbeans.impl.xb.substwsdl.DefinitionsDocument)
{
+                addWsdlSchemas(url.toString(),
+                               (org.apache.xmlbeans.impl.xb.substwsdl.DefinitionsDocument)urldoc,
+                               errorListener, scontentlist);
+            } else if (urldoc instanceof SchemaDocument) {
+                addSchema(url.toString(), (SchemaDocument)urldoc, errorListener, false,
+                          scontentlist);
+            } else {
+                StscState.addError(errorListener, XmlErrorCodes.INVALID_DOCUMENT_TYPE, new
Object[] {
+                    url, "wsdl or schema"
+                }, urldoc);
+            }
+
+        } catch (XmlException e) {
+            errorListener.add(e.getError());
+        } catch (Exception e) {
+            StscState.addError(errorListener, XmlErrorCodes.CANNOT_LOAD_FILE, new Object[]
{
+                "url", wsdlFile, e.getMessage()
+            }, (URL)null);
+        }
+
+        SchemaDocument.Schema[] sdocs = (SchemaDocument.Schema[])scontentlist
+            .toArray(new SchemaDocument.Schema[scontentlist.size()]);
+
+        // now the config files.
+        List<ConfigDocument.Config> cdoclist = new ArrayList<ConfigDocument.Config>();
+        List<File> javaFiles = new ArrayList<File>();
+        if (configFiles != null) {
+            for (int i = 0; i < configFiles.length; i++) {
+                if (configFiles[i].endsWith(".java")) {
+                    javaFiles.add(new File(configFiles[i]));
+                    continue;
+                }
+                if (!configFiles[i].endsWith(".xsdconfig")) {
+                    //jaxws/jaxb customization file or something else
+                    continue;
+                }
+                try {
+                    XmlOptions options = new XmlOptions();
+                    options.put(XmlOptions.LOAD_LINE_NUMBERS);
+                    options.setEntityResolver(entResolver);
+                    options.setLoadSubstituteNamespaces(MAP_COMPATIBILITY_CONFIG_URIS);
+
+                    XmlObject configdoc = loader.parse(configFiles[i], null, options);
+                    if (!(configdoc instanceof ConfigDocument)) {
+                        StscState.addError(errorListener, XmlErrorCodes.INVALID_DOCUMENT_TYPE,
new Object[] {
+                            configFiles[i], "xsd config"
+                        }, configdoc);
+                    } else {
+                        StscState.addInfo(errorListener, "Loading config file " + configFiles[i]);
+                        if (configdoc.validate(new XmlOptions().setErrorListener(errorListener)))
{
+                            ConfigDocument.Config config = ((ConfigDocument)configdoc).getConfig();
+                            cdoclist.add(config);
+                            config.setExtensionArray(new Extensionconfig[] {});
+                        }
+                    }
+                } catch (XmlException e) {
+                    errorListener.add(e.getError());
+                } catch (Exception e) {
+                    StscState.addError(errorListener, XmlErrorCodes.CANNOT_LOAD_FILE, new
Object[] {
+                        "xsd config", configFiles[i], e.getMessage()
+                    }, new File(configFiles[i]));
+                }
+            }
+        }
+        ConfigDocument.Config[] cdocs = (ConfigDocument.Config[])cdoclist
+            .toArray(new ConfigDocument.Config[cdoclist.size()]);
+
+
+        SchemaTypeLoader linkTo = SchemaTypeLoaderImpl.build(null, cpResourceLoader, null);
+
+        URI baseURI = null;
+        if (baseDir != null) {
+            baseURI = baseDir.toURI();
+        }
+
+        XmlOptions opts = new XmlOptions();
+        opts.setCompileDownloadUrls();
+        
+        
+        if (mdefNamespaces != null) {
+            opts.setCompileMdefNamespaces(mdefNamespaces);
+        }
+        opts.setCompileNoValidation(); // already validated here
+        opts.setEntityResolver(entResolver);
+        opts.setGenerateJavaVersion("1.5");
+
+        // now pass it to the main compile function
+        SchemaTypeSystemCompiler.Parameters params = new SchemaTypeSystemCompiler.Parameters();
+        params.setSchemas(sdocs);
+        params.setConfig(BindingConfigImpl.forConfigDocuments(cdocs, 
+                                                              javaFiles.toArray(new File[javaFiles.size()]),

+                                                              CodeGenUtil.systemClasspath()));
+        params.setLinkTo(linkTo);
+        params.setOptions(opts);
+        params.setErrorListener(errorListener);
+        params.setJavaize(true);
+        params.setBaseURI(baseURI);
+        params.setSourcesToCopyMap(sourcesToCopyMap);
+        //params.setSchemasDir(schemasDir);
+        return SchemaTypeSystemCompiler.compile(params);
+    }
+
+
+    
+  
+
+    private static void addSchema(String name, SchemaDocument schemadoc, XmlErrorWatcher
errorListener,
+                                  boolean noVDoc, List<SchemaDocument.Schema>  scontentlist)
{
+        StscState.addInfo(errorListener, "Loading schema file " + name);
+        XmlOptions opts = new XmlOptions().setErrorListener(errorListener);
+        if (noVDoc) {
+            opts.setValidateTreatLaxAsSkip();
+        }
+        if (schemadoc.validate(opts)) {
+            scontentlist.add(schemadoc.getSchema());
+        }
+    }
+
+    private static void addWsdlSchemas(String name,
+                                       org.apache.xmlbeans.impl.xb.substwsdl.DefinitionsDocument
wsdldoc,
+                                       XmlErrorWatcher errorListener,
+                                       List<SchemaDocument.Schema> scontentlist) {
+        if (wsdlContainsEncoded(wsdldoc)) {
+            StscState
+                .addWarning(
+                            errorListener,
+                            "The WSDL "
+                                + name
+                                + " uses SOAP encoding. SOAP encoding "
+                                + "is not compatible with literal XML Schema.",
+                            XmlErrorCodes.GENERIC_ERROR, wsdldoc);
+        }
+        StscState.addInfo(errorListener, "Loading wsdl file " + name);
+        XmlOptions opts = new XmlOptions().setErrorListener(errorListener);
+        XmlObject[] types = wsdldoc.getDefinitions().getTypesArray();
+        int count = 0;
+        for (int j = 0; j < types.length; j++) {
+            XmlObject[] schemas = types[j]
+                .selectPath("declare namespace xs=\"http://www.w3.org/2001/XMLSchema\" xs:schema");
+            if (schemas.length == 0) {
+                StscState
+                    .addWarning(
+                                errorListener,
+                                "The WSDL "
+                                    + name
+                                    + " did not have any schema documents in "
+                                    + "namespace 'http://www.w3.org/2001/XMLSchema'",
+                                XmlErrorCodes.GENERIC_ERROR, wsdldoc);
+                continue;
+            }
+
+            for (int k = 0; k < schemas.length; k++) {
+                if (schemas[k] instanceof SchemaDocument.Schema && schemas[k].validate(opts))
{
+                    count++;
+                    scontentlist.add((SchemaDocument.Schema)schemas[k]);
+                }
+            }
+        }
+        StscState.addInfo(errorListener, "Processing " + count + " schema(s) in " + name);
+    }
+
+   
+
+    private static boolean wsdlContainsEncoded(XmlObject wsdldoc) {
+        // search for any <soap:body use="encoded"/> etc.
+        XmlObject[] useAttrs = wsdldoc
+            .selectPath("declare namespace soap='http://schemas.xmlsoap.org/wsdl/soap/' "
+                        + ".//soap:body/@use|.//soap:header/@use|.//soap:fault/@use");
+        for (int i = 0; i < useAttrs.length; i++) {
+            if ("encoded".equals(((SimpleValue)useAttrs[i]).getStringValue())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+}

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/databinding/xmlbeans/src/main/resources/META-INF/tools-plugin.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/resources/META-INF/tools-plugin.xml?rev=663658&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/resources/META-INF/tools-plugin.xml (added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/resources/META-INF/tools-plugin.xml Thu Jun
 5 09:58:15 2008
@@ -0,0 +1,23 @@
+<?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.
+-->
+
+<plugin name="xmlbeans" version="" provider="cxf.apache.org" xmlns="http://cxf.apache.org/tools/plugin">
+    <databinding name="xmlbeans" package="org.apache.cxf.xmlbeans.tools" profile="XMLBeansToolingDataBinding"/>
+</plugin>
\ No newline at end of file

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/main/resources/META-INF/tools-plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/main/resources/META-INF/tools-plugin.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/databinding/xmlbeans/src/main/resources/META-INF/tools-plugin.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message