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;
    }
    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);
}

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 ; } 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 ) ; }
this method checks whether two grammars are the same . currently , we compare the root element names for dtd grammars and the target namespaces for schema grammars . the application can override this behaviour and add its own logic .
