XSD Simple Types-XSD Restriction - XSD

What is XSD Restriction?

Restriction element is used for defining accepted values that an XML element can take.

Syntax

base

Type of the Element on which restriction is to be applied. For example,

specifies that this restriction is specific to an element of type int.

restriction

restriction is normally a range of conditions to be applied on the element's value. In this example, we've set a restriction on marks that marks should be in range of 0 to 100 with both values are included.

Examples

Restriction on Value.

Condition − Marks should be in range of 0 to 100.

Restriction on Set of Values.

Condition − Grades should only be A, B or C.

Restriction using regular pattern.

Condition − firstname should be in alphabets only.

Types of Restrictions

S.No.

Restriction & Description

1

Enumeration

Defines a list of values which are acceptable.

2

FractionDigits

Defines the maximum number of decimal places allowed(zero or more).

3

Length

Defines length in terms of characters of string or items in a list(zero or more).

4

MaxExclusive

Defines upper bounds for numeric values excluding this number.

5

maxInclusive

Defines upper bounds for numeric values including this number.

6

maxLength

Defines maximum length in terms of characters of string or items in a list(zero or more).

7

minExclusive

Defines lower bounds for numeric values excluding this number.

8

minInclusive

Defines lower bounds for numeric values including this number.

9

minLength

Defines minimum length in terms of characters of string or items in a list(zero or more).

10

pattern

Defines the exact sequence of characters identified by the pattern that are acceptable

11

totalDigits

Defines the exact number of digits allowed in the number(always greater than zero)

12

whiteSpace

Defines the way in which white space characters (line feeds, tabs, spaces, and carriage returns) are handled

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

XSD Topics