} else {
//there MUST be an element in the definitions with this name.
XSDElementDeclaration elementDecl =
getXSDElementDeclaration(elementName, definitions);
if (null == elementDecl) {
throw new YSchemaBuildingException(
"Expected a corresponding element definition for " +
elementName);
} else if (isAnElementReference(elementDecl)) {
throw new YSchemaBuildingException(
"elementDecl = " + XSDUtil.convertToString(elementDecl));
} else {
elements.add(elementDecl);
}
}
} else {
//there exists an element name and a type name therefore we must search the
//definitions list for a type definition. And then build an element from the type.
XSDTypeDefinition typeDef =
getXSDTypeDefinition(typeName, definitions, isSchema4Schema);
if (null == typeDef) {
throw new YSchemaBuildingException(
"Expected a corresponding type definition for " + typeName);
}
XSDElementDeclaration element = _xsdFactory.createXSDElementDeclaration();
element.setName(elementName);