Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.SchemaTypeLoader


        XmlObject xmlObject = XmlBeansUtil.parse(schema1.toURL(), getClass().getClassLoader());
        Collection errors = new ArrayList();
        XmlOptions xmlOptions = new XmlOptions();
        xmlOptions.setErrorListener(errors);
        XmlObject[] schemas = new XmlObject[] {xmlObject};
        SchemaTypeLoader schemaTypeLoader = XmlBeans.loadXsd(new XmlObject[] {});
        SchemaTypeSystem schemaTypeSystem;
        try {
            schemaTypeSystem = XmlBeans.compileXsd(schemas, schemaTypeLoader, xmlOptions);
            if (errors.size() > 0) {
                throw new DeploymentException("Could not compile schema type system: errors: " + errors);
View Full Code Here


        XmlObject xmlObject = XmlBeansUtil.parse(schema1.toURL());
        Collection errors = new ArrayList();
        XmlOptions xmlOptions = new XmlOptions();
        xmlOptions.setErrorListener(errors);
        XmlObject[] schemas = new XmlObject[] {xmlObject};
        SchemaTypeLoader schemaTypeLoader = XmlBeans.loadXsd(new XmlObject[] {});
        SchemaTypeSystem schemaTypeSystem;
        try {
            schemaTypeSystem = XmlBeans.compileXsd(schemas, schemaTypeLoader, xmlOptions);
            if (errors.size() > 0) {
                throw new DeploymentException("Could not compile schema type system: errors: " + errors);
View Full Code Here

        XmlObject xmlObject = XmlBeansUtil.parse(schema1.toURL(), getClass().getClassLoader());
        Collection errors = new ArrayList();
        XmlOptions xmlOptions = new XmlOptions();
        xmlOptions.setErrorListener(errors);
        XmlObject[] schemas = new XmlObject[] {xmlObject};
        SchemaTypeLoader schemaTypeLoader = XmlBeans.loadXsd(new XmlObject[] {});
        SchemaTypeSystem schemaTypeSystem;
        try {
            schemaTypeSystem = XmlBeans.compileXsd(schemas, schemaTypeLoader, xmlOptions);
            if (errors.size() > 0) {
                throw new DeploymentException("Could not compile schema type system: errors: " + errors);
View Full Code Here

        XmlObject xmlObject = XmlBeansUtil.parse(schema1.toURL(), getClass().getClassLoader());
        Collection errors = new ArrayList();
        XmlOptions xmlOptions = new XmlOptions();
        xmlOptions.setErrorListener(errors);
        XmlObject[] schemas = new XmlObject[] {xmlObject};
        SchemaTypeLoader schemaTypeLoader = XmlBeans.loadXsd(new XmlObject[] {});
        SchemaTypeSystem schemaTypeSystem;
        try {
            schemaTypeSystem = XmlBeans.compileXsd(schemas, schemaTypeLoader, xmlOptions);
            if (errors.size() > 0) {
                throw new DeploymentException("Could not compile schema type system: errors: " + errors);
View Full Code Here

        XmlObject xmlObject = XmlBeansUtil.parse(schema1.toURI().toURL(), getClass().getClassLoader());
        Collection errors = new ArrayList();
        XmlOptions xmlOptions = new XmlOptions();
        xmlOptions.setErrorListener(errors);
        XmlObject[] schemas = new XmlObject[] {xmlObject};
        SchemaTypeLoader schemaTypeLoader = XmlBeans.loadXsd(new XmlObject[] {});
        SchemaTypeSystem schemaTypeSystem;
        try {
            schemaTypeSystem = XmlBeans.compileXsd(schemas, schemaTypeLoader, xmlOptions);
            if (errors.size() > 0) {
                throw new DeploymentException("Could not compile schema type system: errors: " + errors);
View Full Code Here

        if (isImmutable())
            return this;

        check_orphaned();

        SchemaTypeLoader stl = get_store().get_schematypeloader();
        XmlObject result = (XmlObject)get_store().copy(stl, schemaType(), xmlOptions);

        return result;
    }
View Full Code Here

        XmlObject xmlObject = XmlBeansUtil.parse(schema1.toURL());
        Collection errors = new ArrayList();
        XmlOptions xmlOptions = new XmlOptions();
        xmlOptions.setErrorListener(errors);
        XmlObject[] schemas = new XmlObject[] {xmlObject};
        SchemaTypeLoader schemaTypeLoader = XmlBeans.loadXsd(new XmlObject[] {});
        SchemaTypeSystem schemaTypeSystem;
        try {
            schemaTypeSystem = XmlBeans.compileXsd(schemas, schemaTypeLoader, xmlOptions);
            if (errors.size() > 0) {
                throw new DeploymentException("Could not compile schema type system: errors: " + errors);
View Full Code Here

                                           File baseDir,
                                           File schemasDir,
                                           EntityResolver entResolver) {


        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);
            options.setGenerateJavaVersion(XmlOptions.GENERATE_JAVA_15);

            state.addSourceUri(wsdlFile, null);
            loadWSDLDoc(loader, url, options, scontentlist, errorListener);


        } 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);

                    URI uri = new URI(configFiles[i]);
                    XmlObject configdoc = null;
                    if ("file".equals(uri.getRawSchemeSpecificPart())) {
                        configdoc = loader.parse(new File(uri), null, options);                       
                    } else {
                        InputSource source = new InputSource(configFiles[i]);
                        Document doc = XMLUtils.parse(source);
                        configdoc = loader.parse(doc, 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();
        }
View Full Code Here

                                           File baseDir,
                                           File schemasDir,
                                           EntityResolver entResolver) {


        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);
            options.setGenerateJavaVersion(XmlOptions.GENERATE_JAVA_15);

           

            XmlObject urldoc = loader.parse(url, null, options);
            state.addSourceUri(wsdlFile, null);

            if (urldoc instanceof org.apache.xmlbeans.impl.xb.substwsdl.DefinitionsDocument) {
                org.apache.xmlbeans.impl.xb.substwsdl.DefinitionsDocument wsdldoc =
                    (org.apache.xmlbeans.impl.xb.substwsdl.DefinitionsDocument)urldoc;
               
                addWsdlSchemas(url.toString(),
                               wsdldoc,
                               errorListener, scontentlist);
               
                for (TImport imp : wsdldoc.getDefinitions().getImportArray()) {
                    if (imp.getLocation().toLowerCase().endsWith(".xsd")) {
                        URL url1 = new URL(url, imp.getLocation());
                        XmlObject urldoc2 = loader.parse(url1, null, options);
                        addSchema(url1.toString(), (SchemaDocument)urldoc2, errorListener, false,
                                  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);

                    URI uri = new URI(configFiles[i]);
                    XmlObject configdoc = null;
                    if ("file".equals(uri.getRawSchemeSpecificPart())) {
                        configdoc = loader.parse(new File(uri), null, options);                       
                    } else {
                        InputSource source = new InputSource(configFiles[i]);
                        Document doc = XMLUtils.parse(source);
                        configdoc = loader.parse(doc, 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();
        }
View Full Code Here

            }
        }

        XmlObject[] schemas = (XmlObject[])sdocs.toArray(new XmlObject[0]);

        SchemaTypeLoader sLoader;
        Collection compErrors = new ArrayList();
        XmlOptions schemaOptions = new XmlOptions();
        schemaOptions.setErrorListener(compErrors);
        if (dl)
            schemaOptions.setCompileDownloadUrls();
        if (nopvr)
            schemaOptions.setCompileNoPvrRule();
        if (noupa)
            schemaOptions.setCompileNoUpaRule();
       
        try
        {
            sLoader = XmlBeans.loadXsd(schemas, schemaOptions);
        }
        catch (Exception e)
        {
            if (compErrors.isEmpty() || !(e instanceof XmlException))
            {
                e.printStackTrace(System.err);
            }
            System.out.println("Schema invalid");
            for (Iterator i = compErrors.iterator(); i.hasNext(); )
                System.out.println(i.next());
            return;
        }
       
        for (int i = 0; i < instanceFiles.length; i++)
        {
            XmlObject xobj;
           
            try
            {
                xobj =
                    sLoader.parse( instanceFiles[i], null, (new XmlOptions()).setLoadLineNumbers() );
            }
            catch (Exception e)
            {
                System.err.println(instanceFiles[i] + " not loadable: " + e);
                e.printStackTrace(System.err);
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.SchemaTypeLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.