if(r==null) {
reportError( ERR_UNDECLARED_PREFIX, typeQName );
// TODO: implement UndefinedType, that is used only when an error is encountered.
// it should accept anything and any facets.
// recover by assuming string.
return new XSDatatypeExp(StringType.theInstance,pool);
}
if( isSchemaNamespace(r[0]) ) {
// internal definitions should be consulted first.
XSDatatype dt = resolveBuiltinDataType(r[1]);
if(dt!=null) return new XSDatatypeExp(dt,pool);
// the name was not found.
// maybe we are parsing schema for schema.
// consult the externally defined types.
}
final SimpleTypeExp sexp = getOrCreateSchema(r[0]).simpleTypes.
getOrCreate(r[1]);
backwardReference.memorizeLink(sexp);
// simple type might be re-defined later.
// therefore, we always need a late-binding datatype,
// even if the datatype is defined already.
return new XSDatatypeExp(r[0],r[1],this,new XSDatatypeExp.Renderer(){
public XSDatatype render( XSDatatypeExp.RenderingContext context ) {
if(sexp.getType()!=null)
return sexp.getType().getType(context);
else
// undefined error is alreadyreported by