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