Simple types and applicable facets of UML-to-XSD transformations

Simple types represent the common data types that you can use directly in an XSD schema, and they can be used to derive other simple types. Each simple data type has applicable facets, which specify constraints on the simple data type.

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
minlength is 1
the value attribute for whitespace has a fixed value of collapse

Name

length, maxLength, minLength
the value attribute for whitespace has a fixed value of collapse
pattern is \i\c*

NCName

length, maxLength, minLength
the value attribute for whitespace has a fixed value of collapse
pattern is [\i-[:]][\c-[:]]*

NMTOKEN

length, maxLength, minLength
the value attribute for whitespace has a fixed value of collapse
pattern is \c+

NMTOKENS

length, maxLength
minLength is 1
the value attribute for whitespace has a fixed value of collapse

NOTATION

length, maxLength, minLength, pattern
the value attribute for whitespace has a fixed value of collapse

QNAME

length, maxLength, minLength, pattern
the value attribute for whitespace has a fixed value of collapse

anyURI, base64Binary, hexBinary

length, maxLength, minLength, pattern
the value attribute for whitespace has a fixed value of collapse

language

length, maxLength, minLength
whitespace value is collapse
pattern is ([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*

float, double

maxExclusive, maxInclusive, minExclusive, minExclusive, pattern
the value attribute for whitespace has a fixed value of collapse

decimal

maxExclusive, maxInclusive, minExclusive, minExclusive, fractionDigits, totalDigits, pattern
the value attribute for whitespace has a fixed value of collapse

integer data types (integer, byte, int, long, negativeInteger, nonNegativeInteger, nonPositiveInteger, positiveInteger, unsignedByte, unsignedInt, unsignedLong,unsignedShort)

maxExclusive, maxInclusive, minExclusive, minExclusive, totalDigits, pattern
fractionDigits is fixed to have a value 0
the value attribute for whitespace has a fixed value of collapse

Date and time data types (date, time, dateTime, gYear,gYearMonth, gMonth, gMonthDay, gDay, duration)

maxExclusive, maxInclusive, minExclusive, minExclusive, pattern
the value attribute for whitespace has a fixed value of collapse

string, normalizedString, token

length, maxLength, minLength, pattern
whitespace value is one of the following:
preserve for a string
replace for a normalizedString
collapse for a token


Feedback