aspose file tools*
The moose likes XML and Related Technologies and the fly likes JDOM vs. SAX performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JDOM vs. SAX performance" Watch "JDOM vs. SAX performance" New topic
Author

JDOM vs. SAX performance

Sergei Voropay
Ranch Hand

Joined: Feb 20, 2001
Posts: 31
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

Joined: Jun 03, 2000
Posts: 5040

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

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Sergei Voropay
Ranch Hand

Joined: Feb 20, 2001
Posts: 31
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

Joined: Feb 20, 2001
Posts: 31
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

Joined: Mar 17, 2000
Posts: 5782

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.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

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

Joined: Jun 12, 2000
Posts: 118
JDOM support both DOM as well as SAX Specification and it is easy to use Api.

hanumanth reddy

http://www.cyberdosti.com


<a href="http://www.jobklub.com" target="_blank" rel="nofollow">http://www.jobklub.com</a><br /> 'Add Job To Life'
Phil Madden
Greenhorn

Joined: Aug 01, 2008
Posts: 2
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

Joined: Aug 01, 2008
Posts: 2
also...for you hardcore guys out there...the DOM means recursion..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

Phil, please Don't Wake The Zombies.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDOM vs. SAX performance