Map<String, SDDocument> docs = MetadataUtil.getMetadataClosure(primary, mdresolver, true);
List<Source> list = new ArrayList<Source>();
List<Source> externalSchemas = new ArrayList<Source>();
for(Map.Entry<String, SDDocument> entry : docs.entrySet()) {
SDDocument doc = entry.getValue();
// Add all xsd:schema fragments from all WSDLs. That should form a closure of schemas.
if (doc.isWSDL()) {
Document dom = createDOM(doc);
// Get xsd:schema node from WSDL's DOM
addSchemaFragmentSource(dom, doc.getURL().toExternalForm(), list);
} else if (doc.isSchema()) {
// If there are multiple schemas with the same targetnamespace,
// JAXP works only with the first one. Above, all schema fragments may have the same targetnamespace,
// and that means it will not include all the schemas. Since we have a list of schemas, just add them.
Document dom = createDOM(doc);
externalSchemas.add(new DOMSource(dom, doc.getURL().toExternalForm()));
}
}
// "honour-all-schemaLocations" feature only applies today to multiple
// imports for the same namespace contained directly or indirectly from
// a root schema document. By adding wsdl schema fragments firs in the