Buggy code:
} static class ErrorHandler implements org . xml . sax . ErrorHandler { public void warning ( SAXParseException ex ) { } public void error ( SAXParseException ex ) { } public void fatalError ( SAXParseException ex ) { } private String getLocationString ( SAXParseException ex ) { } } private int attributeTypeName ( XMLAttributeDecl attrDecl ) { } private void validateElementAndAttributes ( QName element , XMLAttrList attrList ) throws Exception { if ( ( ( ( fGrammar ) == null ) && ( ! ( fValidating ) ) ) && ( ! ( fNamespacesEnabled ) ) ) { fCurrentElementIndex = - 1 ; fCurrentContentSpecType = - 1 ; fInElementContent = false ; if ( ( fAttrListHandle ) != ( - 1 ) ) { fAttrList . endAttrList ( ) ; int index = fAttrList . getFirstAttr ( fAttrListHandle ) ; while ( index != ( - 1 ) ) { if ( fStringPool . equalNames ( fAttrList . getAttrName ( index ) , fXMLLang ) ) { fDocumentScanner . checkXMLLangAttributeValue ( fAttrList . getAttValue ( index ) ) ; break ; } index = fAttrList . getNextAttr ( index ) ; } } return ; } int elementIndex = - 1 ; if ( ( fGrammar ) != null ) { if ( XMLValidator . DEBUG_SCHEMA_VALIDATION ) { System . out . println ( ( ( ( "localpart:<seq2seq4repair_space>'" + ( fStringPool . toString ( element . localpart ) ) ) + "'<seq2seq4repair_space>and<seq2seq4repair_space>scope<seq2seq4repair_space>:<seq2seq4repair_space>" ) + ( fCurrentScope ) ) ) ; } if ( ( element . uri ) == ( - 1 ) ) { elementIndex = fGrammar . getElementDeclIndex ( element . localpart , fCurrentScope ) ; } else { elementIndex = fGrammar . getElementDeclIndex ( element . localpart , TOP_LEVEL_SCOPE ) ; } if ( elementIndex == ( - 1 ) ) { if ( ( fGrammarIsSchemaGrammar ) && ( ( fCurrentElementIndex ) != ( - 1 ) ) ) { TraverseSchema . ComplexTypeInfo baseTypeInfo = null ; baseTypeInfo = ( ( org . apache . xerces . validators . schema . SchemaGrammar ) ( fGrammar ) ) . getElementComplexTypeInfo ( fCurrentElementIndex ) ; while ( baseTypeInfo != null ) { elementIndex = fGrammar . getElementDeclIndex ( element . localpart , baseTypeInfo . scopeDefined ) ; if ( elementIndex > ( - 1 ) ) { break ; } baseTypeInfo = baseTypeInfo . baseComplexTypeInfo ; } } if ( ( ( element . uri ) == ( - 1 ) ) && ( elementIndex == ( - 1 ) ) ) { elementIndex = fGrammar . getElementDeclIndex ( element . localpart , TOP_LEVEL_SCOPE ) ; element . uri = fStringPool . addSymbol ( "" ) ; } if ( elementIndex == ( - 1 ) ) if ( XMLValidator . DEBUG_SCHEMA_VALIDATION ) System . out . println ( ( ( ( ( ( ( ( ( ( ( ( ( "!!!<seq2seq4repair_space>can<seq2seq4repair_space>not<seq2seq4repair_space>find<seq2seq4repair_space>elementDecl<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>grammar,<seq2seq4repair_space>" + "<seq2seq4repair_space>the<seq2seq4repair_space>element<seq2seq4repair_space>localpart:<seq2seq4repair_space>" ) + ( element . localpart ) ) + "[" ) + ( fStringPool . toString ( element . localpart ) ) ) + "]" ) + "<seq2seq4repair_space>the<seq2seq4repair_space>element<seq2seq4repair_space>uri:<seq2seq4repair_space>" ) + ( element . uri ) ) + "[" ) + ( fStringPool . toString ( element . uri ) ) ) + "]" ) + "<seq2seq4repair_space>and<seq2seq4repair_space>the<seq2seq4repair_space>current<seq2seq4repair_space>enclosing<seq2seq4repair_space>scope:<seq2seq4repair_space>" ) + ( fCurrentScope ) ) ) ; } if ( XMLValidator . DEBUG_SCHEMA_VALIDATION ) { fGrammar . getElementDecl ( elementIndex , fTempElementDecl ) ; System . out . println ( ( ( ( ( ( ( ( ( "elementIndex:<seq2seq4repair_space>" + elementIndex ) + "<seq2seq4repair_space>\n<seq2seq4repair_space>and<seq2seq4repair_space>itsName<seq2seq4repair_space>:<seq2seq4repair_space>\'" ) + ( fStringPool . toString ( fTempElementDecl . name . localpart ) ) ) + "\'<seq2seq4repair_space>\n<seq2seq4repair_space>its<seq2seq4repair_space>ContentType:" ) + ( fTempElementDecl . type ) ) + "\n<seq2seq4repair_space>its<seq2seq4repair_space>ContentSpecIndex<seq2seq4repair_space>:<seq2seq4repair_space>" ) + ( fTempElementDecl . contentSpecIndex ) ) + "\n" ) ) ; } } if ( ( fGrammarIsSchemaGrammar ) && ( elementIndex != ( - 1 ) ) ) { String anotherSchemaURI = ( ( org . apache . xerces . validators . schema . SchemaGrammar ) ( fGrammar ) ) . getElementFromAnotherSchemaURI ( elementIndex ) ; if ( anotherSchemaURI != null ) { <START_BUG> fCurrentSchemaURI = fStringPool . addSymbol ( anotherSchemaURI ) ; <END_BUG> switchGrammar ( fCurrentSchemaURI ) ; } } int contentSpecType = getContentSpecType ( elementIndex ) ; if ( ( contentSpecType == ( - 1 ) ) && ( fValidating ) ) { reportRecoverableXMLError ( MSG_ELEMENT_NOT_DECLARED , VC_ELEMENT_VALID , element . rawname ) ; } if ( ( ( fGrammar ) != null ) && ( elementIndex != ( - 1 ) ) ) { fAttrListHandle = addDefaultAttributes ( elementIndex , attrList , fAttrListHandle , fValidating , ( ( fStandaloneReader ) != ( - 1 ) ) ) ; } if ( ( fAttrListHandle ) != ( - 1 ) ) { fAttrList . endAttrList ( ) ; } if ( XMLValidator . DEBUG_PRINT_ATTRIBUTES ) { String elementStr = fStringPool . toString ( element . rawname ) ; System . out . print ( ( "startElement:<seq2seq4repair_space><" + elementStr ) ) ; if ( ( fAttrListHandle ) != ( - 1 ) ) { int index = attrList . getFirstAttr ( fAttrListHandle ) ; while ( index != ( - 1 ) ) { System . out . print ( ( ( ( ( "<seq2seq4repair_space>" + ( fStringPool . toString ( attrList . getAttrName ( index ) ) ) ) + "=\"" ) + ( fStringPool . toString ( attrList . getAttValue ( index ) ) ) ) + "\"" ) ) ; index = attrList . getNextAttr ( index ) ; } } System . out . println ( ">" ) ; } if ( ( fAttrListHandle ) != ( - 1 ) ) { int index = fAttrList . getFirstAttr ( fAttrListHandle ) ; while ( index != ( - 1 ) ) { int attrNameIndex = attrList . getAttrName ( index ) ; if ( fStringPool . equalNames ( attrNameIndex , fXMLLang ) ) { fDocumentScanner . checkXMLLangAttributeValue ( attrList . getAttValue ( index ) ) ; }

Fix:
fGrammarNameSpaceIndex = fCurrentSchemaURI = fStringPool . addSymbol ( anotherSchemaURI ) ;