Breaking News
yeni film izle hd film seyret film izle

XML Schema Facets

Restrictions(facets) are used to define acceptable values for XML elements or attributes. Restrictions on XML elements are called facets.
By using these restrictions, we can control the kind of value that can be supplied. For instance suppose eBIZ.com want to place an restriction on the age and the condition is “only those who are above 15 and below 76 can join eBIZ.com”. We can place this restriction using schema restriction.
 
Simple facets
 
<xsd:element name=”age” type=”xsd:integer”>
<xsd:simpleType>
<xsd:restriction base=”xsd:integer”>
<xsd:minInclusive value=”16″ />
<xsd:maxInclusive value=”75″ />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
 
 
Restrictions for Data types
 
Constraint Description
enumeration Defines a list of acceptable values
fractionDigits Specifies the maximum number of decimal places allowed. Must be equal to or greater than zero
length Specifies the exact number of characters or list items allowed. Must be equal to or greater than zero
maxExclusive Specifies the upper bounds for numeric values (the value must be less than this value)
maxInclusive Specifies the upper bounds for numeric values (the value must be less than or equal to this value)
maxLength Specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero
minExclusive Specifies the lower bounds for numeric values (the value must be greater than this value)
minInclusive Specifies the lower bounds for numeric values (the value must be greater than or equal to this value)
minLength Specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero
pattern Defines the exact sequence of characters that are acceptable
totalDigits Specifies the exact number of digits allowed. Must be greater than zero
whiteSpace Specifies how white space (line feeds, tabs, spaces, and carriage returns) is handled
 
 
Exmple :
 
<?xml version=”1.0″ encoding=”UTF-8″?>
<xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
targetNamespace=”http://www.ebizel.com”
xmlns=”http://www.ebizel.com”
elementFormDefault=”qualified”>
<xsd:element name=”ebiz”>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref=”address” minOccurs=”1″ maxOccurs=”unbounded”/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name=”address”>
<xsd:complexType>
<xsd:sequence>
     <xsd:element ref=”name” minOccurs=”1″ maxOccurs=”1″/>
     <xsd:element ref=”age” minOccurs=”1″ maxOccurs=”1″ />
     <xsd:element ref=”address_str” minOccurs=”1″ maxOccurs=”1″/>
     <xsd:element ref=”city” minOccurs=”1″ maxOccurs=”1″/>
     <xsd:element ref=”state” minOccurs=”1″ maxOccurs=”1″/>
<xsd:element ref=”pin” minOccurs=”1″ maxOccurs=”1″ />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name=”name” type=”xsd:string”/>
<xsd:element name=”age” type=”xsd:integer”>
<xsd:simpleType>
     <xsd:restriction base=”xsd:integer”>
          <xsd:minInclusive value=”16″ />
          <xsd:maxInclusive value=”75″ />
          </xsd:restriction>
</xsd:simpleType>
</xsd:element>
     <xsd:element name=”address_str” type=”xsd:string”/>
     <xsd:element name=”city” type=”xsd:string”/>
     <xsd:element name=”state” type=”xsd:string”>
<xsd:simpleType>
<xsd:restriction base=”xsd:string”>
<xsd:minLength value=”2″ />
<xsd:maxLength value=”4″ />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name=”pin” type=”xsd:integer”>
<xsd:simpleType>
<xsd:restriction base=”xsd:integer”>
<xsd:length value=”6″ />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

</xsd:schema>

Check Also

XML and Server

Generating XML with JSP   XML can be generated on a server without any installed …