use of org.apache.ws.commons.schema.XmlSchemaInclude in project cxf by apache.
the class ServiceWSDLBuilder method buildTypes.
protected void buildTypes(final Collection<SchemaInfo> schemas, final Map<String, SchemaInfo> imports, final Definition def) {
Types types = def.createTypes();
for (SchemaInfo schemaInfo : schemas) {
Schema schemaImpl = getSchemaImplementation(def);
schemaImpl.setRequired(true);
schemaImpl.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl.setElement(schemaInfo.getElement());
for (XmlSchemaExternal ext : schemaInfo.getSchema().getExternals()) {
if (ext.getSchema() == null) {
continue;
}
if (ext instanceof XmlSchemaImport) {
SchemaImport imp = schemaImpl.createImport();
imp.setNamespaceURI(((XmlSchemaImport) ext).getNamespace());
imp.setSchemaLocationURI(((XmlSchemaImport) ext).getSchemaLocation());
Schema schemaImpl2 = getSchemaImplementation(def);
schemaImpl2.setRequired(true);
schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
try {
schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
} catch (XmlSchemaSerializerException e) {
// ignore
}
imp.setReferencedSchema(schemaImpl2);
schemaImpl.addImport(imp);
} else if (ext instanceof XmlSchemaInclude) {
SchemaReference imp = schemaImpl.createInclude();
imp.setSchemaLocationURI(((XmlSchemaInclude) ext).getSchemaLocation());
Schema schemaImpl2 = getSchemaImplementation(def);
schemaImpl2.setRequired(true);
schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
try {
schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
} catch (XmlSchemaSerializerException e) {
// ignore
}
imp.setReferencedSchema(schemaImpl2);
schemaImpl.addInclude(imp);
} else if (ext instanceof XmlSchemaRedefine) {
SchemaReference imp = schemaImpl.createRedefine();
imp.setSchemaLocationURI(((XmlSchemaRedefine) ext).getSchemaLocation());
Schema schemaImpl2 = getSchemaImplementation(def);
schemaImpl2.setRequired(true);
schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
try {
schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
} catch (XmlSchemaSerializerException e) {
// ignore
}
imp.setReferencedSchema(schemaImpl2);
schemaImpl.addRedefine(imp);
}
}
types.addExtensibilityElement(schemaImpl);
}
def.setTypes(types);
}
Aggregations