users@jaxb.java.net

RE: Java objects to XML Mapping.

From: <varun.rally_at_rbs.com>
Date: Wed, 8 Jul 2009 07:59:56 +0100

Ok, I will but I just want to make sure I am on the right track.

So with JAXB, it is possible to use pre-existing Java objects and annotate their fields to create a XML that confirms to a particular schema. Is that correct? If yes, how JAXB will find all classes that have annotations.


-----Original Message-----
From: aleksei.valikov_at_gmail.com [mailto:aleksei.valikov_at_gmail.com] On Behalf Of Aleksei Valikov
Sent: 08 July 2009 12:28
To: users_at_jaxb.dev.java.net
Subject: Re: Java objects to XML Mapping.

Hi,

> Actually we need to populate each and every element inside the XML. JAXB has created a class for each element in XML. Hence if we go with the first approach, then we will definitely require all 120+ classes.

If you need to populate each and every element inside the XML then I don't see why you mind having 120 classes. Would you prefer two or three huge classes?

By the way, usually JAXB does not create a class per element, it's usually class per complex type. 120 classes would mean the order of 120 complex types in your schema for me.

> 2nd approach looks better to me as well, but I don't have any idea on how to achieve it. Can you please through some more light on the second option.
>
> For Example, let us say there is tag <employeeName>. Its value needs to be populated from some class for example..BankAccountDetails and the field name is ename. Then how do we proceed in the right direction.
>
> Also, please share some internet references for the 2nd option that I can look at, learn and implement.

To be honest, I don't feel like quoting Google.
You may start with the Chapter 8 of the JAXB specification, it explains Java Type to XML binding.

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


***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
Authorised and regulated by the Financial Services Authority.
 
This e-mail message is confidential and for use by the
addressee only. If the message is received by anyone other
than the addressee, please return the message to the sender
by replying to it and then delete the message from your
computer. Internet e-mails are not necessarily secure. The
Royal Bank of Scotland plc does not accept responsibility for
changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the
transmission of viruses, it is the responsibility of the recipient to
ensure that the onward transmission, opening or use of this
message and any attachments will not adversely affect its
systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient should carry
out such virus and other checks as it considers appropriate.

Visit our website at www.rbs.com

***********************************************************************************