I am currently working on replacing an obsolete system with JAXB and I am having trouble parsing XML. The number one requirement for a system is that it must be a replacement, so I cannot change the XML format. Below is the XML section that is causing me problems.
<xx>
<s1>
<X>-9999</X>
<Y>-9999</Y>
</s1>
<s2>
<X>-9999</X>
<Y>-9999</Y>
</s2>
</xx>
The problem with XML is that all s # objects are exact and can contain up to 256 of them. Is there a way in JAXB to annotate such a tag, or do I need 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 will be only 2 s # objects, but this 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;
}
}