while( it.hasNext() ) {
IncludeHandler inc = (IncludeHandler) it.next();
logger.finest("compressing include " + inc.getSchemaLocation());
if (inc != null && inc.getSchemaLocation() != null) {
Schema cs;
URI incURI = null;
if (thisURI == null) {
try {
incURI = new URI(inc.getSchemaLocation());
} catch (URISyntaxException e) {
logger.warning(e.getMessage());
}
} else {
incURI = thisURI.normalize().resolve(inc.getSchemaLocation());
}
cs = SchemaFactory.getInstance(targetNamespace, incURI, logger.getLevel());
if (uri != null) {
uri = incURI.resolve(uri);
} else {
uri = incURI;
}
// already compressed
addSchema(cs);
}
}
}
includes = null;
// imports may be schema or schemaHandler
if (this.imports != null) {
// have now loaded the included stuff.
LinkedList imports1 = new LinkedList();
it = this.imports.iterator();
while( it.hasNext() ) {
Object obj = it.next();
if (obj instanceof ImportHandler) {
ImportHandler imp = (ImportHandler) obj;
URI incURI = null;
// if ((imp.getSchemaLocation() != null) && (thisURI != null)) {
// incURI = thisURI.normalize().resolve(imp
// .getSchemaLocation());
// }
// fix from chris dillard
if (imp.getSchemaLocation() != null) {
if (thisURI != null) {
// For resolving relative URIs
incURI = thisURI.normalize().resolve(imp.getSchemaLocation());
} else {
// If thisURI is null, we have to assume the
// URI is absolute.
incURI = imp.getSchemaLocation();
}
}
Schema cs = SchemaFactory.getInstance(imp.getNamespace(), incURI, logger.getLevel());
imports1.add(cs);
} else {
imports1.add(obj);
}