Buggy code:
return null ; } else { fListName = qualifiedName ; } } else if ( varietyProperty . equals ( ELT_RESTRICTION ) ) { baseTypeName = ( ( QName ) ( contentAttrs [ XSAttributeChecker . ATTIDX_BASE ] ) ) ; restriction = true ; } else if ( varietyProperty . equals ( ELT_UNION ) ) { union = true ; memberTypes = ( ( Vector ) ( contentAttrs [ XSAttributeChecker . ATTIDX_MEMBERTYPES ] ) ) ; if ( memberTypes != null ) { size = memberTypes . size ( ) ; } else { size = 1 ; } dTValidators = new Vector ( size , 2 ) ; } else { Object [ ] args = new Object [ ] { varietyProperty } ; fErrorReporter . reportError ( SCHEMA_DOMAIN , "FeatureUnsupported" , args , SEVERITY_ERROR ) ; } if ( ( DOMUtil . getNextSiblingElement ( content ) ) != null ) { reportGenericSchemaError ( "error<seq2seq4repair_space>in<seq2seq4repair_space>content<seq2seq4repair_space>of<seq2seq4repair_space>simpleType" ) ; } DatatypeValidator baseValidator = null ; if ( ( baseTypeName == null ) && ( memberTypes == null ) ) { content = DOMUtil . getFirstChildElement ( content ) ; content = checkContent ( content , contentAttrs , schemaDoc ) ; if ( content == null ) { reportGenericSchemaError ( ( ( "no<seq2seq4repair_space>child<seq2seq4repair_space>element<seq2seq4repair_space>found<seq2seq4repair_space>for<seq2seq4repair_space>simpleType<seq2seq4repair_space>'" + nameProperty ) + "'" ) ) ; return null ; } if ( DOMUtil . getLocalName ( content ) . equals ( ELT_SIMPLETYPE ) ) { baseValidator = traverseLocal ( content , fSchemaDoc , fGrammar ) ; if ( ( baseValidator != null ) && union ) { dTValidators . addElement ( ( ( DatatypeValidator ) ( baseValidator ) ) ) ; } if ( baseValidator == null ) { Object [ ] args = new Object [ ] { content . getAttribute ( ATT_BASE ) } ; fErrorReporter . reportError ( SCHEMA_DOMAIN , "UnknownBaseDatatype" , args , SEVERITY_ERROR ) ; return null ; } } else { Object [ ] args = new Object [ ] { simpleTypeDecl . getAttribute ( ATT_NAME ) } ; fErrorReporter . reportError ( SCHEMA_DOMAIN , "ListUnionRestrictionError" , args , SEVERITY_ERROR ) ; return null ; } } else { numOfTypes = 1 ; if ( union ) { numOfTypes = size ; } int baseRefContext = ( restriction ) ? SchemaSymbols . RESTRICTION : 0 ; baseRefContext = baseRefContext | ( union ? SchemaSymbols . UNION : 0 ) ; baseRefContext = baseRefContext | ( list ? SchemaSymbols . LIST : 0 ) ; for ( int i = 0 ; i < numOfTypes ; i ++ ) { if ( union ) { baseTypeName = ( ( QName ) ( memberTypes . elementAt ( i ) ) ) ; } baseValidator = findDTValidator ( simpleTypeDecl , baseTypeName , baseRefContext ) ; if ( baseValidator == null ) { reportGenericSchemaError ( ( ( ( ( "base<seq2seq4repair_space>type<seq2seq4repair_space>not<seq2seq4repair_space>found:<seq2seq4repair_space>'" + ( baseTypeName . uri ) ) + "," ) + ( baseTypeName . localpart ) ) + "'" ) ) ; baseValidator = ( ( DatatypeValidator ) ( SG_SchemaNS . getGlobalTypeDecl ( ATTVAL_STRING ) ) ) ; } if ( ( fListName . length ( ) ) != 0 ) { if ( baseValidator instanceof ListDatatypeValidator ) { reportCosListOfAtomic ( ) ; return null ; } if ( isListDatatype ( baseValidator ) ) { reportCosListOfAtomic ( ) ; return null ; } } if ( union ) { dTValidators . addElement ( ( ( DatatypeValidator ) ( baseValidator ) ) ) ; } } } if ( baseTypeName == null ) { content = DOMUtil . getNextSiblingElement ( content ) ; } else { content = DOMUtil . getFirstChildElement ( content ) ; } if ( union ) { int index = size ; if ( memberTypes != null ) { content = checkContent ( content , contentAttrs , schemaDoc ) ; } while ( content != null ) { baseValidator = traverseLocal ( content , fSchemaDoc , fGrammar ) ; if ( baseValidator != null ) { if ( ( ( fListName . length ( ) ) != 0 ) && ( baseValidator instanceof ListDatatypeValidator ) ) { reportCosListOfAtomic ( ) ; return null ; } dTValidators . addElement ( ( ( DatatypeValidator ) ( baseValidator ) ) ) ; } if ( baseValidator == null ) { Object [ ] args = new Object [ ] { simpleTypeDecl . getAttribute ( ATT_BASE ) , simpleTypeDecl . getAttribute ( ATT_NAME ) } ; fErrorReporter . reportError ( SCHEMA_DOMAIN , "UnknownBaseDatatype" , args , SEVERITY_ERROR ) ; baseValidator = ( ( DatatypeValidator ) ( SG_SchemaNS . getGlobalTypeDecl ( ATTVAL_STRING ) ) ) ; } content = DOMUtil . getNextSiblingElement ( content ) ; } } if ( ( fListName . length ( ) ) != 0 ) { if ( fListName . equals ( qualifiedName ) ) { fListName = fSchemaHandler . EMPTY_STRING ; } } if ( restriction && ( content != null ) ) { fFacetInfo fi = traverseFacets ( content , contentAttrs , nameProperty , baseValidator , schemaDoc , fGrammar ) ; fFacetData = fi . facetdata ; } DatatypeValidator newDV = null ; if ( list ) { try { newDV = new ListDatatypeValidator ( baseValidator , fFacetData , true ) ; } catch ( InvalidDatatypeFacetException e ) { reportGenericSchemaError ( e . getMessage ( ) ) ; } } else if ( restriction ) { newDV = createRestrictedValidator ( baseValidator , fFacetData ) ; } else { newDV = new UnionDatatypeValidator ( dTValidators ) ; } <START_BUG> if ( newDV != null ) { <END_BUG> newDV . setFinalSet ( finalProperty ) ; ( ( AbstractDatatypeValidator ) ( newDV ) ) . fLocalName = nameProperty ; fGrammar . addGlobalTypeDecl ( newDV ) ; } return newDV ; } private void reportCosListOfAtomic ( ) { } private DatatypeValidator findDTValidator ( Element elm , QName baseTypeStr , int baseRefContext ) { } private boolean isListDatatype ( DatatypeValidator validator ) { } }

Fix:
if ( ( newDV != null ) && isGlobal ) {