users@jaxb.java.net

Re: jaxb2-reflection library help

From: Hunor Bartha <hunor.bartha_at_ambo.ro>
Date: Wed, 06 Jun 2007 08:35:42 +0300

Thanks for your answer,

in the meantime i realized that this is not possible, so i did it using
the parent node, just the way you suggest.

Regards,

hunor

Kohsuke Kawaguchi wrote:
> Hunor Bartha wrote:
>> I am trying to use the jaxb2-reflection library to dynamically read
>> information about jaxb objects. Could somebody please post some short
>> example how to obtain the name of the xml element(node) to which a
>> given jaxb object is bound to. I would be interested in the value of
>> the /name/ property of the @XmlElement annotation. It seemed
>> straightforward at the beginning, but by now i am completely lost
>> between the different RuntimeClass* interfaces and implementations.
>> For example, if i have the class:
>>
>> public class Parent{
>> @XmlElement(name = "Node1", required = true)
>> protected *Node1Type* node;
>> }
>>
>> and at runtime i have an instance of *Node1Type*, how could i obtain
>> the "Node1" string from it?
>
> Node1Type maybe used in many classes and bound to different element
> names, so such computation is impossible.
>
> If you have a Field object that represents Parent.node and would like
> to get to the element name from there, that's more tractable.
>