DOM and SAX
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
DOM is a document-based parsing process. A DOM parser reads a whole XML source into a large, complex internal structure and provides lots of operations to extract, insert and modify the loaded data. DOM is good for when you need to load and transform whole documents, or create new XML documents in memory ready for such a peocess.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-Mirko
Originally posted by Frank Carver:
SAX is a stream-based parsing process. You can easily configure a SAX parse to grab certain tags and/or their contents, and ignore others. This makes it quick and effective for extracting specific information from potentially large XML sources.
DOM is a document-based parsing process. A DOM parser reads a whole XML source into a large, complex internal structure and provides lots of operations to extract, insert and modify the loaded data. DOM is good for when you need to load and transform whole documents, or create new XML documents in memory ready for such a peocess.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Perhaps this is the one of the most compelling reason to consider DOM-parsing despite of its performance issues. Ofcourse one can always implement a hybrid-SAX that allows manipulating the XML content. It is not impossible, but may be redundant since DOM is available out there which can do the exact same thing!
Hope that helps,
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java2 Platform.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Don't forget though, that there is a difference between the DOM and a DOM. You can build your own lighter-weight Document Object Model, using SAX or any other simple parsing system. JDOM is an example of this; it's a full document model which is much easier to traverse in Java than using the official DOM interface.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
2)SAX is good for large documents because it takes comparitively less memory than Dom.
3)SAX takes less time to read a document where as Dom takes more time.
4)With SAX we can access data but we can't modify data.
5)We can stop the SAX parsing when ever and where ever you want.
6)SAX is sequential parsing but with DOM we can move to back also.
7)To parse machine generated code SAX is better.To parse human readable documents DOM is useful.
[This message has been edited by Murali Mohan (edited June 15, 2001).]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-----------------<br />IBM XML Developer <br />SCJP 1.4
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
This is just guessing, but I don't think there is one that uses SAX. XSL transformation is a complex task (ever seen the XSL specification?), which requires the engine to move back and forth within the document due to even the simplest XPath expressions. In practice, the only viable way I can think of is to keep the whole document in memory (a la DOM).Originally posted by Shabbir Rahman:
Can any one give a XSLT parser name which can transform a big XML file and can give output a big xml file using SAX.
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
If you have to compeletely change the hierarchy, its going to be a BIG memory intensive job. If you are just doing a few renamings, adding/removing attributes or changing limited areas of the hierarchy, then you might be able to write a custom SAX based utility or find a XSLT processor that won't use a lot of memory.
Bill
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-----------------<br />IBM XML Developer <br />SCJP 1.4
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Regards,<br />Ketan KC Chachad
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Ketan Chachad:
Can anyone provide me with a tutorial for SAX?
Go to http://www.ibm.com/developerworks and search for "Understanding SAX".
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
| I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad? The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










