• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DOM/SAX Questions

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic