MetadataUtil.MetadataResolver mdresolver = new MetadataResolverImpl(sd);
Map<String, SDDocument> docs = MetadataUtil.getMetadataClosure(primary, mdresolver, true);
List<Source> list = 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);
list.add(new DOMSource(dom, doc.getURL().toExternalForm()));
}
}
//addSchemaSource(list);
return list.toArray(new Source[list.size()]) ;
}