title: How do I use XmlAttribute value to determine where to store XmlElement value?
body: <p>My XML file looks like this:</p>
  
  <pre><code>&lt;root&gt;
      &lt;element attribute="valueA"&gt;one&lt;/element&gt;
      &lt;element attribute="valueB"&gt;two&lt;/element&gt;
      &lt;element attribute="valueC"&gt;three&lt;/element&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>And I have this Java class:</p>
  
  <pre><code>public class Vals {
      public String valueA;
      public String valueB;
      public String valueC;
  }
  </code></pre>
  
  <p>I would like to bind the XML data to Vals by doing something like this:</p>
  
  <pre><code>public class Vals {
      @XmlElement(name="element", @XmlAttribute(name="attribute", value_of_attribute="valueA"))
      public String valueA;
      @XmlElement(name="element", @XmlAttribute(name="attribute", value_of_attribute="valueB"))
      public String valueB;
      @XmlElement(name="element", @XmlAttribute(name="attribute", value_of_attribute="valueC"))
      public String valueC;
  }
  </code></pre>
  
  <p>Obviously, this is illegal but I hope it demonstrates what I am trying to do: Use annotations to unmarshall data from XML to Java class fields, where the XmlAttribute value determines where to store the XmlElement value.</p>