Use
Facets enable you to restrict the value range of a data type in XML schema to a particular subset. This enables you to determine exactly which value is expected in a special case for a simple data type, an element, or an attribute. For example:
· A telephone number (using a pattern on a string)
· A selection of permitted values, for example to classify the different classes for a flight (using an enumeration)
Prerequisites
Before you can use a facet, you must have selected a built-in data type in the Type column for your simple data type, element, or attribute. Otherwise the input field in the Details column remains locked.
Features
Using the XSD editor, you can further restrict the value range of a built-in data type for simple data types, elements or attributes.
Input Options in the Details Column
Facet | Meaning |
enumeration | Restricts the value range to a set of individual values. The values must be separated by blanks in the XSD editor. |
fractionDigits | Specifies the number of places permitted after the comma. Only xsd:nonNegativeInteger type values are valid. |
length, | Exact (length), maximum (maxLength), or minimum (minLength) length of a data type. The XSD editor only permits these facets for data types that are based on xsd:string. The value of this facet must be of type xsd:nonNegativeInteger. |
maxExclusive, | Upper limit for the value set exclusive (maxExclusive) or inclusive (maxInclusive) of the specified value. The value of this facet must not exceed the value range of the data type that is restricted by the facet. |
minExclusive, | Lower limit for the value set exclusive (minExclusive) or inclusive (minInclusive) of the specified value. The value of this facet must not exceed the value range of the data type that is restricted by the facet. |
pattern | Specifies a pattern for string-based data types. The pattern must have the form of a regular expression that describes a set of appropriate character sequences. |
totalDigits | Specifies the total number of digits in a number. Only xsd:positiveInteger type values are valid. |
whiteSpace | Specifies how to apply white space characters (line feed, tabs, blanks, and carriage returns). Three values are permitted: · preserve: Retains all white space characters. · replace: Replaces every line feed, tab, and carriage return with a blank. · collapse: As for replace but subsequent blanks are replaced by a single blank and leading and final blanks are deleted. |
For more information, see http://www.w3.org/TR/xmlschema-2/#rf-facets.
Regular Expressions in XML Schema
Regular expressions originate from the Unix world and are expressions that you can use to describe any type of string. For a description of regular expressions; see http://www.w3.org/TR/xmlschema-2/#regexs. Instead of repeating this definition, here are a few common examples of how regular expressions are used:
Example Pattern
Regular Expression | Appropriate Strings (Separated by Commas and Blanks) |
[abcdefg] | a, b, c, d, e, f, g |
[A-Z][A-Z][A-Z] | ABC, DEF, SAP, SPD, CDU, FDP, PDS |
[0-9][0-9][0-9] | 007, 459, 471, 999, 879 |
[a-z]([0-9])* | a, b, c, d, e, i12784937, e3321, t4000, b345 |
[a-z]([0-9])+ | a304, i20, e3012, t5, b90000 |
([a-z]|[0-9])+ | a, ab, abc, abcdefg, 0, 1, 01, 012, 0123 |
When using a star (*), the character may not occur at all in the string, or it can occur an unlimited number of times. When using a plus (+), the character must occur at least once in the string. The square brackets specify the character selection.
For further examples, see http://www.w3schools.com/schema/schema_facets.asp.
Additionally, there are also special characters that can be introduced with a backslash, for example:
· \d: A number
· \c: A character in the sense of a character permitted for names in XML schema