title: Injected class name for marshaling
body: <p>The problem is around jaxb marshaling. Consider the following classes:</p>
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  public class Dog { //... }
  
  
  @XmlRootElement(name = &quot;dobermann&quot;)
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Dobermann extends Dog { //... }
  
  
  @XmlRootElement(name = &quot;pitbull&quot;)
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Pitbull extends Dog { //... }
  
  
  @XmlRootElement(name = &quot;animal&quot;)
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Animal
  {
      @XmlElement(required = true)
      Dog dog;
      
      // setter
      // ...
  }
  
  public class Test {
     public static void main(String... args) {
        Animal animal = new Animal();
        animal.setDog(new Dobermann());
      
        // Marshaling to xml
     }
  }
  </code></pre>
  <p>now, jaxb generates:</p>
  <pre><code>&lt;animal&gt;
      &lt;dog&gt; ... &lt;/dog&gt;
      ...
  &lt;/animal&gt;
  </code></pre>
  <p>but I want:</p>
  <pre><code>&lt;animal&gt;
      &lt;dobermann&gt; ... &lt;/dobermann&gt;
      ...
  &lt;/animal&gt;
  </code></pre>
  <p>or</p>
  <pre><code>&lt;animal&gt;
      &lt;pitbull&gt; ... &lt;/pitbull&gt;
      ...
  &lt;/animal&gt;
  </code></pre>
  <p>Actually I want the xml element name depended on injected type.
  How to do this?
  Thanks.</p>