title: XSD element with a value AND xsi:nil="true"
body: <p>I have an XSD element </p>
  
  <pre><code>&lt;xsd:element name="author" type="cmd:Author" nillable="true"&gt;
      &lt;xsd:annotation&gt;
          &lt;xsd:documentation&gt;Contains author name and author id
          &lt;/xsd:documentation&gt;
      &lt;/xsd:annotation&gt;
  &lt;/xsd:element&gt;
  </code></pre>
  
  <p>Type author:</p>
  
  <pre><code>&lt;xsd:complexType name="Author"&gt;
      &lt;xsd:annotation&gt;
          &lt;xsd:documentation&gt;Author's name and id.
          &lt;/xsd:documentation&gt;
      &lt;/xsd:annotation&gt;
      &lt;xsd:simpleContent&gt;
          &lt;xsd:extension base="cmd:AuthorName"&gt;
               &lt;xsd:attribute name="id" type="cmd:Id" use="optional"&gt;
                  &lt;xsd:annotation&gt;
                      &lt;xsd:documentation&gt;Author's Id
                      &lt;/xsd:documentation&gt;
                  &lt;/xsd:annotation&gt;
              &lt;/xsd:attribute&gt;
          &lt;/xsd:extension&gt;
      &lt;/xsd:simpleContent&gt;
  &lt;/xsd:complexType&gt;
  </code></pre>
  
  <p>Base AuthorName:</p>
  
  <pre><code>&lt;xsd:simpleType name="AuthorName"&gt;
      &lt;xsd:annotation&gt;
          &lt;xsd:documentation&gt;Type defining author's name. 
                  It may contain characters from AllowedChars
          &lt;/xsd:documentation&gt;
      &lt;/xsd:annotation&gt;
      &lt;xsd:restriction base="cmd:AllowedChars"&gt;
          &lt;xsd:maxLength value="112"/&gt;
      &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;
  </code></pre>
  
  <p>Type Id:</p>
  
  <pre><code>&lt;xsd:simpleType name="Id"&gt;
      &lt;xsd:annotation&gt;
          &lt;xsd:documentation&gt;Id
          &lt;/xsd:documentation&gt;
      &lt;/xsd:annotation&gt;
      &lt;xsd:restriction base="xsd:string"&gt;
          &lt;xsd:pattern value="\d{6}"/&gt;
      &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;
  </code></pre>
  
  <p>The problem is that I always have an ID but sometimes it may happen that AuthorName is null.</p>
  
  <p>In that situation what I get is:</p>
  
  <pre><code>&lt;author id="111111"/&gt;
  </code></pre>
  
  <p>What I want to get is:</p>
  
  <pre><code>&lt;author id="111111" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:nil="true"/&gt;
  </code></pre>
  
  <p>My actual state makes problems with schema compatibility. Is it possible to do the thing I want without changing XSD model? Splitting Author into AuthorName and AuthorId isn't backward compatible and will require rewriting pretty big application.</p>
  
  <p>Additional info (I'm not quite sure what is useful and what isn't):
  application is in J2E, I'm binding xsd with JAXB and I am generating classes using XJC.</p>
  
  <p>Generated class Author:</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "Author", propOrder = {
      "value"
  })
  public class Author implements Serializable
  {
      @XmlValue
      protected String value;
      @XmlAttribute(name = "id")
      protected String id;
      //getters and setters
  }
  </code></pre>