// TODO: undefined grammar check.
Expression grammarTopLevel = Expression.nullSet;
itr = grammar.iterateSchemas();
while( itr.hasNext() ) {
XMLSchemaSchema schema = (XMLSchemaSchema)itr.next();
if( !isSchemaDefined(schema) ) {
reportError(
backwardReference.getReferer(schema),
ERR_UNDEFINED_SCHEMA,
new Object[]{schema.targetNamespace} );
return; // surpress excessive error messages.
}
// detect undefined declarations.
detectUndefinedOnes( schema.attributeDecls, ERR_UNDEFINED_ATTRIBUTE_DECL );
detectUndefinedOnes( schema.attributeGroups, ERR_UNDEFINED_ATTRIBUTE_GROUP );
detectUndefinedOnes( schema.complexTypes, ERR_UNDEFINED_COMPLEX_TYPE );
detectUndefinedOnes( schema.elementDecls, ERR_UNDEFINED_ELEMENT_DECL );
detectUndefinedOnes( schema.groupDecls, ERR_UNDEFINED_GROUP );
detectUndefinedOnes( schema.simpleTypes, ERR_UNDEFINED_SIMPLE_TYPE );
// TODO: it is now possible to check that the derivation doesn't
// violate the final property of the parent type.
// prepare top-level expression.
// at the same time, compute the substitutions field of ElementDeclExps.
// TODO: make sure this is a correct implementation
// any globally declared element can be a top-level element.
Expression exp = Expression.nullSet;
ReferenceExp[] elems = schema.elementDecls.getAll();
for( int i=0; i<elems.length; i++ )
exp = pool.createChoice( exp, elems[i] );
schema.topLevel = exp;
// toplevel of the grammar will be choices of toplevels of all modules.
grammarTopLevel = pool.createChoice( grammarTopLevel, exp );
}
// some of the back-patching process relies on this grammar.topLevel field.
grammar.topLevel = grammarTopLevel;
// perform all back patching.
runBackPatchJob();
// perform substitutability computation
//-----------------------------------------
// this process depends on the result of back-patching.
// a buffer which will be used to check the recursive substitution group definition.
final Set recursiveSubstBuffer = new java.util.HashSet();
itr = grammar.iterateSchemas();
while( itr.hasNext() ) {
XMLSchemaSchema schema = (XMLSchemaSchema)itr.next();
ReferenceExp[] elems = schema.elementDecls.getAll();
for( int i=0; i<elems.length; i++ ) {
final ElementDeclExp e = (ElementDeclExp)elems[i];