It is possible to restrict the values of an element in the XSD, using some specific restriction tags.

Below is a code snippet, which provides an example of how to restrict an attribute value in the xsd. This will lead to restrict the client application from setting up any other values to the restricted attribute.

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="" xmlns="" elementFormDefault="qualified" targetNamespace="">

<xs:element name="transaction" type="TransactionType"/>

<xs:element fixed="10" name="size" type="xs:integer"/>

<xs:complexType name="TransactionType">


<xs:element name="name">


<xs:restriction base="xs:string">

<xs:minLength value="1"/>

<xs:enumeration value="type1"/>

<xs:enumeration value="type2"/>

<xs:enumeration value="type3"/>




<xs:element minOccurs="0" ref="size"/>




Sandeep Joshi
Mathematics, Technology and Programming are my passion. I am a part of Java Ecosystem and through this blog, I contribute to it. I am here to blog about my interests, views and experiences.
I am on Google+ and Facebook.
I feel proud to be listed as a "National Memory Record Holder" in the Limca Book of Records, 2009 and have attempted for an International Memory record in the Guiness Book of Records. I can remember the value of PI upto 10,000 digits after the decimal (3.1415.....). You can contact me on ; I would like to hear from you :)