}
protected void buildTypes(final Collection<SchemaInfo> schemas,
final Map<String, SchemaInfo> imports,
final Definition def) {
Types types = def.createTypes();
Document doc = null;
try {
doc = XMLUtils.newDocument();
} catch (ParserConfigurationException e) {
throw new RuntimeException("DOM configuration problem", e);
}
Element nd = XMLUtils.createElementNS(doc, new QName(WSDLConstants.NS_SCHEMA_XSD,
"schema"));
nd.setAttribute("xmlns", WSDLConstants.NS_SCHEMA_XSD);
doc.appendChild(nd);
for (SchemaInfo schemaInfo : schemas) {
if (!useSchemaImports) {
SchemaImpl schemaImpl = new SchemaImpl();
schemaImpl.setRequired(true);
schemaImpl.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl.setElement(schemaInfo.getElement());
types.addExtensibilityElement(schemaImpl);
} else {
//imports
String name = baseFileName + "_schema" + (++xsdCount) + ".xsd";
Element imp = XMLUtils.createElementNS(doc,
new QName(WSDLConstants.NS_SCHEMA_XSD,
"import"));
imp.setAttribute("schemaLocation", name);
imp.setAttribute("namespace", schemaInfo.getNamespaceURI());
nd.appendChild(imp);
imports.put(name, schemaInfo);
}
}
if (useSchemaImports) {
SchemaImpl schemaImpl = new SchemaImpl();
schemaImpl.setRequired(true);
schemaImpl.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl.setElement(nd);
types.addExtensibilityElement(schemaImpl);
}
def.setTypes(types);
}