title: Generate Java classes from XML Schema with restrictions using JAXB
body: <p>By the use of the command line tool 'xjc' for example, it is possible to create Java classes from an existing XML Schema.</p>
  
  <p>I've tried that with a simple XML Schema before:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  
   &lt;xs:element name="employee" type="employee"/&gt;
  
   &lt;xs:complexType name="employee"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="name" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:element name="salary" type="xs:double"/&gt;
      &lt;xs:element name="designation" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:element name="address" type="address" minOccurs="0"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="id" type="xs:int" use="required"/&gt;
   &lt;/xs:complexType&gt;
  
   &lt;xs:complexType name="address"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="city" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:element name="line1" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:element name="line2" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:element name="state" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:element name="zipcode" type="xs:long"/&gt;
    &lt;/xs:sequence&gt;
   &lt;/xs:complexType&gt; 
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>But when I add a definition which has some restrictions, the restrictions will be just ignored. For example: </p>
  
  <pre><code>&lt;xs:element name="Temperature" type="myTemperature"/&gt;
  &lt;xs:simpleType name="myTemperature"&gt;
   &lt;xs:restriction base="xs:double"&gt;
    &lt;xs:minExclusive value="-273.15"/&gt;
   &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;xs:element name="age"&gt;
   &lt;xs:simpleType&gt;
    &lt;xs:restriction base="xs:integer"&gt;
     &lt;xs:minInclusive value="0"/&gt;
     &lt;xs:maxInclusive value="100"/&gt;
    &lt;/xs:restriction&gt;
   &lt;/xs:simpleType&gt;
  &lt;/xs:element&gt; 
  </code></pre>
  
  <p>All the restrictions like minInclusive, maxInclusive, maxLength, totalDigits, etc. will be ignored. Is there a way to include this restrictions in the creation of the Java classes from the XML Schema?</p>