}
// create the simple type based on the "base" type
XSSimpleType newDecl = null;
if (restriction) {
newDecl = fSchemaHandler.fDVFactory.createTypeRestriction(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
else if (list) {
newDecl = fSchemaHandler.fDVFactory.createTypeList(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
else if (union) {
XSSimpleType[] memberDecls = (XSSimpleType[]) dTValidators.toArray(new XSSimpleType[dTValidators.size()]);
newDecl = fSchemaHandler.fDVFactory.createTypeUnion(name, schemaDoc.fTargetNamespace, (short)finalProperty, memberDecls,
annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
// now traverse facets, if it's derived by restriction
if (restriction && content != null) {
FacetInfo fi = traverseFacets(content, baseValidator, schemaDoc);
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);
// Recreate the type, ignoring the facets
newDecl = fSchemaHandler.fDVFactory.createTypeRestriction(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
}
// no element should appear after this point
if (content != null) {
if (restriction) {