Thank you Werner for your feedback. If you decide to tackle this issue, I'll most probably try out your different proposals.
In the mean time, I've been giving this some thought, and a (quite
inefficient) workaround that doesn't rely on CASTOR modifications could
be to :
1/ Define a mapping file with all the non-dynamic fields
2/ When needed, read in the mapping file as a DOM tree and add the nodes
corresponding to the dynamic field names to list of children of their
class node. Then dump the resulting tree in a temporary file.
3/ Set the mapping location of the Marshaller to this temporary file.
Apart from the performance hit, do you see any flaws in this "hack" ?
Cheers,
Mark
Le 30/11/2010 10:55, Werner Guttmann a écrit :
> Hi Mark,
>
> this is currently not an option with Castor. But given the increasing
> frequency of people asking for precisely this feature, I am more than
> willing to look into this - given that there's input from the folks
> requesting this.
>
> Regards
> Werner
>
> On 30.11.2010 09:31, Mark Hoebeke wrote:
>> Hi,
>>
>> I have been exploring Castor for some time now, but couldn't find an
>> answer to the issue I'm facing.
>>
>> I need to dynamically generate element names from the keys of a HashMap.
>> For instance, if my map looks like :
>>
>> { 'color' => 'red', 'size' => 'xl', 'price' => 10.0 }
>>
>> I'd like the XML fragment to look like :
>>
>> <color>red</color>
>> <size>xl</size>
>> <price>10.0</price>
>>
>> This looks like bad practice, but the actual values of the keys in the
>> map are constrained making it possible to define a schema against which
>> to validate the generated XML. Moreover, it is impractical to define
>> classes having fields for every possible key of the map. Hence the need
>> to try a dynamic element generation approach.
>>
>> Any clues welcomed !
>>
>> Mark
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>> http://xircles.codehaus.org/manage_email
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
<<attachment: mark_hoebeke.vcf>>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email

