Buggy code:
protected static final String SCHEMA_NONS_LOCATION = ( Constants . XERCES_PROPERTY_PREFIX ) + ( Constants . SCHEMA_NONS_LOCATION ) ; protected static final String JAXP_SCHEMA_SOURCE = ( Constants . JAXP_PROPERTY_PREFIX ) + ( Constants . SCHEMA_SOURCE ) ; protected static final String NAMESPACE_CONTEXT_PROPERTY = ( Constants . XERCES_PROPERTY_PREFIX ) + ( Constants . NAMESPACE_CONTEXT_PROPERTY ) ; private static final String [ ] RECOGNIZED_FEATURES = new String [ ] { XMLSchemaValidator . VALIDATION , XMLSchemaValidator . SCHEMA_VALIDATION , XMLSchemaValidator . DYNAMIC_VALIDATION , XMLSchemaValidator . SCHEMA_FULL_CHECKING } ; private static final String [ ] RECOGNIZED_PROPERTIES = new String [ ] { XMLSchemaValidator . SYMBOL_TABLE , XMLSchemaValidator . ERROR_REPORTER , XMLSchemaValidator . ENTITY_RESOLVER , XMLSchemaValidator . VALIDATION_MANAGER , XMLSchemaValidator . SCHEMA_LOCATION , XMLSchemaValidator . SCHEMA_NONS_LOCATION , XMLSchemaValidator . JAXP_SCHEMA_SOURCE , XMLSchemaValidator . NAMESPACE_CONTEXT_PROPERTY } ; protected static final int ID_CONSTRAINT_NUM = 1 ; protected ElementPSVImpl fCurrentPSVI = new ElementPSVImpl ( ) ; protected final AugmentationsImpl fAugmentations = new AugmentationsImpl ( ) ; protected XMLString fDefaultValue ; protected boolean fDynamicValidation = false ; protected boolean fDoValidation = false ; protected boolean fFullChecking = false ; protected boolean fNormalizeData = true ; protected boolean fSchemaElementDefault = true ; protected boolean fAugPSVI = true ; protected boolean fEntityRef = false ; protected boolean fInCDATA = false ; protected SymbolTable fSymbolTable ; protected final class XSIErrorReporter { XMLErrorReporter fErrorReporter ; Vector fErrors = new Vector ( XMLSchemaValidator . INITIAL_STACK_SIZE , XMLSchemaValidator . INC_STACK_SIZE ) ; int [ ] fContext = new int [ XMLSchemaValidator . INITIAL_STACK_SIZE ] ; int fContextCount ; public void reset ( XMLErrorReporter errorReporter ) { } public void pushContext ( ) { } public String [ ] popContext ( ) { } public String [ ] mergeContext ( ) { } public void reportError ( String domain , String key , Object [ ] arguments , short severity ) throws XNIException { } public void reportError ( XMLLocator location , String domain , String key , Object [ ] arguments , short severity ) throws XNIException { } } protected final XMLSchemaValidator . XSIErrorReporter fXSIErrorReporter = new XMLSchemaValidator . XSIErrorReporter ( ) ; protected XMLEntityResolver fEntityResolver ; protected ValidationManager fValidationManager = null ; protected ValidationState fValidationState = new ValidationState ( ) ; protected XMLGrammarPool fGrammarPool ; protected String fExternalSchemas = null ; protected String fExternalNoNamespaceSchema = null ; protected Object fJaxpSchemaSource = null ; final XMLResourceIdentifierImpl fResourceIdentifier = new XMLResourceIdentifierImpl ( ) ; protected final XSDDescription fXSDDescription = new XSDDescription ( ) ; protected final Hashtable fLocationPairs = new Hashtable ( ) ; protected final LocationArray fNoNamespaceLocationArray = new XMLSchemaLoader . LocationArray ( ) ; protected String fBaseURI = null ; protected XMLDocumentHandler fDocumentHandler ; protected XMLDocumentSource fDocumentSource ; public String [ ] getRecognizedFeatures ( ) { } public void setFeature ( String featureId , boolean state ) throws XMLConfigurationException { } public String [ ] getRecognizedProperties ( ) { } public void setProperty ( String propertyId , Object value ) throws XMLConfigurationException { } public void setDocumentHandler ( XMLDocumentHandler documentHandler ) { } public XMLDocumentHandler getDocumentHandler ( ) { } public void setDocumentSource ( XMLDocumentSource source ) { } public XMLDocumentSource getDocumentSource ( ) { } public void startDocument ( XMLLocator locator , String encoding , Augmentations augs ) throws XNIException { } public void xmlDecl ( String version , String encoding , String standalone , Augmentations augs ) throws XNIException { } public void doctypeDecl ( String rootElement , String publicId , String systemId , Augmentations augs ) throws XNIException { } public void startPrefixMapping ( String prefix , String uri , Augmentations augs ) throws XNIException { } public void startElement ( QName element , XMLAttributes attributes , Augmentations augs ) throws XNIException { } public void emptyElement ( QName element , XMLAttributes attributes , Augmentations augs ) throws XNIException { } public void characters ( XMLString text , Augmentations augs ) throws XNIException { } public void ignorableWhitespace ( XMLString text , Augmentations augs ) throws XNIException { } public void endElement ( QName element , Augmentations augs ) throws XNIException { fDefaultValue = null ; Augmentations modifiedAugs = handleEndElement ( element , augs ) ; if ( ( fDocumentHandler ) != null ) { <START_BUG> if ( ( fSchemaElementDefault ) || ( ( fDefaultValue ) == null ) ) { <END_BUG> fDocumentHandler . endElement ( element , modifiedAugs ) ; } else { fDocumentHandler . characters ( fDefaultValue , null ) ; fDocumentHandler . endElement ( element , modifiedAugs ) ; } } } public void endPrefixMapping ( String prefix , Augmentations augs ) throws XNIException { } public void startCDATA ( Augmentations augs ) throws XNIException { } public void endCDATA ( Augmentations augs ) throws XNIException { } public void endDocument ( Augmentations augs ) throws XNIException { } public void setBaseURI ( String base ) { } public boolean characterData ( String data , Augmentations augs ) { } public void elementDefault ( String data ) { } public void startGeneralEntity ( String name , XMLResourceIdentifier identifier , String encoding , Augmentations augs ) throws XNIException { } public void textDecl ( String version , String encoding , Augmentations augs ) throws XNIException { } public void comment ( XMLString text , Augmentations augs ) throws XNIException { } public void processingInstruction ( String target , XMLString data , Augmentations augs ) throws XNIException { } public void endGeneralEntity ( String name , Augmentations augs ) throws XNIException { } static final int INITIAL_STACK_SIZE = 8 ; static final int INC_STACK_SIZE = 8 ; private static final boolean DEBUG_NORMALIZATION = false ; private final XMLString fEmptyXMLStr = new XMLString ( null , 0 , ( - 1 ) ) ; private static final int BUFFER_SIZE = 20 ; private final XMLString fNormalizedStr = new XMLString ( ) ; private boolean fFirstChunk = true ; private boolean fTrailing = false ; private short fWhiteSpace = - 1 ; private boolean fUnionType = false ; final XSGrammarBucket fGrammarBucket ; final SubstitutionGroupHandler fSubGroupHandler ; final XMLSchemaLoader fSchemaLoader ;

Fix:
if ( ( ! ( fSchemaElementDefault ) ) || ( ( fDefaultValue ) == null ) ) {