![]() |
xml to object and vice versa
Hi,
I have an xml file, corresponding to an xsd. If there some tool, which would take this xml and xsd and give me an object. And also take the object and xsd and give me xml. I read about couple of tools like JAXB, xstrem and xmlBeans. The issue i have with them, is they make their own classes, i want to use classes which i have already defined by my object. And it's not similar to the ones they create. Is there any other tool, which also takes classes and use that for object? Regards, Jyoti |
Re: xml to object and vice versa
On 23 Jul, 12:02, JyotiC <jyoti.chha...@gmail.com> wrote:
> Hi, > http://www.castor.org/ Mike. > I have an xml file, corresponding to an xsd. If there some tool, which > would take this xml and xsd and give me an object. And also take the > object and xsd and give me xml. > > I read about couple of tools like JAXB, xstrem and xmlBeans. > The issue i have with them, is they make their own classes, i want to > use classes which i have already defined by my object. And it's not > similar to the ones they create. > > Is there any other tool, which also takes classes and use that for > object? > > Regards, > Jyoti |
Re: xml to object and vice versa
Thanks Mike.
It's saying about the mapping file. Could Castor use xsd instead of a mapping file? Regards, Jyoti On Jul 23, 6:33 pm, mikew01 <mike...@blueyonder.co.uk> wrote: > On 23 Jul, 12:02, JyotiC <jyoti.chha...@gmail.com> wrote:> Hi, > > http://www.castor.org/ > > Mike. > > > I have an xml file, corresponding to an xsd. If there some tool, which > > would take this xml and xsd and give me an object. And also take the > > object and xsd and give me xml. > > > I read about couple of tools like JAXB, xstrem and xmlBeans. > > The issue i have with them, is they make their own classes, i want to > > use classes which i have already defined by my object. And it's not > > similar to the ones they create. > > > Is there any other tool, which also takes classes and use that for > > object? > > > Regards, > > Jyoti |
Re: xml to object and vice versa
JyotiC wrote:
> I have an xml file, corresponding to an xsd. If there some tool, which > would take this xml and xsd and give me an object. And also take the > object and xsd and give me xml. > > I read about couple of tools like JAXB, xstrem and xmlBeans. > The issue i have with them, is they make their own classes, i want to > use classes which i have already defined by my object. And it's not > similar to the ones they create. I think you should redesign. It is not good to have two originals: both xsd and java. One should be generated from the other. And then all tools will work. Arne |
Re: xml to object and vice versa
> It's saying about the mapping file.
> Could Castor use xsd instead of a mapping file? Not sure on that one Ive only ever used it with the castor mapping files, very easy to set up and very versatile, we use it commercially. This tutorial seems to make use of an xsd http://www.geocities.com/sireenmalik/details.html. Mike. |
Re: xml to object and vice versa
> The issue i have with them, is they make their own classes, i want to > use classes which i have already defined by my object. And it's not > similar to the ones they create. Write a XMLRenderer interface and a XMLRenderer class for your class. And make your class XMLRenderable and set it up so it can be instantiated with a XMLRender. It's tedious to write the rendering and instanciating code yourself (although there are workarounds) but with some packages - especially when you're dealing with XML - you can run into encoding issues - like you render an object assuming UTF-8 and it's something else and you end up with a null object instead of something usable. Later, if you'd like, you can swap out the XMLRender class to use Castor or JDOM or reflection, whatever you want. |
Re: xml to object and vice versa
On Jul 24, 6:38 am, Arne Vajhøj <a...@vajhoej.dk> wrote:
> JyotiC wrote: > > I have an xml file, corresponding to an xsd. If there some tool, which > > would take this xml and xsd and give me an object. And also take the > > object and xsd and give me xml. > > > I read about couple of tools like JAXB, xstrem and xmlBeans. > > The issue i have with them, is they make their own classes, i want to > > use classes which i have already defined by my object. And it's not > > similar to the ones they create. > > I think you should redesign. It is not good to have two > originals: both xsd and java. One should be generated from > the other. And then all tools will work. > > Arne My java code is generated from xsd. But it's different format then JAXB and others. Now i need to add functionality of to and from xml. Regards, Jyoti |
Re: xml to object and vice versa
JyotiC wrote:
> On Jul 24, 6:38 am, Arne Vajhøj <a...@vajhoej.dk> wrote: >> JyotiC wrote: >>> I have an xml file, corresponding to an xsd. If there some tool, which >>> would take this xml and xsd and give me an object. And also take the >>> object and xsd and give me xml. >>> I read about couple of tools like JAXB, xstrem and xmlBeans. >>> The issue i have with them, is they make their own classes, i want to >>> use classes which i have already defined by my object. And it's not >>> similar to the ones they create. >> I think you should redesign. It is not good to have two >> originals: both xsd and java. One should be generated from >> the other. And then all tools will work. > > My java code is generated from xsd. But it's different format then > JAXB and others. Now i need to add functionality of to and from xml. You should obviously have picked a tool that generated Java code that had read and write capability. But if you did not and you can not switch tool, then I think you will need to write code yourself. Arne |
Re: xml to object and vice versa
On Jul 25, 5:58 am, "gimme_this_gimme_t...@yahoo.com"
<gimme_this_gimme_t...@yahoo.com> wrote: > > The issue i have with them, is they make their own classes, i want to > > use classes which i have already defined by my object. And it's not > > similar to the ones they create. > > Write a XMLRenderer interface and a XMLRenderer class for your class. > > And make your class XMLRenderable and set it up so it can be > instantiated with a XMLRender. > > It's tedious to write the rendering and instanciating code yourself > (although there are workarounds) but with some packages - especially > when you're dealing with XML - you can run into encoding issues - like > you render an object assuming UTF-8 and it's something else and you > end up with a null object instead of something usable. > > Later, if you'd like, you can swap out the XMLRender class to use > Castor or JDOM or reflection, whatever you want. This sounds good. I'd give it a try. Thanks! I do have one question in it. If my xsd use sequence. How would XMLRenderer know about order? Regards, Jyoti |
Re: xml to object and vice versa
If you're looking for something that knows about sequences I recommend
that you lookup up hibernate and middle-gen. middle-gen can connect to a database and: Create XML representations of the tables Handle sequences for most databases - MySQL, Oracle, and DB2 Can create Java classes from the database-tables/XML-representations with getters and setters Provides a tool to tweak datatypes such as Longs instead of Integers The same tool also creates an ERD of the database tables. > I do have one question in it. If my xsd use sequence. How would > XMLRenderer know about order? > > Regards, > Jyoti- Hide quoted text - > > - Show quoted text - |
| All times are GMT. The time now is 04:42 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.