Search in sources :

Example 1 with XmlSchema

use of org.apache.ws.commons.schema.XmlSchema in project tdi-studio-se by Talend.

the class ComponentBuilder method findImportSchema.

private void findImportSchema(Definition wsdlDefinition, Vector schemas, Map importElement, Set<String> imports) throws WSDLException {
    org.w3c.dom.Element schemaElementt;
    List includeElement = null;
    Iterator keyIterator = importElement.keySet().iterator();
    Boolean isHaveImport = false;
    while (keyIterator.hasNext()) {
        Object object = keyIterator.next();
        if (object != null) {
            String key = object.toString();
            Vector importEle = (Vector) importElement.get(key);
            for (int i = 0; i < importEle.size(); i++) {
                Map importChildElement = null;
                com.ibm.wsdl.extensions.schema.SchemaImportImpl importImpl = (com.ibm.wsdl.extensions.schema.SchemaImportImpl) importEle.elementAt(i);
                // to avoid import cycle
                String importLocation = importImpl.getSchemaLocationURI() + ":" + importImpl.getNamespaceURI();
                if (imports.contains(importLocation)) {
                    continue;
                } else {
                    imports.add(importLocation);
                }
                if (importImpl.getReferencedSchema() != null) {
                    schemaElementt = importImpl.getReferencedSchema().getElement();
                    String documentBase = importImpl.getReferencedSchema().getDocumentBaseURI();
                    if ((com.ibm.wsdl.extensions.schema.SchemaImportImpl) importEle.elementAt(i) != null) {
                        if (((com.ibm.wsdl.extensions.schema.SchemaImportImpl) importEle.elementAt(i)).getReferencedSchema() != null) {
                            importChildElement = ((com.ibm.wsdl.extensions.schema.SchemaImportImpl) importEle.elementAt(i)).getReferencedSchema().getImports();
                            if (importChildElement != null && importChildElement.size() > 0 && !isIncludeSchema(documentBase)) {
                                isHaveImport = true;
                                documentBaseList.add(documentBase);
                            // validateImportUrlPath(importElement);
                            }
                        }
                    }
                    XmlSchema schemaImport = createschemafromtype(schemaElementt, wsdlDefinition, documentBase);
                    if (schemaImport != null) {
                        schemas.add(schemaImport);
                        if (schemaImport.getTargetNamespace() != null) {
                            schemaNames.add(schemaImport.getTargetNamespace());
                        }
                    }
                }
                if (isHaveImport) {
                    findImportSchema(wsdlDefinition, schemas, importChildElement, imports);
                }
                if ((com.ibm.wsdl.extensions.schema.SchemaImportImpl) importEle.elementAt(i) != null) {
                    if (((com.ibm.wsdl.extensions.schema.SchemaImportImpl) importEle.elementAt(i)).getReferencedSchema() != null) {
                        includeElement = ((com.ibm.wsdl.extensions.schema.SchemaImportImpl) importEle.elementAt(i)).getReferencedSchema().getIncludes();
                        if (includeElement != null && includeElement.size() > 0) {
                            findIncludesSchema(wsdlDefinition, schemas, includeElement);
                        }
                    }
                }
            }
        }
    }
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) Vector(java.util.Vector) Map(java.util.Map)

Example 2 with XmlSchema

use of org.apache.ws.commons.schema.XmlSchema in project tdi-studio-se by Talend.

the class ComponentBuilder method collectAllXmlSchemaElement.

/**
     * DOC gcui Comment method "collectAllElement".
     * 
     * @return
     */
private void collectAllXmlSchemaElement() {
    for (int i = 0; i < wsdlTypes.size(); i++) {
        XmlSchema xmlSchema = (wsdlTypes.elementAt(i));
        if (xmlSchema == null) {
            continue;
        }
        XmlSchemaObjectTable elements = xmlSchema.getElements();
        Iterator elementsItr = elements.getValues();
        while (elementsItr.hasNext()) {
            XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) elementsItr.next();
            allXmlSchemaElement.add(xmlSchemaElement);
        }
    }
}
Also used : XmlSchemaObjectTable(org.apache.ws.commons.schema.XmlSchemaObjectTable) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Iterator(java.util.Iterator)

Example 3 with XmlSchema

use of org.apache.ws.commons.schema.XmlSchema in project tdi-studio-se by Talend.

the class ComponentBuilder method createSchemaFromTypes.

protected Vector<XmlSchema> createSchemaFromTypes(List<Definition> wsdlDefinitions) throws WSDLException {
    Vector<XmlSchema> schemas = new Vector<XmlSchema>();
    Set<String> imports = new HashSet<String>();
    org.w3c.dom.Element schemaElementt = null;
    Map importElement = null;
    List includeElement = null;
    for (Definition def : wsdlDefinitions) {
        if (def.getTypes() != null) {
            Vector schemaExtElem = findExtensibilityElement(def.getTypes().getExtensibilityElements(), "schema");
            for (int i = 0; i < schemaExtElem.size(); i++) {
                ExtensibilityElement schemaElement = (ExtensibilityElement) schemaExtElem.elementAt(i);
                if (schemaElement != null && schemaElement instanceof UnknownExtensibilityElement) {
                    schemaElementt = ((UnknownExtensibilityElement) schemaElement).getElement();
                    String documentBase = ((javax.wsdl.extensions.schema.Schema) schemaElement).getDocumentBaseURI();
                    XmlSchema schema = createschemafromtype(schemaElementt, def, documentBase);
                    if (schema != null) {
                        schemas.add(schema);
                        if (schema.getTargetNamespace() != null) {
                            schemaNames.add(schema.getTargetNamespace());
                        }
                    }
                    importElement = ((javax.wsdl.extensions.schema.Schema) schemaElement).getImports();
                    if (importElement != null && importElement.size() > 0) {
                        findImportSchema(def, schemas, importElement, imports);
                    }
                }
                if (schemaElement != null && schemaElement instanceof javax.wsdl.extensions.schema.Schema) {
                    schemaElementt = ((javax.wsdl.extensions.schema.Schema) schemaElement).getElement();
                    String documentBase = ((javax.wsdl.extensions.schema.Schema) schemaElement).getDocumentBaseURI();
                    Boolean isHaveImport = false;
                    importElement = ((javax.wsdl.extensions.schema.Schema) schemaElement).getImports();
                    if (importElement != null && importElement.size() > 0) {
                        Iterator keyIterator = importElement.keySet().iterator();
                        // }
                        if (importElement.size() > 0) {
                            isHaveImport = true;
                        }
                    // validateImportUrlPath(importElement);
                    }
                    XmlSchema schema = createschemafromtype(schemaElementt, def, documentBase);
                    if (schema != null) {
                        schemas.add(schema);
                        if (schema.getTargetNamespace() != null) {
                            schemaNames.add(schema.getTargetNamespace());
                        }
                    }
                    if (isHaveImport) {
                        findImportSchema(def, schemas, importElement, imports);
                    }
                }
            }
        }
    }
    return schemas;
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) Definition(javax.wsdl.Definition) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) XmlSchema(org.apache.ws.commons.schema.XmlSchema) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) Vector(java.util.Vector) Map(java.util.Map) HashSet(java.util.HashSet)

Example 4 with XmlSchema

use of org.apache.ws.commons.schema.XmlSchema in project tdi-studio-se by Talend.

the class ComponentBuilder method findIncludesSchema.

/**
     * DOC gcui Comment method "findIncludesSchema".
     * 
     * @param wsdlDefinition
     * @param schemas
     * @param includeElement
     * @throws WSDLException
     */
private void findIncludesSchema(Definition wsdlDefinition, Vector schemas, List includeElement) throws WSDLException {
    org.w3c.dom.Element schemaElementt;
    for (int i = 0; i < includeElement.size(); i++) {
        schemaElementt = ((com.ibm.wsdl.extensions.schema.SchemaReferenceImpl) includeElement.get(i)).getReferencedSchema().getElement();
        String documentBase = ((com.ibm.wsdl.extensions.schema.SchemaReferenceImpl) includeElement.get(i)).getReferencedSchema().getDocumentBaseURI();
        XmlSchema schemaInclude = createschemafromtype(schemaElementt, wsdlDefinition, documentBase);
        if (schemaInclude != null) {
            schemas.add(schemaInclude);
            if (schemaInclude.getTargetNamespace() != null) {
                schemaNames.add(schemaInclude.getTargetNamespace());
            }
        }
    }
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema)

Example 5 with XmlSchema

use of org.apache.ws.commons.schema.XmlSchema in project tdi-studio-se by Talend.

the class ComponentBuilder method createschemafromtype.

private XmlSchema createschemafromtype(org.w3c.dom.Element schemaElement, Definition wsdlDefinition, String documentBase) throws WSDLException {
    if (schemaElement == null) {
        throw new WSDLException(WSDLException.INVALID_WSDL, "Unable to find schema extensibility element in WSDL");
    }
    XmlSchema xmlSchema = null;
    XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
    xmlSchemaCollection.setBaseUri(fixDocumentBase(documentBase));
    xmlSchema = xmlSchemaCollection.read(schemaElement);
    return xmlSchema;
}
Also used : WSDLException(javax.wsdl.WSDLException) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection)

Aggregations

XmlSchema (org.apache.ws.commons.schema.XmlSchema)51 QName (javax.xml.namespace.QName)37 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)37 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)35 Test (org.junit.Test)35 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)28 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)11 ArrayList (java.util.ArrayList)10 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)6 Iterator (java.util.Iterator)6 List (java.util.List)5 XmlSchemaCollection (org.apache.ws.commons.schema.XmlSchemaCollection)5 Map (java.util.Map)4 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)4 HashMap (java.util.HashMap)3 XmlSchemaComplexContent (org.apache.ws.commons.schema.XmlSchemaComplexContent)3 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)3 XmlSchemaObjectTable (org.apache.ws.commons.schema.XmlSchemaObjectTable)3 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)3 WfsException (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException)3