• 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

Questions on DOM/SAX test from XML Exam List

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 2 questions regarding DOM/SAX test from Java Ranch's XML Exam List.
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.
Answer:b
Can someone tell me why a is not correct?
11. Use of SAX based parser is most likely to be used in which of the following scenarios?
a) You want to process the document in a sequential order only.
b) The documents is very large.
c) When there is no need to validate XML documents.
d) The parser implements only SAX based approach.
Answer:a
I think b is also OK.

Thanks
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,
I think, the answer for the fist question should be SAX parser, because question specificaly mentinons, Memory may be a constraint and DOM parsers are heavy on memory when XML documents are very large.
As u know, the DOM parser builds the DOM tree (in memory) for the entire XML document before parsing it. Hence for a large XML document performance of the application would be hit badly if a DOM parser is used.
For 2nd question a seems to be an approporiate choice because it mentions that document is to be processed sequentially and only SAX parsers have this feature.
Hope this helps,
amit

Originally posted by Brooklyn Luo:
I have 2 questions regarding DOM/SAX test from Java Ranch's XML Exam List.
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.
Answer:b
Can someone tell me why a is not correct?
11. Use of SAX based parser is most likely to be used in which of the following scenarios?
a) You want to process the document in a sequential order only.
b) The documents is very large.
c) When there is no need to validate XML documents.
d) The parser implements only SAX based approach.
Answer:a
I think b is also OK.

Thanks



------------------
Sun Certified Java Programmer for Java 2 Programming
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For question 1:
I believe 'a' is not correct because, although it is true that SAX offers better performance than DOM with large documents, 'b' is MORE likely to be used because SAX forces you to read the document sequentially whereas DOM allows you to navigate to a portion of the document and manipulate the data in place. This satisfies the requirement of extracting very few of the information from the document in a timely manner. If you were outputting the entire document, SAX would be more efficient, and thus 'a' would be correct.
Question 2:
Again both are correct, but we need to answer which is MORE likely. Although it is true that the efficiency of processing large documents is greater with SAX than DOM, the fact that the document MUST be processed sequentially suggest that the only logical choice can be SAX.
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Scott Collens:
For question 1:
I believe 'a' is not correct because, although it is true that SAX offers better performance than DOM with large documents, 'b' is MORE likely to be used because SAX forces you to read the document sequentially whereas DOM allows you to navigate to a portion of the document and manipulate the data in place. This satisfies the requirement of extracting very few of the information from the document in a timely manner. If you were outputting the entire document, SAX would be more efficient, and thus 'a' would be correct.


Regarding input: what kind of magic in your opinion makes it possible for DOM just to skip pieces the input file up to the right position where relevant data can be found, as opposed to SAX which reads the same characters and passes them to handlers which in turn are free to skip thiem?
Regarding output: does SAX has anything to do with document output?
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is evident from the discusion that the cause of confusion is the ambiguous sentences used to frame the questions. Can someone email the author( his address can be found on top of the mock exam page ) and findout the intent? Perhaps he can reframe the question if he feels all of us have misunderstood the original intent.
Thanks!
 
Scott Collens
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vlad Patryshev:
Regarding input: what kind of magic in your opinion makes it possible for DOM just to skip pieces the input file up to the right position where relevant data can be found, as opposed to SAX which reads the same characters and passes them to handlers which in turn are free to skip thiem?
Regarding output: does SAX has anything to do with document output?


My apologies. I was considering that one may want to update the info., rather than just extract it. I tend to agree with Brooklyn. SAX appears to be the the correct solution.
Regarding output. Once again, I apologize for my poor choice of words. If some one has contacted the author of the test, can you kindly post the response.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic