Make JAXB error on non mapped elements

HomEmicsloold

New Member
I am trying to do the opposite of: JAXB - Ignore elementThat is I'm trying to parse XML with JAXB to a POJO and I want to JAXB to fail if it does NOT find a matching Java property for a given element. I know I could probably do schema validation but I would rather not do that.Example:\[code\]@XmlRootElement(name="Dog")public class Dog { private String name; public String getName() {return name;} public String setName(String name) {this.name = name};}\[/code\]This XML would fail:\[code\]<Dog><id>blah</id><name>Stuff</name></Dog>\[/code\]Because there is no \[code\]id\[/code\] Java property
 
Back
Top