public boolean equals(XMLGrammarDescription desc1, XMLGrammarDescription desc2) {
if (desc1 instanceof XMLSchemaDescription) {
if (!(desc2 instanceof XMLSchemaDescription)) {
return false;
}
final XMLSchemaDescription sd1 = (XMLSchemaDescription) desc1;
final XMLSchemaDescription sd2 = (XMLSchemaDescription) desc2;
final String targetNamespace = sd1.getTargetNamespace();
if (targetNamespace != null) {
if (!targetNamespace.equals(sd2.getTargetNamespace())) {
return false;
}
}
else if (sd2.getTargetNamespace() != null) {
return false;
}
// The JAXP 1.3 spec says that the implementation can assume that
// if two schema location hints are the same they always resolve
// to the same document. In the default grammar pool implementation
// we only look at the target namespaces. Here we also compare
// location hints.
final String expandedSystemId = sd1.getExpandedSystemId();
if (expandedSystemId != null) {
if (!expandedSystemId.equals(sd2.getExpandedSystemId())) {
return false;
}
}
else if (sd2.getExpandedSystemId() != null) {
return false;
}
return true;
}
return desc1.equals(desc2);