What is the proper way to set the XML_NAMING property programmatically,
without a properties file?
I have this code:
public static User unmarshalUser(final java.io.Reader reader)
throws MarshalException, ValidationException {
XMLContext context = new XMLContext();
context.setProperty(XMLConfiguration.XML_NAMING,
"com.ics.xml.MixedCapitalizedXMLNaming");
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setClass(User.class);
User user = (User) unmarshaller.unmarshal(reader);
return user;
}
It doesn't work because the XML_NAMING property is not being set properly.
If I comment out the line
//context.setProperty(XMLConfiguration.XML_NAMING,
"com.ics.xml.MixedCapitalizedXMLNaming");
And add a castor.properties file with the line:
org.exolab.castor.xml.naming=com.ics.xml.MixedCapitalizedXMLNaming
Then it works.
Thanks for your help,
John