title: JAXB: xjc and fixed values for attributes of derived types
body: <p>I'm trying to create an xsd with a type hierarchy.
  What I'm hoping to archieve is that the subtypes fill the base type's attributes with a certain value.
  This is my best result:</p>
  
  <pre><code>&lt;xs:complexType name="base_type"&gt;
      &lt;xs:attribute name="att" use="required" type="xs:string" /&gt;
  &lt;/xs:complexType&gt;
  &lt;xs:complexType name="type1_t"&gt;
      &lt;xs:complexContent&gt;
          &lt;xs:restriction base="base_type"&gt;
              &lt;xs:attribute name="att" fixed="value1" use="required" type="xs:string" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
  &lt;xs:complexType name="type2_t"&gt;
      &lt;xs:complexContent&gt;
          &lt;xs:restriction base="base_type"&gt;
              &lt;xs:attribute name="att" fixed="value2" use="required" type="xs:string" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>The "att" attribute is made available by base_type, and in elements of type1_t and type2_t, I'd like them set to "value1" and "value2", respectively.</p>
  
  <p>The container element looks like this:</p>
  
  <pre><code>&lt;xs:element name="root"&gt;
      &lt;xs:complexType&gt;
          &lt;xs:choice maxOccurs="unbounded"&gt;
              &lt;xs:element name="type1" type="type1_t" /&gt;
              &lt;xs:element name="type2" type="type2_t" /&gt;
          &lt;/xs:choice&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>Now I'm running xjc to generate Java classes for this code, but the "fixed" attribute is not represented in what I get in the Type1T.java, which consists only of</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "type1_t")
  public class Type1T extends BaseType { }
  </code></pre>
  
  <p>I would have expected</p>
  
  <pre><code>{
    @Override public String getAtt() { return "value1"; }
  }
  </code></pre>
  
  <p>?
  That is (almost) what gets generated when the type is generated by itself (ie not as an extension of a base type).</p>
  
  <p>I'm I doing something wrong? Is what I'm trying to do just not possible?</p>
  
  <p>My goal is to automatically generate all java code from xsd; otherwise I suppose a way to implement this would be to code the fixed values in the created ObjectFactory methods for each class manually. However, then I would need to prevent ObjectFactory from getting generated every time...</p>
  
  <p>Any hints? Tips? Thoughts?</p>