if (s.getNamespaceURI().equals(part.getElementQName().getNamespaceURI())) {
schemaInfo = s;
break;
}
}
XmlSchema schema;
if (schemaInfo == null) {
schema = schemas.newXmlSchemaInCollection(part.getElementQName().getNamespaceURI());
if (qualifiedSchemas) {
schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
}
NamespaceMap nsMap = new NamespaceMap();
nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, schema.getTargetNamespace());
nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
schema.setNamespaceContext(nsMap);
schemaInfo = new SchemaInfo(part.getElementQName().getNamespaceURI());
schemaInfo.setSchema(schema);
serviceInfo.addSchema(schemaInfo);
} else {
schema = schemaInfo.getSchema();
}
XmlSchemaComplexType ct = new XmlSchemaComplexType(schema);
ct.setName(part.getElementQName().getLocalPart());
// Before updating everything, make sure we haven't added this
// type yet. Multiple methods that throw the same exception
// types will cause duplicates.
if (schema.getTypeByName(ct.getQName()) != null) {
return;
}
XmlSchemaElement el = new XmlSchemaElement();
XmlSchemaUtils.setElementQName(el, part.getElementQName());
schema.getItems().add(el);
schema.getElements().add(el.getQName(), el);
part.setXmlSchema(el);
schema.getItems().add(ct);
schema.addType(ct);
schemaInfo.setElement(null);
el.setSchemaTypeName(part.getElementQName());
XmlSchemaSequence seq = new XmlSchemaSequence();
ct.setParticle(seq);