Simple types and applicable facets of UML-to-XSD transformations
XSD facets
Facets enable you to specify constraints on a data type. Use facets to specify a valid range of values, specify the precision and length of values, define lists of valid values and pattern matching.
The following table lists the facets that are part of the XML Schema language:Facet | Definition |
---|---|
fractionDigits | The number of fractional digits must be less than or equal to x |
length | The length of the value must be x |
maxExclusive | The value must be less than x |
maxInclusive | The value must be less than or equal to x |
maxLength | The length of the value must be less than or equal to x |
minExclusive | The value must be greater than x |
minInclusive | The value must be greater than or equal to x |
minLength | The length of the value must be greater than or equal to x |
pattern | x is one of the regular expressions that the value can match |
totalDigits | The number of significant digits must be less than or equal to x |
whitespace | The schema processor should either preserve, replace, or collapse whitespace, depending on x |
Simple types and applicable facets
Simple types are the concrete representations of abstract concepts of data. An integer is an example of an abstract concept of data. Other simple types can be derived from these built-in simple types.The following table lists the simple data types that are built into the XML Schema language. The table also lists the applicable facets for each simple data type. Note that even though W3C recommendation specifies enumeration as a facet, enumeration is not listed in the table. To represent an enumeration, use the UML enumeration or a class with the «enumeration» stereotype.
Built-in simple data types | Applicable facets |
---|---|
ENTITY, ID, IDREFS | length, maxLength, pattern |
Name | length, maxLength, minLength |
NCName | length, maxLength, minLength |
NMTOKEN | length, maxLength, minLength |
NMTOKENS | length, maxLength |
NOTATION | length, maxLength, minLength, pattern |
QNAME | length, maxLength, minLength, pattern |
anyURI, base64Binary, hexBinary | length, maxLength, minLength, pattern |
language | length, maxLength, minLength |
float, double | maxExclusive, maxInclusive, minExclusive, minExclusive, pattern |
decimal | maxExclusive, maxInclusive, minExclusive, minExclusive, fractionDigits, totalDigits, pattern |
integer data types (integer, byte, int, long, negativeInteger, nonNegativeInteger, nonPositiveInteger, positiveInteger, unsignedByte, unsignedInt, unsignedLong,unsignedShort) | maxExclusive, maxInclusive, minExclusive, minExclusive, totalDigits, pattern |
Date and time data types (date, time, dateTime, gYear,gYearMonth, gMonth, gMonthDay, gDay, duration) | maxExclusive, maxInclusive, minExclusive, minExclusive, pattern |
string, normalizedString, token | length, maxLength, minLength, pattern |