Value constraints refine a simple type by defining limits on the values which it can represent.
It is often useful to be able to constrain the values which an element can take, perhaps to ensure that messages conform to business rules. This topic describes how value constraints can be added to a simple type in order to constrain the values of all elements based on it.
Most of the value constraints discussed here are modeled by XML Schema facets, and are associated with a simple type. However, default values and fixed values can be defined for an element, and these are associated with the element itself.
If an attribute is missing from an input message, it will be assigned the default value.
Note that default value constraints are associated with the element itself, and therefore cannot be inherited.
If an attribute is present in an input message, it must have the fixed value. If an attribute is missing from an input message, it will be assigned the fixed value.
Fixed value constraints are associated with the element itself, and therefore cannot be inherited.
Length constraints can be applied to simple types which are derived from xsd:hexBinary, xsd:base64Binary or xsd:string (including built in schema types such as xsd:normalisedString).
Length constraints are inherited from ancestor types, and any length constraints defined for a simple type must not relax the constraints imposed by any of its ancestor types. For example, it would be illegal to derive a type 'longString' (Max Length=100) from a type 'shortString' (Max Length=10).
Range constraints are inherited from ancestor types, and any range constraints defined for a simple type must not relax the constraints imposed by any of its ancestor types. For example, it would be illegal to derive a type 'largeNumber' (Max Inclusive=100) from a type 'smallNumber' (Max Inclusive=10).
The message model does not allow exclusive constraints to be applied to non-integral types (float, decimal, double, dateTime, and so on).
Enumeration constraints are inherited from ancestor types, and any set of enumeration constraints defined for a simple type must not increase the range of allowed values. For example, it would be illegal to derive a type 'AllColours' (with enumerations for all colours of the rainbow) from a type 'MonoColours' (with enumerations for 'black' and 'white' only).
Precision constraints are inherited from ancestor types, and any precision constraints defined for a simple type must not relax the constraints imposed by any of its ancestor types. For example, it would be illegal to derive a type 'veryPrecise' (Fraction Digits=10) from a type 'notVeryPrecise' (Fraction Digits=1).
As with all value constraints, a simple type can inherit pattern constraints from the simple type on which it is based. In this case, the set of pattern constraints contributed by each ancestor type must be satisfied as well as the set contributed by the simple type itself. In other words, the sets of pattern constraints from each level in the type hierarchy are combined using Boolean AND.
Pattern constraints can only be applied to simple types which are derived from xsd:string.
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
ad10470_ |