Buggy code:
ComplexTypeRecoverableError ( String msgKey , Object [ ] args ) { } } XSComplexTypeDecl traverseLocal ( Element complexTypeNode , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) { } XSComplexTypeDecl traverseGlobal ( Element complexTypeNode , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) { } private XSComplexTypeDecl traverseComplexTypeDecl ( Element complexTypeDecl , String complexTypeName , Object [ ] attrValues , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) { } private void traverseSimpleContent ( Element simpleContentElement , XSComplexTypeDecl typeInfo , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) throws XSDComplexTypeTraverser . ComplexTypeRecoverableError { String typeName = typeInfo . fName ; Object [ ] attrValues = fAttrChecker . checkAttributes ( simpleContentElement , false , schemaDoc ) ; typeInfo . fContentType = XSComplexTypeDecl . CONTENTTYPE_SIMPLE ; typeInfo . fParticle = null ; Element simpleContent = checkContent ( DOMUtil . getFirstChildElement ( simpleContentElement ) , attrValues , schemaDoc ) ; fAttrChecker . returnAttrArray ( attrValues , schemaDoc ) ; if ( simpleContent == null ) { throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( ) ; } String simpleContentName = simpleContent . getLocalName ( ) ; if ( simpleContentName . equals ( ELT_RESTRICTION ) ) typeInfo . fDerivedBy = SchemaSymbols . RESTRICTION ; else if ( simpleContentName . equals ( ELT_EXTENSION ) ) typeInfo . fDerivedBy = SchemaSymbols . EXTENSION ; else { reportGenericSchemaError ( ( ( ( "ComplexType<seq2seq4repair_space>" + typeName ) + ":<seq2seq4repair_space>" ) + "Child<seq2seq4repair_space>of<seq2seq4repair_space>simpleContent<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>restriction<seq2seq4repair_space>or<seq2seq4repair_space>extension" ) ) ; throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( ) ; } if ( ( DOMUtil . getNextSiblingElement ( simpleContent ) ) != null ) { reportGenericSchemaError ( ( ( ( "ComplexType<seq2seq4repair_space>" + typeName ) + ":<seq2seq4repair_space>" ) + "Invalid<seq2seq4repair_space>child<seq2seq4repair_space>of<seq2seq4repair_space>simpleContent" ) ) ; throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( ) ; } attrValues = fAttrChecker . checkAttributes ( simpleContent , false , schemaDoc ) ; QName baseTypeName = ( ( QName ) ( attrValues [ XSAttributeChecker . ATTIDX_BASE ] ) ) ; fAttrChecker . returnAttrArray ( attrValues , schemaDoc ) ; if ( baseTypeName == null ) { reportGenericSchemaError ( ( ( ( "ComplexType<seq2seq4repair_space>" + typeName ) + ":<seq2seq4repair_space>" ) + "The<seq2seq4repair_space>base<seq2seq4repair_space>attribute<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>specified<seq2seq4repair_space>for<seq2seq4repair_space>the<seq2seq4repair_space>restriction<seq2seq4repair_space>or<seq2seq4repair_space>extension" ) ) ; throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( ) ; } XSTypeDecl type = ( ( XSTypeDecl ) ( fSchemaHandler . getGlobalDecl ( schemaDoc , TYPEDECL_TYPE , baseTypeName ) ) ) ; typeInfo . fBaseType = type ; DatatypeValidator baseValidator = null ; XSComplexTypeDecl baseComplexType = null ; if ( type instanceof XSComplexTypeDecl ) { baseComplexType = ( ( XSComplexTypeDecl ) ( type ) ) ; if ( ( baseComplexType . fContentType ) != ( XSComplexTypeDecl . CONTENTTYPE_SIMPLE ) ) { reportGenericSchemaError ( ( ( ( "ComplexType<seq2seq4repair_space>" + typeName ) + ":<seq2seq4repair_space>" ) + "The<seq2seq4repair_space>base<seq2seq4repair_space>type<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>complex" ) ) ; throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( ) ; } baseValidator = baseComplexType . fDatatypeValidator ; } else { baseValidator = ( ( DatatypeValidator ) ( type ) ) ; if ( ( typeInfo . fDerivedBy ) == ( SchemaSymbols . RESTRICTION ) ) { reportGenericSchemaError ( ( ( ( "ComplexTYpe<seq2seq4repair_space>" + typeName ) + ":<seq2seq4repair_space>" ) + "ct-props-correct.2:<seq2seq4repair_space>The<seq2seq4repair_space>base<seq2seq4repair_space>is<seq2seq4repair_space>a<seq2seq4repair_space>simple<seq2seq4repair_space>type.<seq2seq4repair_space>It<seq2seq4repair_space>cannot<seq2seq4repair_space>be<seq2seq4repair_space>used<seq2seq4repair_space>in<seq2seq4repair_space>a<seq2seq4repair_space>derivation<seq2seq4repair_space>by<seq2seq4repair_space>restriction" ) ) ; throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( ) ; } } if ( ( ( baseValidator . getFinalSet ( ) ) & ( typeInfo . fDerivedBy ) ) != 0 ) { reportGenericSchemaError ( ( ( ( "ComplexType<seq2seq4repair_space>" + typeName ) + ":<seq2seq4repair_space>" ) + "The<seq2seq4repair_space>base<seq2seq4repair_space>type<seq2seq4repair_space>has<seq2seq4repair_space>a<seq2seq4repair_space>final<seq2seq4repair_space>value<seq2seq4repair_space>that<seq2seq4repair_space>prohibits<seq2seq4repair_space>this<seq2seq4repair_space>derivation" ) ) ; throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( ) ; } simpleContent = checkContent ( DOMUtil . getFirstChildElement ( simpleContent ) , null , schemaDoc ) ; if ( ( typeInfo . fDerivedBy ) == ( SchemaSymbols . RESTRICTION ) ) { if ( simpleContent . getLocalName ( ) . equals ( ELT_SIMPLETYPE ) ) { DatatypeValidator dv = fSimpleTypeTraverser . traverseLocal ( simpleContent , schemaDoc , grammar ) ; baseValidator = dv ; simpleContent = DOMUtil . getNextSiblingElement ( simpleContent ) ; } Hashtable fFacetData = null ; Element attrNode = null ; if ( simpleContent != null ) { fFacetInfo fi = traverseFacets ( simpleContent , null , typeName , baseValidator , schemaDoc , grammar ) ; fFacetData = fi . facetdata ; attrNode = fi . nodeAfterFacets ; } <START_BUG> typeInfo . fDatatypeValidator = createRestrictedValidator ( baseValidator , fFacetData ) ; <END_BUG> if ( ( typeInfo . fDatatypeValidator ) == null ) { reportGenericSchemaError ( "Internal<seq2seq4repair_space>error<seq2seq4repair_space>-<seq2seq4repair_space>could<seq2seq4repair_space>not<seq2seq4repair_space>create<seq2seq4repair_space>a<seq2seq4repair_space>new<seq2seq4repair_space>validator" ) ; throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( ) ; } if ( ! ( isAttrOrAttrGroup ( attrNode ) ) ) { throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( "src-ct" , new Object [ ] { typeInfo . fName } ) ; } traverseAttrsAndAttrGrps ( attrNode , typeInfo . fAttrGrp , schemaDoc , grammar ) ; mergeAttributes ( baseComplexType . fAttrGrp , typeInfo . fAttrGrp , typeName , false ) ; String error = typeInfo . fAttrGrp . validRestrictionOf ( baseComplexType . fAttrGrp ) ; if ( error != null ) { reportGenericSchemaError ( ( ( ( "ComplexType<seq2seq4repair_space>" + typeName ) + ":<seq2seq4repair_space>" ) + error ) ) ; throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( ) ; } } else { typeInfo . fDatatypeValidator = baseValidator ; if ( simpleContent != null ) { Element attrNode = simpleContent ; if ( ! ( isAttrOrAttrGroup ( attrNode ) ) ) { throw new XSDComplexTypeTraverser . ComplexTypeRecoverableError ( "src-ct" , new Object [ ] { typeInfo . fName } ) ; } traverseAttrsAndAttrGrps ( attrNode , typeInfo . fAttrGrp , schemaDoc , grammar ) ; if ( baseComplexType != null ) { mergeAttributes ( baseComplexType . fAttrGrp , typeInfo . fAttrGrp , typeName , true ) ; } } } } private void traverseComplexContent ( Element complexContentElement , XSComplexTypeDecl typeInfo , boolean mixedOnType , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) throws XSDComplexTypeTraverser . ComplexTypeRecoverableError { } private void mergeAttributes ( XSAttributeGroupDecl fromAttrGrp , XSAttributeGroupDecl toAttrGrp , String typeName , boolean extension ) throws XSDComplexTypeTraverser . ComplexTypeRecoverableError { } private void processComplexContent ( Element complexContentChild , XSComplexTypeDecl typeInfo , boolean isMixed , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) throws XSDComplexTypeTraverser . ComplexTypeRecoverableError { } private boolean isAttrOrAttrGroup ( Element e ) { }

Fix:
typeInfo . fDatatypeValidator = createRestrictedValidator ( baseValidator , fFacetData , fErrorReporter ) ;