• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Errors in DOM/SAX Mock exams ???

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I've just tried DOM & SAX Mock exam by Author: Kris. VidhyaSagar
and I'm now a little bit confused with it answer :
DOM & SAX [Design / Implementation/ Information modeling].
Can any more experienced ranchers clearify this ?


2. What are the four interfaces of SAX?
a) DocumentHandler, ErrorHandler, DTDHandler, EntityResolver
b) DocumentHandler, ErrorHandler, DTDHandler, EntityHandler
c) DocumentHandler, Errorhandler, DTDHandler, SchemaHandler
d) None of these


My answer : d
Kris answer : a


3. What does "characters()" method stand for?
a) a method of DOM API to insert character data in the XML document.
b) a method of the SAX DocumentHandler interface to receive notification of the
character data.
c) a method of the DOM interface to replace the entity reference with the character
data.
d) None of these.
My answer : d
Kris answer: b


--------------------------------------------------
DocumentHandler is no longer an interface (deprecated!!!) and became an class in SAX2.
It's worth to noticed that IBM XML Objectives clearly mentioned about SAX2 so the above Kris's answer can't be correct.
-------------------------------------------------


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.


My answer:a
Kris answer : b
--------------------------------
Why use DOM when the document is large; memory & speed may be constrained.
--------------------------------


6. 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.
a)true
b)false


My answer : b
Kris answer : a
--------------------------------
SAX can clearly recognize PI & process it thus the sentence is false.
-------------------------------


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.


My answer: c
Kris answer: b
------------------------------------
I can't understand why SAX alone can't be used ???
because DOM is too costly ("memory & speed constraint") ??
------------------------------------


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.


My answer : a,b
Kris answer: a
-----------------------------------
Why b can't be correct ?
------------------------------------


12. DOM can be used to process the HTML documents also.
a)true
b)false


My answer : b
Kris answer : a
-------------------------------------
??? HTML is not even well-formed XML, so how come DOM cant process it ???
-------------------------------------
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi See,
I have same confuse with you on several answers, maybe some experts can come up and give us explain.
Here is some questions I want to ask you.
5. When you construct an XML using a DOM enabled Parser, the same parser should be used to process back the XML document when the process involves legacy applications, otherwise it is not necessary to do so.
a) Not really
b) Yes, whenver the process is between legacy conectivity this is better.
c) You can use SAX enabled parser to fill this gap.
d) This statement is not a correct one, because DOM is constructed using IDL.

Answer : d
Why the answer is d? why c is not correct? what does "DOM is constructed using IDL" means?
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.

Answers: a
My answer is ABD. why D is not correct?

Thanks
 
Dennis L Chen
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...........and I think for Q12 the answer is "true".
Because the question ask "Can" DOM do........
In case HTML is well-formatted, DOM can be used.
 
See El
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what I understand, well-formed HTML (not well-formed XML) doesn't need to be well-formed XML (ie. <p> tag without closing </p> and more...) so it even won't get through SAX, not mentioning DOM (which in most case use SAX to pre-process XML).
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
El,
Please look at the following. I'm repeating the questions here just for comfort sake -

2. What are the four interfaces of SAX?
a) DocumentHandler, ErrorHandler, DTDHandler, EntityResolver
b) DocumentHandler, ErrorHandler, DTDHandler, EntityHandler
c) DocumentHandler, Errorhandler, DTDHandler, SchemaHandler
d) None of these


The answer is "a". Please have a look at the following API from Java people who implemented the SAX standard -
http://java.sun.com/xml/jaxp/dist/1.1/docs/api/org/xml/sax/package-summary.html
---------------------------------------------

3. What does "characters()" method stand for?
a) a method of DOM API to insert character data in the XML document.
b) a method of the SAX DocumentHandler interface to receive notification of the
character data.
c) a method of the DOM interface to replace the entity reference with the character
data.
d) None of these.


The answer is "b". It is true that DocumentHandler interface has been deprecated and we have ContentHandler in its place.
"DocumentHandler is no longer an interface (deprecated!!!) and became an class in SAX2."
I guess you are confusing DefaultHandler class of SAX2 with DocumentHandler interface of SAX1.
-------------------------------------------------

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.


I think this is a little confusing kind of question. My consensus, i would go for SAX if i see it in the exam. Reasons, it says "The application is to extract the very few of its information from document"
------------------------------------------------

6. 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.
a)true
b)false


This is definitely "false" as SAX can do the stuff in the processingInstruction() method of its ContentHandler interface
-------------------------------------------------

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.


The answer would be "b". Reasons, it is clearly mentioned that they need to sort the contents and this can be achieved with SAX also, but more painful. Hence the "best approach" as required in the question would be DOM. Also remember that "memory and speed" issues are not mentioned at all. We should not assume anything else other than what is given in the question.
-------------------------------------------------

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.


The first and foremost choice would be "a". Sequential processing is the prime feature of the SAX mechanism. It also "can be" used for large documents if we donot have enough memory resources. If we do have enough memory, DOM would always be the most convenient stuff. Hence if you are ask to choose "the best" choice, it would be "a". If you are asked to choose 2 choices, then you should go for "b" also. If you are asked to choose 3 choices, the question should be wrongly framed as the other choices given here are meaningless.
-------------------------------------------------

12. DOM can be used to process the HTML documents also.
a)true
b)false


Yeah; definitely, but "well-formed" html. If you look at the DOM API, they always talk about xml and html together.
http://java.sun.com/xml/jaxp/dist/1.1/docs/api/org/w3c/dom/package-summary.html
One more important thing is that if the document(xml/html) is not well-formed, the parser wouldn't even load it into the DOM tree.
=================================================
Dennis,
Please look at the following -

5. When you construct an XML using a DOM enabled Parser, the same parser should be used to process back the XML document when the process involves legacy applications, otherwise it is not necessary to do so.
a) Not really
b) Yes, whenver the process is between legacy conectivity this is better.
c) You can use SAX enabled parser to fill this gap.
d) This statement is not a correct one, because DOM is constructed using IDL.


The answer is "d". DOM is just an IDL (they don't talk of the implementation, which is typically done by parsers). Hence any parser that implements DOM can be used.
Hope this helps.
 
Dennis L Chen
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jayadev.
 
reply
    Bookmark Topic Watch Topic
  • New Topic