Test mapping of XML data to/from a java object(s) using dozer.
That is, given a sample XML file , map this to new java classes with appropriate get/set methods for the various elements
A sample XML file is given below:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<cXML payloadID="1272549644772.1050674118.000000197@2Vmg9c/TnwT1ZqGdAuiHQvbDmNc=" timestamp="2010-04-29T07:00:44-07:00" version="1.2.020">
<Header>
<From>
<Credential domain="Test_Code">
<Identity>ID_SYSTEM</Identity>
</Credential>
</From>
<To>
<Credential domain="Test_Code">
<Identity>ID_SYSTEM</Identity>
</Credential>
</To>
<Sender>
<Credential domain="AribaNetworkUserId">
<Identity>test.test@sial.com</Identity>
<SharedSecret>sigma123</SharedSecret>
</Credential>
<UserAgent>Sender Application 1.0</UserAgent>
</Sender>
</Header>
</cXML>
I need to map this to new java class
Please help me.
Basic dozer
mapping is really easy, if the attributes have same name / type it will map auto:
<mapping>
<class-a>org.dozer.vo.TestObject</class-a>
<class-b>org.dozer.vo.TestObjectPrime</class-b>
</mapping>
If you have some different named attributes:
<mapping>
<class-a>org.dozer.vo.TestObject</class-a>
<class-b>org.dozer.vo.TestObjectPrime</class-b>
<field>
<a>one</a>
<b>onePrime</b>
</field>
</mapping>
For more info you can find in the user guide and examples of XML mappings