List<XmlSchema> xmlSchemaList) throws Exception {
XmlSchemaType schemaType = null;
Iterator i = xmlSchemaList.iterator();
while (i.hasNext()) {
XmlSchema xmlSchemaType = (XmlSchema) i.next();
if (part.getElementName() != null) {
XmlSchemaElement schemaElement = xmlSchemaType
.getElementByName(part.getElementName());
if (schemaElement == null) {
QName elName = part.getElementName();
String prefix = definition.getPrefix(elName
.getNamespaceURI());
QName name = new QName(elName.getNamespaceURI(), prefix
+ ":" + elName.getLocalPart(), prefix);
schemaElement = xmlSchemaType.getElementByName(name);
}
if (schemaElement != null) {
if (schemaElement.getSchemaType() != null) {
schemaType = schemaElement.getSchemaType();
}
}
} else {
if (part.getTypeName() != null) {
schemaType = xmlSchemaType
.getTypeByName(part.getTypeName());
// Endpoint reference types will give a null schemaType
// here, so we need to
// go through the list of imports to find the definition for
// an Endpoint
// reference type.
if (schemaType == null
&& xmlSchemaType.getIncludes().getCount() > 0) {
XmlSchemaObjectCollection includes = xmlSchemaType
.getIncludes();
Iterator includeIter = includes.getIterator();
while (includeIter.hasNext()) {
Object obj = includeIter.next();
if (!(obj instanceof XmlSchemaImport)) {
continue;
}
XmlSchemaImport xmlImport = (XmlSchemaImport) obj;
if (xmlImport.getNamespace().equals(
part.getTypeName().getNamespaceURI())) {
XmlSchema importSchema = xmlImport.getSchema();
schemaType = importSchema.getTypeByName(part
.getTypeName());
}
}
}