Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question to authors on JAXP & SAX  RSS feed

 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Richard,
This might be a newbie question, but I'm curious what is the core difference between JAXP and SAX and when do I want to use each of them to process XML? Also, how thoroughly do you cover XML processing in your book?
Thanks.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vad Fogel:
Hi Richard,
This might be a newbie question, but I'm curious what is the core difference between JAXP and SAX and when do I want to use each of them to process XML? Also, how thoroughly do you cover XML processing in your book?
Thanks.

SAX is an event-based API for processing XML (the XML parser implementation sends your code events as it goes through the XML document).
DOM is a tree-based API for processing XML (the XML parser constructs a Java object hierarchy from the DOM tree that you can then "interrogate" to get the data you want).
JAXP is an implementation-independent API for parsing XML. In other words, you use the factory classes DocumentBuilderFactory and SAXParserFactory, defined in the JAXP API to obtain some implementation of the corresponding parser interfaces.
I'd suggest browsing the articles at IBM developerWorks. They have some pretty good XML related tutorials there.
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response, Lasse!
Actually, I did some programming with both DOM and SAX, but I've never had exposure to JAXP. What I know is that DOM is more intuitive to work with whereas SAX is more efficient for handling memory intensive XML processing. If I get you right, JAXP can potentially take advantage of the both approaches, is it correct?
Thanks.
 
Richard Monson-Haefel
author
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lasse is right on target. I would add that JAXP was intended to be a impl independent way of bootstraping accces to any DOM or SAX parser, but these technologies are now defining their own impl independent frameworks, so its not clear what JAXP will offer in the future.
My book goes in to great detail about XML, XML Namespace and XML Schema, all of which you need to know for Web services. It also covers JAXP, SAX, and DOM - but that coverage is a bit lighter because I found that Elliotte Rusty Harold's wonderful book, *Processing XML with Java* is just the best reference. In the book I cover the parsers, but point readers to Rusty's book for a more indepth study of SAX, JAXP, DOM, and TrAX.
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response, Richard!
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vad Fogel:
If I get you right, JAXP can potentially take advantage of the both approaches, is it correct?
Yes, JAXP can be used for both DOM and SAX based XML processing, but not simultaneously, of course
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!