title: Jaxb: how to unmarshall xs:any XML-string part?
body: <p>I have an application doing XML&lt;->conversions using Jaxb and automatically generated classes with maven-jaxb2-plugin. </p>
  
  <p>Someplace deep in my schema, I have the possibility to enter "ANY" xml. </p>
  
  <p>Update: this better describes my schema. Some known XML wrapping a totally unknown part (the "any" part).</p>
  
  <pre><code>&lt;xs:complexType name="MessageType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="XmlAnyPayload" minOccurs="0"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:any namespace="##any"/&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
      &lt;xs:element name="OtherElements"&gt;
          ....
  &lt;/xs:sequence&gt;
  </code></pre>
  
  <p></p>
  
  <p>This maps (by jaxb) to a inner class like this.</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "", propOrder = {
      "any"
  })
  public static class XmlAnyPayload {
  
      @XmlAnyElement(lax = true)
      protected Object any;
  </code></pre>
  
  <p>When I unmarshall the entire structure, it is no problem. The "Object any" will render into a org.apache.xerces.dom.ElementNSImpl. Now, I want to recreate the Java object manually and then go to XML. How do I take some random XML and put into the any (org.apache.xerces.dom.ElementNSImpl) element to be able to build up the Java object?</p>
  
  <p>Also, the next case is when I have this element as java, I want to unmarshall this very part (to be able to extract the XML string of this element). But this is not possible. I get an exception about root elements. But it is not possible to annotate ElementNSImpl.</p>
  
  <pre><code>unable to marshal type "com.sun.org.apache.xerces.internal.dom.ElementNSImpl" as an element because it is missing an @XmlRootElement annotation
  </code></pre>
  
  <p>Do you have any suggestions on how to handle these problems?</p>