Package org.apache.ws.commons.schema

Examples of org.apache.ws.commons.schema.XmlSchemaImport


        if (includes != null) {
            Iterator tempIterator = includes.getIterator();
            while (tempIterator.hasNext()) {
                Object o = tempIterator.next();
                if (o instanceof XmlSchemaImport) {
                    XmlSchemaImport schemaImport = (XmlSchemaImport)o;
                    XmlSchema schema1 = schemaImport.getSchema();
                    if (schema1 != null) {
                        compile(schema1, isPartofGroup);
                    } else if (schemaImport.getNamespace().equals(Constants.NS_URI_XML)) {
                        // AXIS2-3229: some Web services (e.g. MS Exchange) assume that
                        // http://www.w3.org/XML/1998/namespace is a known namespace and that
                        // no schemaLocation is required when importing it. Load a local copy of
                        // the schema in that case.
                        schema1 = new XmlSchemaCollection().read(new InputSource(
                                SchemaCompiler.class.getResource("namespace.xsd").toExternalForm()), null);
                        schemaImport.setSchema(schema1);
                        compile(schema1, isPartofGroup);
                    } else if (!schemaImport.getNamespace().equals(Constants.URI_2001_SCHEMA_XSD)) {
                        // Give the user a hint why the schema compilation fails...
                        log.warn("No schemaLocation for import of " + schemaImport.getNamespace() + "; compilation may fail");
                    }
                }
                if (o instanceof XmlSchemaInclude) {
                    XmlSchema schema1 = ((XmlSchemaInclude) o).getSchema();
                    if (schema1 != null){
View Full Code Here


                        // if this is an inline import without a schema location
                        // xmlschema does not load the schema.
                        // so we try to figure out it either from the available schemas
                        // or from the laded schemas.
                        if ((externalSchema == null) && externalComponet instanceof XmlSchemaImport){
                            XmlSchemaImport xmlSchemaImport = (XmlSchemaImport) externalComponet;
                            String importNamespce = xmlSchemaImport.getNamespace();
                            if ((importNamespce != null) && !importNamespce.equals(Constants.URI_2001_SCHEMA_XSD)) {
                                if (loadedSchemaMap.containsKey(importNamespce)) {
                                    externalSchema = loadedSchemaMap.get(importNamespce);
                                } else if (availableSchemaMap.containsKey(importNamespce)) {
                                    XmlSchema tempSchema = availableSchemaMap.get(importNamespce);
View Full Code Here

                    xmlSchema.getIncludes().add(includeElement);
                }
            }
        } else {
            if (!((NamespaceMap)xmlSchema.getNamespaceContext()).values().contains(schemaTypeName.getNamespaceURI())) {
                XmlSchemaImport importElement = new XmlSchemaImport();
                importElement.setNamespace(schemaTypeName.getNamespaceURI());
                xmlSchema.getItems().add(importElement);
                ((NamespaceMap)xmlSchema.getNamespaceContext()).put(generatePrefix(), schemaTypeName.getNamespaceURI());
            }
        }
    }
View Full Code Here

                    xmlSchema.getItems().add(includeElement);
                }
            }
        } else {
            if (!((NamespaceMap)xmlSchema.getNamespaceContext()).values().contains(schemaTypeName.getNamespaceURI())) {
                XmlSchemaImport importElement = new XmlSchemaImport();
                importElement.setNamespace(schemaTypeName.getNamespaceURI());

                // Add schemaLocation on imports
                String schemaLocation = (String)schemaLocationMap.get(schemaTypeName.getNamespaceURI());
                importElement.setSchemaLocation(schemaLocation);
                xmlSchema.getItems().add(importElement);
                ((NamespaceMap)xmlSchema.getNamespaceContext()).put(generatePrefix(), schemaTypeName.getNamespaceURI());
            }
        }
    }
View Full Code Here

                    equals(xmlSchema.getNamespaceContext().getNamespaceURI(prefixes[count])) ) {
                return prefixes[count];
            }
        }

        XmlSchemaImport importElement = new XmlSchemaImport();
        importElement.setNamespace(schemaTypeName.getNamespaceURI());
        xmlSchema.getItems().add(importElement);
        prefix = generatePrefix();
        //it is safe to cast like this since it was this class that instantiated the
        //NamespaceContext and assigned it to an instance of a NamespaceMap (see method getXmlSchema)
        ((NamespaceMap)xmlSchema.getNamespaceContext()).put(prefix,
View Full Code Here

    private void addImport(XmlSchema schema, String ns) {
        if (!ns.equals(schema.getTargetNamespace())
            && !ns.equals(WSDLConstants.NS_SCHEMA_XSD)
            && !isExistImport(schema, ns)) {
            XmlSchemaImport is = new XmlSchemaImport(schema);
            is.setNamespace(ns);
            if (this.schemaLocationMapping.get(ns) != null) {
                is.setSchemaLocation(this.schemaLocationMapping.get(ns));
            }
            if (!schema.getItems().contains(is)) {
                schema.getItems().add(is);
            }
        }
View Full Code Here

    private boolean isExistImport(XmlSchema schema, String ns) {
        boolean isExist = false;

        for (XmlSchemaExternal ext : schema.getExternals()) {
            if (ext instanceof XmlSchemaImport) {
                XmlSchemaImport xsImport = (XmlSchemaImport)ext;
                if (xsImport.getNamespace().equals(ns)) {
                    isExist = true;
                    break;
                }
            }
        }
View Full Code Here

     */
    public static boolean schemaImportsNamespace(XmlSchema schema, String namespaceUri) {
        List<XmlSchemaExternal> externals =  schema.getExternals();
        for (XmlSchemaExternal what : externals) {
            if (what instanceof XmlSchemaImport) {
                XmlSchemaImport imp = (XmlSchemaImport)what;
                // already there.
                if (namespaceUri.equals(imp.getNamespace())) {
                    return true;
                }
            }
        }
        return false;
View Full Code Here

        }

        List<XmlSchemaExternal> externals = schema.getExternals();
        for (XmlSchemaExternal what : externals) {
            if (what instanceof XmlSchemaImport) {
                XmlSchemaImport imp = (XmlSchemaImport)what;
                // already there.
                if (namespaceUri.equals(imp.getNamespace())) {
                    return;
                }
            }
        }
        XmlSchemaImport imp = new XmlSchemaImport(schema);
        imp.setNamespace(namespaceUri);
    }
View Full Code Here

    private void addImport(XmlSchema schema, String ns) {
        if (!ns.equals(schema.getTargetNamespace())
            && !ns.equals(WSDLConstants.NU_SCHEMA_XSD)
            && !isExistImport(schema, ns)) {
           
            XmlSchemaImport is = new XmlSchemaImport();
            is.setNamespace(ns);
            schema.getItems().add(is);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.schema.XmlSchemaImport

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.