I'm using XMLMapper to deserialize AIML code (mostly the same as XML) and got this problem when I mix text and tags under the same tag. Example:
<set name="setVar">
<srai>FUNCTION1</srai>
<srai>FUNCTION2<star index="1"/></srai>
</set>
My java classes definition are:
@JacksonXmlRootElement(localName = "set")
public class Set {
@JacksonXmlProperty(isAttribute = true, localName = "name")
public String name;
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty(localName = "srai")
public List<Srai> srais;
public Set() {
}
public Set(String name, List<Srai> srais) {
this.name = name;
this.srais = srais;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Srai> getSrais() {
return srais;
}
public void setSrais(List<Srai> srais) {
this.srais = srais;
}
}
@JacksonXmlRootElement(localName = "srai")
public class Srai {
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty(localName = "star")
public List<Star> stars;
@JacksonXmlText
public String text;
public Srai() {}
public Srai(String text, List<Star> stars) {
this.text = text;
this.stars = stars;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public List<Star> getStars() {
return stars;
}
public void setStars(List<Star> stars) {
this.stars = stars;
}
}
@JacksonXmlRootElement(localName = "star")
public class Star {
@JacksonXmlProperty(isAttribute = true)
public int index;
public Star() {
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
}
If I try to deserialize code in which there are only text or only stars into the srai, everything works perfect, the problem appears when I mix text and tags.