• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock question

 
Vasim Patel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi


I came across this question in mock siteL
http://www.javaranch.com/xml/XML_DOM_SAX.htm

An XML document to be processed is very large. The application extracts a small portion of the information from the document. Memory and speed may be constraints. Which method or methods are most appropriate for this situation?
a) Use SAX
b) Use DOM
c) Extract the necessary information and process using XSLT.
d) Use a schema-based approach.

I feel a and c are both correct choices. But the correct anser according to the site is C.
I have sent a mail to the owner, but does anyone feel both a and c are correct.
 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

a. Using the SAX parser is fast, but u may not be able to extract and store the information u need.

b. DOM of course slow - so obvoiusly rejected from choice.

c. Using XSLT u can create extract, the required portion. But the catch here is that ur XSLT parser should have been built on top of a SAX parser.

(Making it over DOM wont solve the problem)


Point to note here is that XSLT use DOM or SAX.

it would have been clear to understand if instead of
"Extract the necessary information and process using XSLT."

the option should have stated

"Extract the necessary information and process using XSLT, which is built using SAX".

d. Schema Based approach - this has nothing to do with the question.
 
Ashok Ravi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vasim,
For ur Info., according to the site the correct answer is 'a' and not 'c' .

Thanks,
Ashok R
[ July 20, 2005: Message edited by: Ashok Ravi ]
 
DW Bolton
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel unequivocally that A is the correct answer. As noted by Andy, XSLT is built on top of either SAX or DOM, so is not really relevant.

As you probably know well, SAX does not have the memory requirements of DOM, since it does not require a full tree be built in memory before processing can occur.

Hence SAX will be the quickest way to find a "small portion" of a large XML document. If the portion to be discovered is at the head of the XML doc, then discovering it will be very quick. Even if it is at the end, then processing time is still only the amount of time to traverse the tree, with no "in memory" model required.

XSLT on SAX is just more processing on top of the SAX traversal, and therefore cannot be any quicker.
 
Vasim Patel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everybody. Yes, the answr according to site is A. Sorry about the confusion. I thought C also would be a good choice since the question says "The application extracts a small portion of the information from the document."
I felt XSLT could also fit in.
Thanks again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic