Buggy code:
} else { dTValidators . add ( dv ) ; } } } } if ( ( content != null ) && ( DOMUtil . getLocalName ( content ) . equals ( ELT_SIMPLETYPE ) ) ) { if ( restriction || list ) { if ( baseTypeName != null ) { reportSchemaError ( ( list ? "src-simple-type.3.a" : "src-simple-type.2.a" ) , null , content ) ; } if ( baseValidator == null ) { baseValidator = traverseLocal ( content , schemaDoc , grammar ) ; } content = DOMUtil . getNextSiblingElement ( content ) ; } else if ( union ) { if ( dTValidators == null ) { dTValidators = new ArrayList ( 2 ) ; } do { dv = traverseLocal ( content , schemaDoc , grammar ) ; if ( dv != null ) { if ( ( dv . getVariety ( ) ) == ( XSSimpleType . VARIETY_UNION ) ) { dvs = dv . getMemberTypes ( ) ; for ( int j = 0 ; j < ( dvs . getLength ( ) ) ; j ++ ) { dTValidators . add ( dvs . item ( j ) ) ; } } else { dTValidators . add ( dv ) ; } } content = DOMUtil . getNextSiblingElement ( content ) ; } while ( ( content != null ) && ( DOMUtil . getLocalName ( content ) . equals ( ELT_SIMPLETYPE ) ) ) ; } } else if ( ( restriction || list ) && ( baseTypeName == null ) ) { reportSchemaError ( ( list ? "src-simple-type.3.b" : "src-simple-type.2.b" ) , null , child ) ; } else if ( union && ( ( memberTypes == null ) || ( ( memberTypes . size ( ) ) == 0 ) ) ) { reportSchemaError ( "src-union-memberTypes-or-simpleTypes" , null , child ) ; } if ( ( restriction || list ) && ( baseValidator == null ) ) { fAttrChecker . returnAttrArray ( contentAttrs , schemaDoc ) ; return errorType ( name , schemaDoc . fTargetNamespace , ( restriction ? XSConstants . DERIVATION_RESTRICTION : XSConstants . DERIVATION_LIST ) ) ; } if ( union && ( ( dTValidators == null ) || ( ( dTValidators . size ( ) ) == 0 ) ) ) { fAttrChecker . returnAttrArray ( contentAttrs , schemaDoc ) ; return errorType ( name , schemaDoc . fTargetNamespace , DERIVATION_UNION ) ; } if ( list && ( isListDatatype ( baseValidator ) ) ) { reportSchemaError ( "cos-st-restricts.2.1" , new Object [ ] { name , baseValidator . getName ( ) } , child ) ; fAttrChecker . returnAttrArray ( contentAttrs , schemaDoc ) ; return errorType ( name , schemaDoc . fTargetNamespace , DERIVATION_LIST ) ; } XSSimpleType newDecl = null ; if ( restriction ) { newDecl = fDVFactory . createTypeRestriction ( name , schemaDoc . fTargetNamespace , ( ( short ) ( finalProperty ) ) , baseValidator , ( annotations == null ? null : new org . apache . xerces . impl . xs . util . XSObjectListImpl ( annotations , annotations . length ) ) ) ; } else if ( list ) { newDecl = fDVFactory . createTypeList ( name , schemaDoc . fTargetNamespace , ( ( short ) ( finalProperty ) ) , baseValidator , ( annotations == null ? null : new org . apache . xerces . impl . xs . util . XSObjectListImpl ( annotations , annotations . length ) ) ) ; } else if ( union ) { XSSimpleType [ ] memberDecls = ( ( XSSimpleType [ ] ) ( dTValidators . toArray ( new XSSimpleType [ dTValidators . size ( ) ] ) ) ) ; newDecl = fDVFactory . createTypeUnion ( name , schemaDoc . fTargetNamespace , ( ( short ) ( finalProperty ) ) , memberDecls , ( annotations == null ? null : new org . apache . xerces . impl . xs . util . XSObjectListImpl ( annotations , annotations . length ) ) ) ; } if ( restriction && ( content != null ) ) { <START_BUG> FacetInfo fi = traverseFacets ( content , baseValidator , schemaDoc ) ; <END_BUG> content = fi . nodeAfterFacets ; try { fValidationState . setNamespaceSupport ( schemaDoc . fNamespaceSupport ) ; newDecl . applyFacets ( fi . facetdata , fi . fPresentFacets , fi . fFixedFacets , fValidationState ) ; } catch ( InvalidDatatypeFacetException ex ) { reportSchemaError ( ex . getKey ( ) , ex . getArgs ( ) , child ) ; newDecl = fDVFactory . createTypeRestriction ( name , schemaDoc . fTargetNamespace , ( ( short ) ( finalProperty ) ) , baseValidator , ( annotations == null ? null : new org . apache . xerces . impl . xs . util . XSObjectListImpl ( annotations , annotations . length ) ) ) ; } } if ( content != null ) { if ( restriction ) { reportSchemaError ( "s4s-elt-must-match.1" , new Object [ ] { SchemaSymbols . ELT_RESTRICTION , "(annotation?,<seq2seq4repair_space>(simpleType?,<seq2seq4repair_space>(minExclusive<seq2seq4repair_space>|<seq2seq4repair_space>minInclusive<seq2seq4repair_space>|<seq2seq4repair_space>maxExclusive<seq2seq4repair_space>|<seq2seq4repair_space>maxInclusive<seq2seq4repair_space>|<seq2seq4repair_space>totalDigits<seq2seq4repair_space>|<seq2seq4repair_space>fractionDigits<seq2seq4repair_space>|<seq2seq4repair_space>length<seq2seq4repair_space>|<seq2seq4repair_space>minLength<seq2seq4repair_space>|<seq2seq4repair_space>maxLength<seq2seq4repair_space>|<seq2seq4repair_space>enumeration<seq2seq4repair_space>|<seq2seq4repair_space>whiteSpace<seq2seq4repair_space>|<seq2seq4repair_space>pattern)*))" , DOMUtil . getLocalName ( content ) } , content ) ; } else if ( list ) { reportSchemaError ( "s4s-elt-must-match.1" , new Object [ ] { SchemaSymbols . ELT_LIST , "(annotation?,<seq2seq4repair_space>(simpleType?))" , DOMUtil . getLocalName ( content ) } , content ) ; } else if ( union ) { reportSchemaError ( "s4s-elt-must-match.1" , new Object [ ] { SchemaSymbols . ELT_UNION , "(annotation?,<seq2seq4repair_space>(simpleType*))" , DOMUtil . getLocalName ( content ) } , content ) ; } } fAttrChecker . returnAttrArray ( contentAttrs , schemaDoc ) ; return newDecl ; } private XSSimpleType findDTValidator ( Element elm , String refName , QName baseTypeStr , short baseRefContext , XSDocumentInfo schemaDoc ) { } private final boolean checkBuiltIn ( String name , String namespace ) { } private boolean isListDatatype ( XSSimpleType validator ) { } private XSSimpleType errorType ( String name , String namespace , short refType ) { } }

Fix:
FacetInfo fi = traverseFacets ( content , newDecl , baseValidator , schemaDoc ) ;