Iterator iterator = typesList.getExtensibilityElements().iterator();
while (iterator.hasNext()) {
WSDLExtensibilityElement element = (WSDLExtensibilityElement) iterator.next();
boolean targetnamespaceFound = false;
if (ExtensionConstants.SCHEMA.equals(element.getType())) {
Schema schema = (Schema) element;
Element schemaElement = schema.getElement();
//first check whether the schema include import statements.
//As per the nature of WSDL if the schema has imports ONLY, then the
//schema element need not contain a target namespace.
NodeList importNodeList = schemaElement.getElementsByTagNameNS(schemaElement.getNamespaceURI(), "import");
NodeList allNodes = schemaElement.getElementsByTagName("*");
//checking the number of child elements and the number of import elements should get us what we need
//if these match, that means we have only import statements
if (importNodeList.getLength()== allNodes.getLength()) {
return;
}
NamedNodeMap attributes = schemaElement.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
if (TARGETNAMESPACE_STRING.equalsIgnoreCase(
attributes.item(i).getNodeName())) {
targetnamespaceFound = true;
break;
}
}
if (!targetnamespaceFound)
throw new CodeGenerationException(
CodegenMessages.getMessage("extension.invalidWSDL",schema.getName().toString()));
}
}
}