boolean wrappeeQualified = (o!= null && o instanceof Boolean) ? ((Boolean) o) : false;
HashMap<String, Schema> xsds = new HashMap<String, Schema>();
HashMap<String, Set<String>> imports = new HashMap<String, Set<String>>();
for(WrapperParameter wp : wrappers) {
String tns = wp.getName().getNamespaceURI();
Schema xsd = xsds.get(tns);
if (xsd == null) {
xsd = create(tns);
xsd.targetNamespace(tns);
if (wrappeeQualified) xsd._attribute("elementFormDefault", "qualified");
xsds.put(tns, xsd);
}
for (ParameterImpl p : wp.getWrapperChildren() ) {
String nsToImport = (p.getBinding().isBody())? bodyParamNS(p): null;
if (nsToImport != null && !nsToImport.equals(tns) && !nsToImport.equals("http://www.w3.org/2001/XMLSchema")) {
Set<String> importSet = imports.get(tns);
if (importSet == null) {
importSet = new HashSet<String>();
imports.put(tns, importSet);
}
importSet.add(nsToImport);
}
}
}
for(Entry<String, Set<String>> entry: imports.entrySet()) {
String tns = entry.getKey();
Set<String> importSet = entry.getValue();
Schema xsd = xsds.get(tns);
for(String nsToImport : importSet) xsd._namespace(nsToImport, true);
for(String nsToImport : importSet) {
com.sun.xml.ws.wsdl.writer.document.xsd.Import imp = xsd._import();
imp.namespace(nsToImport);
}
}
return xsds;
}