users@jaxb.java.net

Binder and dom customization

From: Petteri Stenius <Petteri.Stenius_at_ubisecure.com>
Date: Tue, 7 Nov 2006 09:01:09 +0200

Hi,

Some of my Java interfaces return DOM objects as the result of anyType wildcard mapping or DOM customization.

If I'm unmarshalling with Binder from a DOM document instance then it would be very nice if the returned DOM objects belonged to the original DOM document instance.

The following sample should make this request more clear. This is my schema fragment:

<complexType name="RootType">
  <sequence>
    <element name="Wildcard">
      <annotation><appinfo><jaxb:dom/></appinfo></annotation>
    </element>
  </sequence>
</complexType>

The jaxb generated RootType interface defines an accessor method "Element getWildcard()".

Now when I do this

Document xml = documentBuilder.parse(input);
Binder<Node> binder = jaxb.createBinder();
RootType root = binder.unmarshal(xml, RootType.class).getValue();
Element wildcard = root.getWildcard();

What I'd like to see is root.getWildcard() return a DOM element from my original DOM instance. The following conditions for example should then be true:
-- wildcard.getOwnerDocument() == xml
-- wildcard.getParentNode() == binder.getXMLNode(root)

An other option is to be able to use DOM elements as input to Binder.getXMLNode. Currently however getXMLNode returns null for DOM elements.

Petteri