users@jaxb.java.net

Re: Converting XML to Java Objects...possible?

From: tweety123 <therhythmic_at_yahoo.com>
Date: Wed, 11 Apr 2007 07:16:56 -0700 (PDT)

Hi all, Thanks for your replies.

How do I actually convert XML to Java object (not class)? I know that to
convert XML to java classes (not objects), I need to use
Marshaller.unmarshal(). How do I convert the XML to java "object" (& not
"class")?

Thanks.



Malachi de Ælfweald wrote:
>
> Or more simply put, JAXB autogenerates an API that reads/writes the XML
> for
> you (based on your XSD).
>
> :)
>
> Malachi
>
> On 4/9/07, Prashant <prashant_at_pramati.com> wrote:
>>
>> Yes, this is possible with Jaxb and is the primary objective of this
>> specification.
>>
>> JAXB generates the Java Classes from a XSD document.
>>
>> Then you can "marshall" any XML instance document of this schema to a
>> Java Objects.
>>
>> If you think of XSD Schema document as a "blue print" Jaxb will generate
>> Class files (Blue print in Java), then for any incoming XML instance
>> document (data) JAXB can create Java Object instances.
>>
>> Perhaps this will help : http://www.jcp.org/en/jsr/detail?id=31
>>
>> *2.1* Please describe the proposed Specification:
>> The proposed specification will define an /XML data-binding facility/
>> for the Java^TM Platform. Such a facility compiles an XML schema into
>> one or more Java classes. These automatically-generated classes handle
>> the translation between XML documents that follow the schema and
>> interrelated instances of the derived classes. They also ensure that the
>> constraints expressed in the schema are maintained as instances of the
>> classes are manipulated.
>>
>> -Prashant
>>
>> tweety123 wrote:
>> > Hi, As far as I know about JAXB, it provides the facility to convert
>> "XSD"
>> > (not XML) to Java "classes" (not objects). This can be done using xjc
>> > compiler. Can XML files (i.e. ones with data) be converted to Java
>> objects
>> > (retaining the data from XML files)? If yes, please throw some light on
>> how
>> > it can be done. If no, then is there some java technology to do such a
>> > thing?
>> >
>> > Thanks.
>> >
>>
>>
>> ---------------------------------------------------------------------
>> 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/Converting-XML-to-Java-Objects...possible--tf3551108.html#a9940466
Sent from the java.net - jaxb users mailing list archive at Nabble.com.