Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDOM vs. SAX performance

 
Sergei Voropay
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently started using JDOM for my XML projects. Compared to parsing and building a document tree with SAX or DOM, JDOM is a blessing in the skies for a Java programmer considering the ease of use. Is there a significant trade-off in performance? Does anyone have any benchmarks comparing SAX and JDOM?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Forgive me if I say the wrong thing, but isn't this
comparing apples and oranges. As I understand, SAX and
(J)DOM models serve different purposes. I am sure we can
get them to work vice-versa, but then IMHO, they are to
be applied in different situations.
I can understand a comparision between JDOM and someother
DOM implementation (if one exists) but JDOM verses SAX ???

Don't don't get me wrong, but just curious as to what others
think?
regds.
- satya
 
Sergei Voropay
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a direct relationship between SAX and JDOM because because in the majority of cases you will use SAXBuilder to build a JDOM document. So it is not like comparing apples and oranges...
 
Sergei Voropay
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Madhav, I probably wasn't clear enough when posting my question. What I was getting at is that you can use both SAX/DOM and JDOM to create XML-aware objects (objects that know how to obtain their state from XML sources and present themselves in XML format). JDOM provides much more Java programmer-friendly approach to dealing with document trees as compared with SAX/DOM, so I was wondering what is the magnitude of performance penalty for using JDOM to obtain the object state from XML sources compared to using SAX for the purpose.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

JDOM attempts to incorporate the best of DOM and SAX. It's a lightweight API designed to perform quickly in a small-memory footprint. JDOM also provides a full document view with random access but, surprisingly, it does not require the entire document to be in memory. The API allows for future flyweight implementations that load information only when needed.
Hope that helps!
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

oooh!
Thanks for clarifying. Appreciate it.
My understanding (read confusion) of JDOM was Java
implementation of DOM model and so I thought it had
nothing to do with SAX.
regds.
- satya
 
hanumanth reddy
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JDOM support both DOM as well as SAX Specification and it is easy to use Api.

hanumanth reddy

http://www.cyberdosti.com
 
Phil Madden
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main thing you have to remember about SAX is..the S stands for simple. It is a sequential api...so...when you want to locate a node...it will search the entire tree. JDOM however will load the entire tree into a DOM when parsing..meaning..its in memory and in a hierarchical manor so searching/manipulating/editing is much faster. Hope this helps

Slihp
 
Phil Madden
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also...for you hardcore guys out there...the DOM means recursion..
 
Paul Clapham
Sheriff
Pie
Posts: 20966
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Phil, please Don't Wake The Zombies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic