Not sure what you're trying to accomplish, but it sounds like something I've 
done. Therefore, I will share the code...
See: http://cl1p.net/XmlEntityParser/

Date: Thu, 20 May 2010 10:19:30 +0200
From: [email protected]
To: [email protected]
Subject: [castor-user] Dynamic Runtime Mapping with Castor
















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(marshallerTarget.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

 

                                          
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1

Reply via email to