* PopulatedExtensionRegistry registers SchemaDeserializer by default, but
* if the user chooses not to register a suitable deserializer then the
* UnknownDeserializer will be used, returning an UnknownExtensibilityElement.
*/
Schema schema = null;
SchemaReference schemaRef = null;
try
{
QName elementType = QNameUtils.newQName(el);
ExtensionDeserializer exDS =
extReg.queryDeserializer(parentType, elementType);
//Now unmarshall the DOM element.
ExtensibilityElement ee =
exDS.unmarshall(parentType, elementType, el, def, extReg);
if (ee instanceof Schema)
{
schema = (Schema) ee;
}
else
{
//Unknown extensibility element, so don't do any more schema parsing on it.
return ee;
}
//Keep track of parsed schemas to avoid duplicating Schema objects
//through duplicate or circular references (eg: A imports B imports A).
if (schema.getDocumentBaseURI() != null)
{
this.allSchemas.put(schema.getDocumentBaseURI(), schema);
}
//At this point, any SchemaReference objects held by the schema will not
//yet point to their referenced schemas, so we must now retrieve these
//schemas and set the schema references.
//First, combine the schema references for imports, includes and redefines
//into a single list
ArrayList allSchemaRefs = new ArrayList();
Collection ic = schema.getImports().values();
Iterator importsIterator = ic.iterator();
while(importsIterator.hasNext())
{
allSchemaRefs.addAll( (Collection) importsIterator.next() );
}
allSchemaRefs.addAll(schema.getIncludes());
allSchemaRefs.addAll(schema.getRedefines());
//Then, retrieve the schema referred to by each schema reference. If the
//schema has been read in previously, use the existing schema object.
//Otherwise unmarshall the DOM element into a new schema object.
ListIterator schemaRefIterator = allSchemaRefs.listIterator();
while(schemaRefIterator.hasNext())
{
try
{
schemaRef = (SchemaReference) schemaRefIterator.next();
if (schemaRef.getSchemaLocationURI() == null)
{
//cannot get the referenced schema, so ignore this schema reference
continue;
}
if (verbose)
{
System.out.println("Retrieving schema at '" +
schemaRef.getSchemaLocationURI() +
(schema.getDocumentBaseURI() == null
? "'."
: "', relative to '" +
schema.getDocumentBaseURI() + "'."));
}
InputStream inputStream = null;
InputSource inputSource = null;
//This is the child schema referred to by the schemaReference
Schema referencedSchema = null;
//This is the child schema's location obtained from the WSDLLocator or the URL
String location = null;
if (loc != null)