title: How to handle forward references of XML IDREF with JAXB XmlAdapter during unmarshal?
body: <p>Is it possible to handle forward references of XML <code>IDREF</code> elements in JAXB <code>XmlAdapter</code> during the unmarshal process? For example, I have the following XML <code>complexType</code>:</p>
  
  <pre><code>&lt;xs:complexType name="person"&gt;
      &lt;xs:complexContent&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="dateOfBirth" type="xs:dateTime" minOccurs="0"/&gt;
              &lt;xs:element name="firstName" type="xs:string" minOccurs="0"/&gt;
              &lt;xs:element name="gender" type="xs:string" minOccurs="0"/&gt;
              &lt;xs:element name="guardian" type="xs:IDREF" minOccurs="0"/&gt;
              &lt;xs:element name="homePhone" type="xs:string" minOccurs="0"/&gt;
              &lt;xs:element name="lastName" type="xs:string" minOccurs="0"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>where the <code>guardian</code> field could reference another <code>Person</code>-type element elsewhere in the document. I am currently using an XmlAdapter when marshalling so that the first time an object is marshalled, it is marshalled by containment, and any subsequent occurances of this object are marshalled by reference. See a previous question of <a href="https://stackoverflow.com/q/7587095/318287">mine</a>. However, due to how my XML instance documents are created, the first occurrence of a <code>Person</code> element could happen after an <code>IDREF</code> to it occurs.</p>
  
  <p>Is this something that is possible? Or do I need to approach this differently? Thanks!</p>