This code:
public static User unmarshalUser(final java.io.Reader reader)
throws MarshalException, ValidationException {
XMLContext context = new XMLContext();
context.setProperty(XMLConfiguration.XML_NAMING, "mixed");
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setClass(User.class);
User user = (User) unmarshaller.unmarshal(reader);
return user;
}
doesn't work because the XML_NAMING property isn't taking effect at runtime. It can only be set from a properties file.
XML_NAMING is org.exolab.castor.xml.naming. Changing the property using the methods XMLContext.setProperty() or Marshaller.setProperty() does not change the XMLNaming strategy as I would have expected. I attached a JUnit test.