This section describes facets as simple datatype restrictions. A facet refers a property on a datatype. Some facets of a facet are allowed to be modified to be more restrictive to construct new user-defined datatypes.
What Is Facet?
In general, the word "facet" means any of the definable aspects that make up an object.
In XSD specification, a "facet" on a datatype refers to a property of the datatype.
For example, facet "bounded=true" on a datatype refers to the property that
the entire value space of the datatype is bounded by 2 values.
Some facets on a datatype are allowed to be modified to become more "restrictive".
The result of such modifications is a new user-defined datatype.
When modifying datatype's facets, we need to remember some rules:
>
Every simple datatype has its own list of pre-defined facets.
Some pre-defined facets are allowed to be modified. Some are not allowed to be modified.
Facet modifications should be applied in "restriction" components.
New settings provided in facet modifications should be equal to or more restrictive
than original settings.
Let's see an example of how to modify facet settings using the "restriction" component
with the following assumptions:
Simple datatype "unsignedByte" has a facet called "maxInclusive".
The original setting of "minInclusive" facet on "unsignedByte" datatype is 0.
The original setting of "maxInclusive" facet on "unsignedByte" datatype is 255.
To construct a new datatype "month" that supports only values from 1 to 12,
we can modify "minInclusive" facet to be more restrictive as 1,
and "maxInclusive" facet to be more restrictive as 12,
My XsdSchemaChecker.java program will give this error on the above XSD document:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaChecker
general_facet_test_invalid_1.xsd
Error:
Line number: 7
Column number: 42
Message: cvc-maxInclusive-valid: Value '366' is not facet-valid
with respect to maxInclusive '255' for type 'unsignedByte'.
Failed with 1 errors.
The following XSD example is also invalid, because facet "length" is supported by "unsignedByte":
My XsdSchemaChecker.java program will give this error on the above XSD document:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaChecker
general_facet_test_invalid_2.xsd
Error:
Line number: 7
Column number: 42
Message: cos-applicable-facets: Facet 'length' is not allowed by
type month.
Failed with 1 errors.