Consider this scenario: I have an XML file called person.xml with the following data.
<person>
<name>MrFoo</name>
<age>28</age>
</person>
If I want to read this XML object in a Java object, I would create a Java bean called PersonBean (with getters / setters for attributes) as:
class Person{
String name;
int age;
}
And I could use any API to read the XML and populate the Java Bean.
But the real question here is if the structure of the XML file changes, that is, if the new attribute 'email' is added to the XML file, then I need to also change the Java bean to add the new attribute. But I want to avoid changing the Java code, even if the XML structure changes.
So what I'm trying to do, I create another XML file PersonStructure.xml with content like:
<class name="Person">
<attributes>
<attribute>
<name>personName</name>
<type>java.lang.String</type>
</attribute>
... and it goes like this...
</attribute>
</class>
PersonStructure.XML Person.Java? , , ?