{
errors.clear();
}
// Work on a cloned and relaxed registries
Registries clonedRegistries = cloneRegistries();
clonedRegistries.setRelaxed();
// Load the schemas
for ( Schema schema : schemas )
{
boolean singleSchemaLoaded = load( clonedRegistries, schema );
// return false if the schema was not loaded in the first place
if ( !singleSchemaLoaded )
{
return false;
}
}
// Build the cross references
errors = clonedRegistries.buildReferences();
if ( errors.isEmpty() )
{
// Ok no errors. Check the registries now
errors = clonedRegistries.checkRefInteg();
if ( errors.isEmpty() )
{
// We are golden : let's apply the schema in the real registries
registries.setRelaxed();
// Load the schemas
for ( Schema schema : schemas )
{
load( registries, schema );
// Update the schema dependences if needed
if ( schema.getDependencies() != null )
{
for ( String dep : schema.getDependencies() )
{
Set<String> deps = schemaDependences.get( dep );
if ( deps == null )
{
deps = new HashSet<String>();
deps.add( schema.getSchemaName() );
}
// Replace the dependences
schemaDependences.put( dep, deps );
}
}
// add the schema to the schemaLoader
schemaLoader.addSchema( schema );
}
// Build the cross references
errors = registries.buildReferences();
registries.setStrict();
loaded = true;
}
}
// clear the cloned registries
clonedRegistries.clear();
return loaded;
}