users@jaxb.java.net

Re: unmarshalling IDREF

From: Joe Fialli <joseph.fialli_at_sun.com>
Date: Tue, 28 Jan 2003 09:42:34 -0500

zhidong zhao wrote:
> Document fragment corresponds to inner type can be unmarshalled if the inner type contains no
> IDREF attributes or the referenced object is in the context of the document fragment, ie,
> created in memory by the same unmarshaller. The problem is if the referenced object is
>outside the context, but accessable in memory, say, in a proviously created
content tree
> starting from the root element, can we build a link to that object and include it into
> the resulting tree?

An IDREF reference to a JAXB instance is not sufficient to have it marshalled.
The referenced JAXB instance MUST BE referenced once by a JAXB property that
is reachable from the JAXB root instance that is being marshalled or validated.


TFrom the Specification, Section 5.8.2:

An element or attribute with a type of xs:IDREF refers to "an element in the
instance document" that has an attribute with a type of xs:ID or derived from
type xs:ID with the same value as the xs:IDREF value.


Note that I emphasized the the referenced instance must be "an element in the
instance document" (you can substitute "document fragment here"). In XML,
a document fragment is not complete if an IDREF refers to an element outside
of the document fragment. JAXB is not capable of determing where in the
document fragment an IDREF element should be contained, the application must
do this.

-Joe




--