Enable synchronization between XML infoset nodes and JAXB objects
representing same XML document.
An instance of this class maintains the association between XML nodes of
an infoset preserving view and a JAXB representation of an XML document.
Navigation between the two views is provided by the methods
Binder.getXMLNode(Object)
and Binder.getJAXBNode(Object)
.
Modifications can be made to either the infoset preserving view or the
JAXB representation of the document while the other view remains
unmodified. The binder is able to synchronize the changes made in the
modified view back into the other view using the appropriate
Binder update methods, Binder.updateXML(Object, Object)
or
Binder.updateJAXB(Object)
.
A typical usage scenario is the following:
- load XML document into an XML infoset representation
Binder.unmarshal(Object)
XML infoset view to JAXB view.
(Note to conserve resources, it is possible to only unmarshal a
subtree of the XML infoset view to the JAXB view.)
- application access/updates JAXB view of XML document.
Binder.updateXML(Object)
synchronizes modifications to JAXB view
back into the XML infoset view. Update operation preserves as
much of original XML infoset as possible (i.e. comments, PI, ...)
A Binder instance is created using the factory method
JAXBContext.createBinder()
or JAXBContext.createBinder(Class)
.
The template parameter, XmlNode
, is the
root interface/class for the XML infoset preserving representation.
A Binder implementation is required to minimally support
an XmlNode
value of org.w3c.dom.Node.class
.
A Binder implementation can support alternative XML infoset
preserving representations.