I want to generate Java classes from a dtd file using JAXB.
The dtd looks like this:
<!--Contents-->
<!ELEMENT persons (header, content) >
<!ELEMENT groups (header, content) >
<!--Header-->
<!ELEMENT header (version) >
<!ELEMENT version(#PCDATA) >
<!--Content-->
<!ELEMENT content(person, group)* >
<!--Person-->
<!ELEMENT person(p_id, p_name) >
<!ELEMENT p_id (#PCDATA) >
<!ELEMENT p_name (#PCDATA) >
<!--Group-->
<!ELEMENT group(g_id) >
<!ELEMENT g_id(#PCDATA) >
When generating the classes with JAXB I get the following ones:
- ObjectFactory
- Content
- Person
- Persons
- Group
- Groups
In the Content class the method to retreive all the persons and groups is
public List<Object> getPersonOrGroup() {
if (personOrGroup == null) {
personOrGroup = new ArrayList<Object>();
}
return this.personOrGroup;
}
Is there anything I can change in the dtd file so the generation of Java classes will make the persons
and groups
separated in the Content
java class, so to retreive all persons and groups would be to make a call to Content.getPersons()
and Content.getGroups()
respectivly?