I have a set of JAXB generated classes, and some of the classes have setter methods that take an "Object" as a parameter. For instance:
@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name="Car", propOrder = { "defaultCar" } public class Car { @XmlElement(name = "DefaultCar") protected Object defaultcar; public void setDefaultCar(Object value) { this.defaultCar = value; }
After I instantiate these classes in my code, I call the setter methods that pass at the required value. Although the method parameter is Object, the values are likely to be strings (I have no control over how it is defined). However, to preserve the integrity, I passed the Object string to match the type of the method parameter. The code looks something like this:
Object value = "Old Banger"; Method method = aCar.getClass().getMethod("setDefaultCar", Object.class); method.invoke(aCar, value);
When I sort Java objects, I get the following in the resulting XML, right before the string value:
xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: type = "xs: string"
I read somewhere about the mismatch of data types between the type of a method parameter and what was passed to it. In my case, the method parameter is "Object", but I pass it a string (although I passed it Object). I also saw this post, and it looks like my problem:
"xsi: type" and "xmlns: xsi" in the generated xml from JAXB
However, this does not help me overcome my problem. Is there a way to remove these links to xmlns: xsi and xsi: type?
thanks
source share