wood burning stoves 2.0*
The moose likes Product and Other Certifications and the fly likes DOM/SAX Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "DOM/SAX Questions" Watch "DOM/SAX Questions" New topic
Author

DOM/SAX Questions

Priya Venkatesan
Ranch Hand

Joined: Nov 02, 2002
Posts: 61
Q1.When Processing Instructions are a part of your parsing process, DOM should be used, since SAX cannot be used to detect a Processing Instruction in a document.

True
False
The think the answer for this should be false, because contentHandler Interface has a method called processingInstruction() to detect it. However the answer given for this is true.
Q2.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.

I think the answer for this should be (a) because of the keywords "
large, extract few, memory &speed constraint. however answer says (b)
Please let me know if my answers are right.
Syed AliRaza Zaidi
Ranch Hand

Joined: May 12, 2002
Posts: 169
According to My point of view
1: True
2: a because you use SAX to Extract and DOM to Maniuplate and Navigate and also memory is constraint therefore you should use SAX
but tell me where did you get these questions?
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
These questions are from the ones in the mock exams section of Javaranch.
The SAX processing Instruction stuff is false as SAX can detect processing instructions by overriding the processingInstruction() method of the ContentHandler interface.
Coming to the DOM/SAX thing, i would go with DOM in this case. These things are really confusing, but i would explicitly look for "filter or extract a subset and doesn't make any mention of searching across constructs, etc." kind of thing to go for SAX.
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
BTW,
I found one related question here -
Q 13. A manufacturing company has an XML application. This application needs to parse
a very big-sized XML comprising of parts information.
The application needs to extract a subset of information about few parts from this
XML document. The system resources allocated for this application are limited. But the
performance has to be good. Which is the best way of doing it?
I feel that until and unless it is very obvious that we should go for SAX(as in the above case), we better stay with DOM. I'll reconsider this at the time of marking the correct option in the exam The bottom line is if the question is vague(as we see in some of them), we have to first define what is wisdom for that moment and then choose wisely
Priya Venkatesan
Ranch Hand

Joined: Nov 02, 2002
Posts: 61
Sorry, I still did'nt get it.
since the question says "large document", "has memory constraint", "need to extract only few parts" I would go for SAX.
Jayadev, why would you choose DOM in the first case(scenario mentioned by me) and why SAX in the scenario posted by you. They both seem to mean the same thing.
These stuffs keep confusing...
Please tell me what are the keywords one should look for in answering these questions.
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
If we look at the questions side-by-side -
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?

AND
A manufacturing company has an XML application. This application needs to parse
a very big-sized XML comprising of parts information.
The application needs to extract a subset of information about few parts from this
XML document. The system resources allocated for this application are limited. But the
performance has to be good. Which is the best way of doing it?

The first and the second scenario are a little different in that in the second they clearly mentioned that -
The system resources allocated for this application are limited. But the
performance has to be good.

The first is a little vague in the sense that -
The memory(system resources) & speed(performance) "may be" a constraint.

I hope that questions will be clearly framed as in the second case for the exam.
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
Also the following is one more instance wherein SAX is the outright choice. The is Q.29 from the following mock exam -
29. For an application that makes use of XML, the input XML data set consists of many elements and is very large. The BEST way to filter or extract a subset of information from the complete XML document would be to:

Look at "filter or extract a subset" and if you find these words, you can almost go for SAX, unless and until they explicitly mention that memory resources are abundant, performance is not of concern and no mention is made of searches across the extracted information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DOM/SAX Questions
 
Similar Threads
Questions on DOM/SAX test from XML Exam List
correct answer
DOM OR SAX
Errors in DOM/SAX Mock exams ???
Question ?