Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding PIs with SAX

 
kavitha balachandran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in one of the mock exam one of the questions is as below
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
the given answer is a(true).
is it correct.i read as SAX is an event based parser and it throws an event when ever it finds start tag,end tag etc...
Regards
Kavitha
 
Hunter Hunt
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kavitha,
As far as SAX is concerned I quote from the book
Processing XML with Java - Elliotte Rusty Harold
Each processing instruction the parser reads is passed to the processingInstruction() method in one invocation. This includes processing instructions that occur before and after the root element. The target is given as the first argument and the data as the second argument.
This is the method signature in Content Handler interface:
public void processingInstruction(String target, String data)
throws SAXException;

So i guess the answer should be FALSE.
Hunter
PS: Here is the URL to the eBook --> http://www.ibiblio.org/xml/books/xmljava/chapters/index.html
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hunter is perfectly right and mock exam is completely false...
See SAX javadoc itself:
http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
method processing instruction()
Best,
Cyril.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic