I'm currently working on replacing a legacy system with JAXB and I'm running into problem with parsing the XML. The number one requirement of the system is that it must be a drop-in replacement so I cannot modify the format of the XML. Below is the XML section that is giving me trouble.
<xx>
<s1>
<X>-9999</X>
<Y>-9999</Y>
</s1>
<s2>
<X>-9999</X>
<Y>-9999</Y>
</s2>
</xx>
The issue with the XML is that all of the s# objects are the exact same and there can be up to 256 of them. Is there a way in JAXB to annotate such a tag or do I have to create 256 separate annotations? Any help would be most appreciated.
Here is the java code for the xx object. Note: the object was originally programmed with the understanding that there would only be 2 s# objects, but that since has changed.
@XmlRootElement(name="xx")
public class XMLXx implements Serializable {
private static final long serialVersionUID = 4064597372833234503L;
private XMLSite siteOne;
private XMLSite siteTwo;
@XmlElement(name="s1")
public XMLSite getSiteOne() {
return siteOne;
}
public void setSiteOne(XMLSite s1) {
this.siteOne = s1;
}
@XmlElement(name="s2")
public XMLSite getSiteTwo() {
return siteTwo;
}
public void setSiteTwo(XMLSite s2) {
this.siteTwo = s2;
}
}
And here is the XMLSite object:
public class XMLSite implements Serializable {
private static final long serialVersionUID = -4374405403222014476L;
private Integer x;
private Integer y;
@XmlElement(name="X")
public Integer getX() {
return x;
}
public void setX(Integer x) {
this.x = x;
}
@XmlElement(name="Y")
public Integer getY() {
return y;
}
public void setY(Integer y) {
this.y = y;
}
}
tags. So there could be etc each with the and tags as children – Chris Flynn Jul 07 '11 at 19:57