title: How to instantiate an empty element with JAXB
body: <p>I use JAXB to create XML messages. The XML I need to create is (for the sake of simplicity):</p>
  
  <pre><code>&lt;request&gt;
    &lt;header/&gt;
  &lt;/request&gt;
  </code></pre>
  
  <p>My code looks like this:</p>
  
  <pre><code>import javax.xml.bind.annotation.*;
  
  @XmlRootElement(name = "request")
  public class Request {
  
      private String header;
  
      @XmlElement(required=true)
      public String getHeader() {
        return header;
      }
  
      public void setHeader(String header) {
        this.header=header;
      }
  }
  </code></pre>
  
  <p>The problem: the <code>header</code> element is not displayed (header is <code>null</code>). When header is set to an empty string, the following is displayed:</p>
  
  <pre><code>&lt;request&gt;
    &lt;header&gt;&lt;/header&gt;
  &lt;/request&gt;
  </code></pre>
  
  <p>When I use as type <code>Object</code> instead of <code>String</code>, the result is even worse:</p>
  
  <pre><code>&lt;request&gt;
    &lt;header xsi:type="xs:string" 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;/header&gt;
  &lt;/request&gt;
  </code></pre>
  
  <p>BTW: I'm using <a href="https://stackoverflow.com/questions/590405/generic-method-in-java-without-generic-argument/590418#590418">this code</a> to create the XML string. </p>
  
  <p>Is it possible to get an empty tag?</p>