Buggy code:
public void processingInstruction ( String target , XMLString data , Augmentations augs ) throws XNIException { } public void endGeneralEntity ( String name , Augmentations augs ) throws XNIException { } public void startDTD ( XMLLocator locator , Augmentations augs ) throws XNIException { } public void ignoredCharacters ( XMLString text , Augmentations augs ) throws XNIException { } public void textDecl ( String version , String encoding , Augmentations augs ) throws XNIException { } public void startParameterEntity ( String name , XMLResourceIdentifier identifier , String encoding , Augmentations augs ) throws XNIException { } public void endParameterEntity ( String name , Augmentations augs ) throws XNIException { } public void elementDecl ( String name , String contentModel , Augmentations augs ) throws XNIException { } public void startAttlist ( String elementName , Augmentations augs ) throws XNIException { } public void attributeDecl ( String elementName , String attributeName , String type , String [ ] enumeration , String defaultType , XMLString defaultValue , XMLString nonNormalizedDefaultValue , Augmentations augs ) throws XNIException { } public void endAttlist ( Augmentations augs ) throws XNIException { } public void internalEntityDecl ( String name , XMLString text , XMLString nonNormalizedText , Augmentations augs ) throws XNIException { } public void externalEntityDecl ( String name , XMLResourceIdentifier identifier , Augmentations augs ) throws XNIException { } public void unparsedEntityDecl ( String name , XMLResourceIdentifier identifier , String notation , Augmentations augs ) throws XNIException { } public void notationDecl ( String name , XMLResourceIdentifier identifier , Augmentations augs ) throws XNIException { } public void startConditional ( short type , Augmentations augs ) throws XNIException { } public void endConditional ( Augmentations augs ) throws XNIException { } public void endDTD ( Augmentations augs ) throws XNIException { } public void startContentModel ( String elementName , Augmentations augs ) throws XNIException { } public void any ( Augmentations augs ) throws XNIException { } public void empty ( Augmentations augs ) throws XNIException { } public void startGroup ( Augmentations augs ) throws XNIException { } public void pcdata ( Augmentations augs ) { } public void element ( String elementName , Augmentations augs ) throws XNIException { } public void separator ( short separator , Augmentations augs ) throws XNIException { } public void occurrence ( short occurrence , Augmentations augs ) throws XNIException { } public void endGroup ( Augmentations augs ) throws XNIException { } public void endContentModel ( Augmentations augs ) throws XNIException { } private void addDTDDefaultAttrsAndValidate ( int elementIndex , XMLAttributes attributes ) throws XNIException { } private String getExternalEntityRefInAttrValue ( String nonNormalizedValue ) { } private void validateDTDattribute ( QName element , String attValue , XMLAttributeDecl attributeDecl ) throws XNIException { } boolean invalidStandaloneAttDef ( QName element , QName attribute ) { } private boolean normalizeAttrValue ( XMLAttributes attributes , int index ) { } private boolean normalizeDefaultAttrValue ( XMLString value ) { } private void rootElementSpecified ( QName rootElement ) throws XNIException { } private int checkContent ( int elementIndex , QName [ ] children , int childOffset , int childCount ) throws XNIException { } private int getContentSpecType ( int elementIndex ) { } private void charDataInContent ( ) { } private String getAttributeTypeName ( XMLAttributeDecl attrDecl ) { } private void init ( ) { } private void ensureStackCapacity ( int newElementDepth ) { } protected void handleStartElement ( QName element , XMLAttributes attributes ) throws XNIException { fPerformValidation = ( ( fValidation ) && ( ( ! ( fDynamicValidation ) ) || ( fSeenDoctypeDecl ) ) ) && ( ( fDTDValidation ) || ( fSeenDoctypeDecl ) ) ; if ( ! ( fSeenRootElement ) ) { fSeenRootElement = true ; fValidationManager . setEntityState ( fDTDGrammar ) ; fValidationManager . setGrammarFound ( fSeenDoctypeDecl ) ; rootElementSpecified ( element ) ; } if ( ( fDTDGrammar ) == null ) { if ( ! ( fPerformValidation ) ) { fCurrentElementIndex = - 1 ; fCurrentContentSpecType = - 1 ; fInElementContent = false ; } if ( ( fPerformValidation ) && ( ! ( fSkipValidation ) ) ) { fSkipValidation = true ; fErrorReporter . reportError ( XML_DOMAIN , "MSG_GRAMMAR_NOT_FOUND" , new Object [ ] { element . rawname } , SEVERITY_ERROR ) ; } } else { fCurrentElementIndex = fDTDGrammar . getElementDeclIndex ( element , ( - 1 ) ) ; fCurrentContentSpecType = getContentSpecType ( fCurrentElementIndex ) ; <START_BUG> if ( ( ( fCurrentElementIndex ) == ( - 1 ) ) && ( fPerformValidation ) ) { <END_BUG> fErrorReporter . reportError ( XML_DOMAIN , "MSG_ELEMENT_NOT_DECLARED" , new Object [ ] { element . rawname } , SEVERITY_ERROR ) ; } else { addDTDDefaultAttrsAndValidate ( fCurrentElementIndex , attributes ) ; } } fInElementContent = ( fCurrentContentSpecType ) == ( XMLElementDecl . TYPE_CHILDREN ) ; ( fElementDepth ) ++ ; if ( fPerformValidation ) { if ( ( fElementChildrenOffsetStack . length ) <= ( fElementDepth ) ) { int [ ] newarray = new int [ ( fElementChildrenOffsetStack . length ) * 2 ] ; System . arraycopy ( fElementChildrenOffsetStack , 0 , newarray , 0 , fElementChildrenOffsetStack . length ) ; fElementChildrenOffsetStack = newarray ; } fElementChildrenOffsetStack [ fElementDepth ] = fElementChildrenLength ; if ( ( fElementChildren . length ) <= ( fElementChildrenLength ) ) { QName [ ] newarray = new QName [ ( fElementChildrenLength ) * 2 ] ; System . arraycopy ( fElementChildren , 0 , newarray , 0 , fElementChildren . length ) ; fElementChildren = newarray ; } QName qname = fElementChildren [ fElementChildrenLength ] ; if ( qname == null ) { for ( int i = fElementChildrenLength ; i < ( fElementChildren . length ) ; i ++ ) { fElementChildren [ i ] = new QName ( ) ; } qname = fElementChildren [ fElementChildrenLength ] ; } qname . setValues ( element ) ; ( fElementChildrenLength ) ++ ; } fCurrentElement . setValues ( element ) ; ensureStackCapacity ( fElementDepth ) ;

Fix:
if ( ( ( fCurrentContentSpecType ) == ( - 1 ) ) && ( fPerformValidation ) ) {