users@jaxb.java.net

Re: Unmarshalling in a custom way

From: lightbulb432 <veerukrishnan_at_hotmail.com>
Date: Wed, 7 Nov 2007 07:39:16 -0800 (PST)

Thanks, that's exactly what I was hoping for.

From the following link (written in mid-2005), could someone let me know
whether it's now possible to specify default XMLAdapters, as specified in
the last section "Issues"? The writer states that 'If this were for only
marshaller and unmarshaller, this can be easily done by, say, adding those
adapters to JAXBContext. But for the schema generator to work, it has to be
done declaratively, meaning that the schema generator can figure out exactly
what adapters apply without running any code.' So if you're not using schema
generator, but rather the unmarshaller, is this possible?

http://weblogs.java.net/blog/kohsuke/archive/2005/04/xmladapter_in_j.html

Also, on that same link, from the section "Sharing State Between Application
and Adapter", how is it possible to 'set configured instances of XmlAdapters
to the unmarshaller/marshaller' as described? I don't see any corresponding
methods in Unmarshaller.

Thanks.



Aleksei Valikov wrote:
>
> Hi.
>
>> I have an XML file that I'd like to unmarshall to Java based on
>> JAXB-annotated classes. I'd like to be able to do this in a custom way,
>> however - right now every attribute gets unmarshalled as a String. Is
>> there
>> a way to provide a custom attribute-unmarshaller or something that says
>> to
>> JAXB if an attribute is of type Class, for example, then use this custom
>> converter class of mine to convert it from the String value in the XML to
>> a
>> Class object?
>>
>> I could of course have a set of data access objects in JAXB with only
>> Strings then domain objects that do the conversion, but it seems overkill
>> and a maintenance headache to have two parallel object hierarchies just
>> because I can't customize the way JAXB unmarshalls.
>>
>> Is this possible with JAXB, or am I out of luck? Any suggestions?
>
> I'm not sure what exactly your problem is, but:
>
> * Simply declare properties fields in the appropriate type if it is
> known to JAXB.
> * Use XMLAdapter to provide custom conversion.
>
> Bye.
> /lexi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>

-- 
View this message in context: http://www.nabble.com/Unmarshalling-in-a-custom-way-tf4764949.html#a13629569
Sent from the java.net - jaxb users mailing list archive at Nabble.com.