This question is Q. 4 of JAVA Ranch XML Mock exams (DOM AND SAX Questions) I had thought answer should be A, as memory is constrained. However given answer is b. Expert views please.
4. There is XML data document which is very large. The application is to extract the very few of its information from document. The memory & speed may be a constraint. Which is the most likely method to be implemented? a) Extract the information using SAX API, event based methods. b) To extract the information using DOM API. c) To extract the necessary information and process using XSLT. d) To use schema based approach Similarly, in the same exam Q 7, I had thought C should have been the answer, because of memory constraint. However as per mock, answer is B. I would be obliged if anyone can explain. 7. Consider a system which is memory & speed constraint. The application is to process XML documents, sort the contents and mail them to a higher configuration machine for transformation. Which is the best approach? a) Use platform native language to process the docuements b) Use DOM based approach. c) Using SAX based approach is the best. d) DOM and SAX must be used in this context
[ July 03, 2002: Message edited by: ZEESHAN AZIZ ]
Point to remember- DOM is memory intensive. If you have memory constraints, you should reevaluate using DOM. DOM also offers flexibility in terms of random( non-sequential) processing. I have emailed firstname.lastname@example.org who happens to be the author of this mock exam to take a look at the answers he has given. Perhaps with each answer he can include a brief explanation.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
I agree with you on question 6. I'm fairly certain that SAX is the correct answer. On question 7, there is more room for doubt because of the sorting requirement. In this case, the DOM might be a better choice. Actually, XSLT would probably be the tool of choice, and it would most likely use the DOM. In general, when only a small subset of the data is required and when sequential processing is okay, SAX is the answer. When complex processing and random node visits are required, DOM is better.
IBM Certified Developer - XML and Related Technologies<br />CXE (Certified XML Expert)<br />Sun Certified Web Component Developer<br />Sun Certified Java 2 Programmer<p>Dan