XSType myType;
if (isReference()) {
XSElement element = getXSSchema().getElement(getName());
if (element == null) {
throw new LocSAXException("Invalid element reference: " + getName() + " is not defined.",
getLocator());
}
element.validate();
myType = element.getType();
} else {
XsTElement element = getXsTElement();
if (isInnerSimpleType()) {
myType = getXSSchema().getXSObjectFactory().newXSType(this, element.getSimpleType());
} else if (isInnerComplexType()) {
myType = getXSSchema().getXSObjectFactory().newXSType(this, element.getComplexType());
} else {
XsQName typeName = element.getType();
if (typeName == null) {
throw new LocSAXException("Invalid element: Either of its 'type' or 'ref' attributes or its 'simpleType' or 'complexType' children must be set.",
getLocator());
}
myType = getXSSchema().getType(typeName);
if (myType == null) {
throw new LocSAXException("Invalid element: The type " + typeName + " is not defined.",
getLocator());
}
}
}
this.type = myType;