Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXP and JAXB

 
Silvio Esser
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When should we use JAXB or JAXP? I saw some overlap on them.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick search of the XML forum discovers that this has recently been discussed.
[ January 26, 2006: Message edited by: Ulf Dittmer ]
 
Silvio Esser
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info.

If I need to create a XML document, I can use JAXP(DOM) or JAXB. But which way is the best?
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you aren't currently using or willing to start using XMLSchema to define an XSD for your documents, then you can ignore JAXB. Nothing wrong with JAXB, just that it is intended to fit into the XMLSchema tools space, not the DTD tools space.
 
Paul Clapham
Sheriff
Posts: 21319
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Silvio Esser:
If I need to create a XML document, I can use JAXP(DOM) or JAXB. But which way is the best?
That depends entirely on where the data for the XML document comes from, and what you plan to do with the XML document.

If you have a Java object and you want to convert it into XML, and subsequently convert back into the same object, then use JAXB. If you have data in a database (for example) and you want to make it into XML, then use one of the JAXP technologies. As usual in the computing business there is no such thing as "best". Spend some time learning about the various XML technologies and you will not find it necessary to ask questions like this one. Specific questions are much easier to answer.
 
Silvio Esser
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may call it "better" instead of "best".

Thanks for the inputs. I agree with you that there are just too many
frameworks or tools out there that do a little helps, but more confusions.
I know BEA has xBean does the same thing as JAXB.
[ January 26, 2006: Message edited by: Silvio Esser ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might browse the last couple of weeks of posts in this forum. As I recall, a variety of XML creation problems have been discussed recently, with many different solutions proposed.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic