Currently I have a simple class setup as:
@XmlRootElement (name = "MyRoot")
public class MyClass {
@XmlElement (name = "String1") private String string1;
@XmlTransient public String getString1() { return this.string1; }
public void setString1(String string1) { this.string1 = string1; }
@XmlElement (name = "String2") private String string2;
@XmlTransient public String getString2() { return this.string2; }
public void setString2(String string2) { this.string2 = string2; }
}
I want the output of the class when processed from JAXB to look like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MyRoot>
<MyWrapper>
<String1>ABC</String1>
<String2>XYZ</String2>
</MyWrapper>
</MyRoot>
My questions are:
@XmlRootElement(name = "MyWrapper"
on it? Is this a simple limitation of JAXB?How is this a limitation, clearly String1 and String2 are members of MyClass, and unless you redefine their parents, its not just going to change like that.
Suggestion, make them transient, use method annotation, and return an array of both of them