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());
for (int x = 0; x < schemaInfo.getSchema().getIncludes().getCount(); x++) {
XmlSchemaExternal ext = (XmlSchemaExternal)schemaInfo.getSchema()
.getIncludes().getItem(x);
if (ext.getSchema() == null) {
continue;
}
if (ext instanceof XmlSchemaImport) {
SchemaImport imp = schemaImpl.createImport();
imp.setNamespaceURI(((XmlSchemaImport)ext).getNamespace());
imp.setSchemaLocationURI(((XmlSchemaImport)ext).getSchemaLocation());
SchemaImpl schemaImpl2 = new SchemaImpl();
schemaImpl2.setRequired(true);
schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
try {
schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
} catch (XmlSchemaSerializerException e) {
//ignore
}
imp.setReferencedSchema(schemaImpl2);
schemaImpl.addImport(imp);
} else if (ext instanceof XmlSchemaInclude) {
SchemaReference imp = schemaImpl.createInclude();
imp.setSchemaLocationURI(((XmlSchemaInclude)ext).getSchemaLocation());
SchemaImpl schemaImpl2 = new SchemaImpl();
schemaImpl2.setRequired(true);
schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
try {
schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
} catch (XmlSchemaSerializerException e) {
//ignore
}
imp.setReferencedSchema(schemaImpl2);
schemaImpl.addInclude(imp);
} else if (ext instanceof XmlSchemaRedefine) {
SchemaReference imp = schemaImpl.createRedefine();
imp.setSchemaLocationURI(((XmlSchemaRedefine)ext).getSchemaLocation());
SchemaImpl schemaImpl2 = new SchemaImpl();
schemaImpl2.setRequired(true);
schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
try {
schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
} catch (XmlSchemaSerializerException e) {
//ignore
}
imp.setReferencedSchema(schemaImpl2);
schemaImpl.addRedefine(imp);
}
}
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);
}