Situation
I have a complex object graphic in Java that needs to be translated back and forth into an XML document. The structure of the graphical object of the XML document schema is very different from the tree of model objects. The two are interchangeable, but translation requires a lot of logic based on contexts that use the relationship between parents and children.
Problem
I work with model objects that are well installed on the old system, and the XML document schema is fairly new. Since our code depends on the structure of model objects, we do not want to restructure them. Here is a simplified example of the type of structural differences I'm dealing with:
Example data model tree
Paragraph
Person
- Name
- Surname
- The address
- ...
SaleTransaction (* )
XML-
- owning_party_contact_ref_id
- exchange_use_type
: [ | | ]
: [PERSON | ADDRESS]
: [CASH EXCHANGE | BARTER EXCHANGE]
SaleTransaction Exchange , 1-1. "" , XML. , "owning_party_contact_ref_id" "Item" SaleTransaction.
, , - , XML-, go-to - XmlAdapter. , , XML- JAXB .
- XML- , . , XmlAdapter / .
- , XmlAdapters. MOXy , , .
- , XmlAdapters , /.
, , ? ?
, , :
# 1
XML. , - . JAXB XML, , . XML- , . , , .
# 2
XmlAdapter , (, XML). JAXB, , , .
# 3
# 1, JDOM JAXB. JAXB, DOM.
, # 1.