• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML and Object already defined. JAXB type questions

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, so we have an Object Model already that we use in our application. We have a web service with its XML schema defined already. The Object Model and XML are set and I need to be able to convert between the two easily. JAXB has the marshalling and unmarshalling of XML to Object and back.

For some reason in my head, I remember that you can generate Java files from an XML Schema and you can create an XML Schema from a Java Object. But what if you already have those two side defined. Can you just create a mapping file that maps the XML to the Object Model?

Or is there a seperate tool we should use. I know Castor looks like they have such a thing.

Thanks

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks exactly like what Castor can provide. Next question will be what overhead to performance will using Castor to marshal and unmarshal as compared to just using DOM and XPath.

Mark
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With DOM and XPath implementations, you do the dirty laundary.
With Castor, it does the laundary for you with your schema as the input.
I have known/worked on projects that relied on Castor (as opposed to ding it ourselves) and I assume they did their homework before going that way. So, I would go with Castor rather than DOM/XPath. My two cents.......


- m
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just want to be sure of the question. Are you just trying to
have some kind of Java-to-XML-to-Java mapping, and don't
care about web services or JAXB? Or are you trying to use
web services and/or JAXB, but want them to use a mapping
you've already created?

As for performance, I haven't tried castor, but I did
some testing to compare JAXB, XmlSchema, SAX, Digester,
Stax.
- stax was best if you could could
keep a reference to your processor
and keep reusing it
- xmlschema was best if you couldn't
keep a reference to your processor
- jaxb was a close second to xmlschema
when you couldn't keep a reference,
and the jaxb type mappings are much
more flexible.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic