Thanks for your detailed reply.
I agree to what you are saying with following inputs.
We just have to marshal the XML and not the other way round in our business scenario.
Also, there should be some way that I create a XML without data, and then a mapping file between objects and tags of XML, then the tool should be able to create XML filled with Data.
There is one such tool called Jelly, but the problem is very limited information is available on it, and there is no mailing list as well for that tool. It is an Apache solution.
________________________________
From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
Sent: 08 July 2009 13:07
To: users_at_jaxb.dev.java.net
Subject: Re: Java objects to XML Mapping.
XML serializing and deserializing is always between an XML document and a Java object tree
that represents the structure of your XML data, according to some schema.
No tool is able to choke up some code performing the mapping between an arbitrary
agglomeration of the data (as in your DB tables) and some XML content tree. For
instance, if your DB entitiy contains fields
firstname, lastname, street, ZIP, city, country, custno,...
and your XML structure is to be
<cust>
<no>...</no>
<name><first>...<last>...</name>
<address><street>...<city>...<country>...</address>
</cust>
then you cannot marshal from the flat structure; you'll have to create
the customer, name and address object hierarchy first.
-W
On 7/8/09, varun.rally_at_rbs.com<mailto:varun.rally_at_rbs.com> <varun.rally_at_rbs.com<mailto:varun.rally_at_rbs.com>> wrote:
Actually, we don't have control over schema, and we cannot change anything inside it. It is given to us by third party system that accepts the XML that we generate.
But yes the following is the scenario...
we cannot change the XML Schema and the information that needs to be populated in the XML is present in 2 different Java Objects that have been populated from 2 DataBase tables.
So what would be the best way to go for it.
Also, we are open for using technologies other than JAXB, if they better fit the requirement.
________________________________
From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com<mailto:wolfgang.laun_at_gmail.com>]
Sent: 08 July 2009 12:42
To: users_at_jaxb.dev.java.net<mailto:users_at_jaxb.dev.java.net>
Subject: Re: Java objects to XML Mapping.
You might study the JAXB tutorial
https://jaxb.dev.java.net/tutorial/
Chapter 2 contains some advice for writing XML schemas that
will result in good Java code. (It is difficult to imagine that your
120 classes don't contain duplicates, resulting from anonymous
types. So, some rewriting of your schema might reduce this
number, perhaps even considerably.)
Chapter 6 discusses annotations, which is the way to go if you
want to marshal using existing Java classes.
Better advice could be given after seeing (part of) your schema
(consistent substitutions might be sufficient to camouflage its
contents, if that's bothering you).
-W
On 7/8/09, varun.rally_at_rbs.com<mailto:varun.rally_at_rbs.com> <varun.rally_at_rbs.com<mailto:varun.rally_at_rbs.com>> wrote:
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> [mailto: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<mailto: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<mailto:users-unsubscribe_at_jaxb.dev.java.net>
For additional commands, e-mail: users-help_at_jaxb.dev.java.net<mailto: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<
http://www.rbs.com/>
***********************************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net<mailto:users-unsubscribe_at_jaxb.dev.java.net>
For additional commands, e-mail: users-help_at_jaxb.dev.java.net<mailto: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<
http://www.rbs.com/>
***********************************************************************************