title: JaxB Java Model to xsd Schema - string length restrictions
body: <p>I am generating an xsd schema from JaxB annotated Java Pojo's.</p>
  
  <pre><code>import javax.xml.bind.annotation.*
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
  @XmlType
  public class Excess {
  
      @XmlElement(required = true)
      private String code;
  
      public String getCode() {
          return code;
      }
  
      public void setCode(String code) {
          this.code = code;
      }
  }
  </code></pre>
  
  <p>Then the generated schema look like this:</p>
  
  <pre><code>  &lt;xs:complexType name="Excess"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name="code" type="xs:string"/&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>I am using 1.6 <code>jaxb2-maven-plugin</code> schemagen goal to generate schema from models.
  What i am trying to achieve is the length restriction as it is in JPA </p>
  
  <pre><code>@Column(name="excess", length=6)
  </code></pre>
  
  <p>But using JaxB</p>
  
  <pre><code>@XmlElement(name="excess", length=6)
  </code></pre>
  
  <p>Was trying to use Krasa plugin as well
  <a href="https://github.com/krasa/krasa-jaxb-tools" rel="nofollow">https://github.com/krasa/krasa-jaxb-tools</a>
  But <code>@Max</code> annotation or any other restriction annotations didn't worked, or maybe my implementation is incorrect.</p>
  
  <p>Any ideas ?
  Thank you.
  Krystian.</p>