Facets
In schema-speak, a facet is an aspect of a possible value
for a simple data type. Depending on the base type, some facets make
more sense than others. For example, a numeric data type can be
restricted by the minimum and maximum possible values it could
contain. But these types of restrictions wouldn’t make sense for a
boolean value. The following list
covers the different facet types that are supported by a schema
processor:
length(orminLengthandmaxLength)patternenumerationwhiteSpacemaxInclusiveandmaxExclusiveminInclusiveandminExclusivetotalDigitsfractionDigits
Facets are applied to simple types using the xs:restriction element. Each facet is expressed as a distinct
element within the restriction block, and multiple facets can be
combined to further restrict potential values of the simple
type.
Handling whitespace
The whiteSpace
facet controls how the schema processor will deal
with any whitespace within the target data. Whitespace
normalization takes place before any of the other facets are
processed. There are three possible values for the whiteSpace facet:
preserveKeep all whitespace exactly as it was in the source document (basic XML 1.0 whitespace handling for content within elements).
replaceReplace occurrences of
#x9(tab),#xA(line feed), and#xD(carriage return) characters with#x20(space) characters.collapsePerform the replace step first, then collapse multiple-space characters into a single space.
Restricting length
The length-restriction facets are fairly ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access