title: Why does xs:any not autobind with jaxb class?
body: <p>I got an <a href="http://www.ech.ch/alfresco/guestDownload/attach/workspace/SpacesStore/246461b8-378f-4032-bc1a-76ba4da0dbfd/eCH-0147T1.xsd" rel="nofollow noreferrer">xsd</a> and I generated JaxB-Classes from it (example ApplicationCustomType). Some classes have an xs:any as element. I can add content (example xs:any) to these fields. The marshalling works well. </p>
  
  <p>But when I try to unmarshall it 
  <code>FullContent contentType = XmlObjectHelper.getXmlTypeFromString(contentType, FullContent.class);</code>
  The JaxB-classes are not populated with the fields from every xs:any. All other fields filled in as they should but the binding of the xs:any seems not to work.</p>
  
  <p>I read that <a href="https://stackoverflow.com/questions/13941747/serializing-with-jaxb-and-the-any">serializing-with-jaxb</a> answer and it looks pretty the same I don't think I forgot something.
  I also tried to add <a href="https://stackoverflow.com/questions/9687588/jaxb-how-to-unmarshall-xsany-xml-string-part">lax = true</a> but again it did not unmarshal my xml.</p>
  
  <p><strong>What did I do wrong or what did I forget?</strong></p>
  
  <pre><code>public class ApplicationCustomType {
  
  @XmlAnyElement
  protected List&lt;Element&gt; any;
  @XmlAnyAttribute
  private Map&lt;QName, String&gt; otherAttributes = new HashMap&lt;QName, String&gt;();
  </code></pre>
  
  <p>An example xs:any element.</p>
  
  <pre><code>@XmlRootElement
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "addressAttachment", propOrder = {
      "locale",
      "ourUserId"
  
  })
  
  public class AddressAttachment {
  
      @XmlElement(required = false)
      protected String locale;
  
      @XmlElement(required = false)
      protected String ourUserId;
  }
  </code></pre>
  
  <p>ObjectFactory.java</p>
  
  <pre><code>@XmlElementDecl(namespace = "http://***/xsd/addressAttachment/v1", name = "information")
  public JAXBElement&lt;AddressAttachment&gt; createAddressAttachment(AddressAttachment value) {
      return new JAXBElement&lt;AddressAttachment&gt;(_AddressAttachment_QNAME, AddressAttachment.class, null, value);
  }
  </code></pre>
  
  <p>The xml I receive:</p>
  
  <pre><code>&lt;content&gt;
     &lt;applicationCustom&gt;
         &lt;addressAttachment&gt;
            &lt;locale&gt;CH.de&lt;/locale&gt;
            &lt;ourUserId&gt;264646337383839&lt;/ourUserId&gt;                       
         &lt;/addressAttachment&gt;
     &lt;/applicationCustom&gt;
  &lt;/content&gt;
  </code></pre>
  
  <p><strong>Solution:</strong></p>
  
  <p>We retried it with (lax = true) on top of the List and not the class.</p>
  
  <pre><code>public class ApplicationCustomType {
  
  @XmlAnyElement(lax = true)
  protected List&lt;Element&gt; any;
  </code></pre>
  
  <p>If you use <code>&lt;Element&gt;</code> or <code>&lt;Object&gt;</code> does not affect the result. When using <code>Element</code> you dont have to provide the class to the marshaller actually. But in both cases you need to add <code>@XmlElementDecl</code> for each <code>XMLRoot</code>class in your Object factory for each Object you want to add to the xs:any list.</p>