if (baseType instanceof ErrorType)
return baseType;
if (baseType.isFinal(XSDatatype.DERIVATION_BY_RESTRICTION))
throw new DatatypeException(
XSDatatypeImpl.localize(XSDatatypeImpl.ERR_INVALID_BASE_TYPE, baseType.displayName()));
if (isEmpty()) {
// if no facet is specified, and user wants anonymous type,
// then no need to create another object.
// TODO: for the type-derivation-OK test to work correctly,
// maybe we need to wrap this by a FinalComponent.
if (newNameUri == null && newLocalName == null)
return baseType;
// using FinalComponent as a wrapper,
// so that the new type object can have its own name.
return new FinalComponent(newNameUri, newLocalName, baseType, 0);
}
XSDatatypeImpl r = baseType; // start from current datatype
// TODO : make sure that the following interpretation is true
/*
several facet consistency check is done here.
those which are done in this time are:
- length and (minLength/maxLength) are exclusive
- maxInclusive and maxExclusive are exclusive
- minInclusive and minExclusive are exclusive
those are exclusive within the one restriction;
that is, it is legal to derive types in the following way:
<simpleType name="foo">
<restriction baseType="string">
<minLength value="3" />
</restrction>
</simpleType>
<simpleType name="bar">
<restriction baseType="foo">
<length value="5" />
</restrction>
</simpleType>
although the following is considered as an error
<simpleType name="bar">
<restriction baseType="foo">
<length value="5" />
<minLength value="3" />
</restrction>
</simpleType>
This method is the perfect place to perform this kind of check.
*/
// makes sure that no mutually exclusive facets are specified
for (int i = 0; i < exclusiveFacetPairs.length; i++)
if (contains(exclusiveFacetPairs[i][0]) && contains(exclusiveFacetPairs[i][1]))
throw new DatatypeException(
XSDatatypeImpl.localize(
XSDatatypeImpl.ERR_X_AND_Y_ARE_EXCLUSIVE,
exclusiveFacetPairs[i][0],
exclusiveFacetPairs[i][1]));