Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt regarding JAXB

 
Sachet Varma
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesnt JAXB score over DOM2 everytime? In the sense , if I have a document , I can marshall it into its object oriented version of interfaces and content trees.
So even if various parts of my app need to work on the doc , I have the XML represented n these classes.

So when would I ever want to use DOM over JAXB??

Do let me know if my concepts are shaky.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
The answer to your first statement is: No.
JAXB and DOM are used for different things.
With JAXB, one binds XML data that adhers to one or more XML schemas that are known beforehand. The result is an object tree of special classes created by the JAXB schema compiler.
DOM is more suitable to process arbitrary XML data, perhaps adhering to some schema that you do not know of beforehand. DOM also creates an object tree in memory, but the objects are of general classes, such as Node, Element, Text etc (all in the org.w3c.dom package).
Best wishes!
 
Sachet Varma
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ivan. Its clear now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic