XSType myType;
if (isReference()) {
XSAttribute attribute = getXSSchema().getAttribute(getName());
if (attribute == null) {
throw new LocSAXException("Invalid attribute reference: No type named " + getName() + " defined.",
getXsTAttribute().getLocator());
}
myType = attribute.getType();
} else if (isInnerSimpleType()) {
XsTLocalSimpleType innerSimpleType = getXsTAttribute().getSimpleType();
myType = getXSSchema().getXSObjectFactory().newXSType(this, innerSimpleType);
myType.validate();
} else {
XsQName typeName = getXsTAttribute().getType();
if (typeName == null) {
typeName = XSAnySimpleType.getInstance().getName();
}
myType = getXSSchema().getType(typeName);
if (myType == null) {
throw new LocSAXException("Invalid attribute: The referenced type " + typeName + " is not defined in the schema.",
getXsTAttribute().getLocator());
}
}
this.type = myType;
}