Hello everyone,

 

I'm wondering if there is a way to modify the xml-name of a top-level
class programmatically? My current solution works like this:

 

...

((XMLClassDescriptorImpl)this.marshaller.getResolver().resolve(marshalle
rTarget.getClass())).setXMLName("myCustomXMLName");

this.marshaller.marshal(marshallerTarget);

...

 

As you already may have noticed the problem with the above solution is
the unchecked cast to XMLClassDescriptorImpl as it is not guaranteed
that the resolve-method 

returns an object of this type. For example if I pass an object of type
String to the resolve-method I get a StringClassDescriptor. In general
it would be interesting if there is a possibility to 

modify the mapping-information (i.e. the state of the descriptors in
memory) at runtime without having to do conditional castings by using
instanceof-checks to get the appropriate descriptor. 

 

Thanks in advance,

 

Best regards,

 

Martin

 

Reply via email to