When use the Moxy to unmarshaling the sample xml to child, it always can't get the name. It always is null.
Sample xml
<?xml version="1.0" encoding="UTF-8"?>
<child>
<name value="test"/>
</child>
Sample class
public class Parent {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@XmlRootElement
public class Child extends Parent {
@Override
@XmlPath("name/@value")
public String getName() {
return super.getName() == null ? "" : super.getName();
}
@Override
public void setName(String name) {
super.setName(name);
}
}
JAXBContext jc2 = JAXBContext.newInstance(Child.class);
Unmarshaller unmarshaller = jc2.createUnmarshaller();
Child child = (Child) unmarshaller.unmarshal(new File("d:\\sample.xml"));
How can I get this value, if I can't make any change on the Parent class.
Thanks,