title: JAXB - Example of following a keyref when unmarshalling
body: <p>According to <a href="http://markmail.org/message/jyloxrham4wasq4u#query:jaxb%20key-ref+page:1+mid:jyloxrham4wasq4u+state:results" rel="nofollow noreferrer">this</a>, you can make use of xs:key and xs:keyref when marshalling and unmarshalling data in JAXB 2.x.</p>
  
  <p>However, I can't find a working example of this being done anywhere.</p>
  
  <p>What we're doing is setting a lookup section in each XML message containing the details for the reference/code values (id, name, description, etc), and then have the data elements later in the message refer back to these items using their key.  XML schema defines and supports this through xs:keyref and xs:key (xs:IDREF is not an allowed option).</p>
  
  <p>What I'd like to do is have my JAXB unmarshaller follow these refs dynamically, replacing the key with the referenced object.</p>
  
  <p>Could anybody refer me to an example of this being done?</p>