need some help answering these questions :) 1.Explain the differences between pa
ID: 3822878 • Letter: N
Question
need some help answering these questions :)
1.Explain the differences between parsing an XML document using a DOM parser and using a SAX parser. Discuss the positive and negative aspects of each. For each of the two types of parsing (i.e., DOM and SAX), give an example of a situation where that type of parsing (i.e., DOM or SAX) would be the best one to use.
(This question is meant to require a short, 2-3 sentence, answer.)
2.Which interface must the class that handles XML SAX parsing events implement?
a)ActionListener
b)ActionHandler
c)EventHandler
d)ContentHandler
e)None of these
3.Assuming default behavior of Java's XML parsing (i.e., no special options are given to constructors, no method calls are made to modify behavior, and the parser is not in validating mode), identify each of the children that would be parsed from the following XML fragment.
<font>
<name>Helvetica</name>
<size>36</size>
</font>
Feel free to consult the XML DOM example which was reviewed in class for additional details on how an XML document like this would be parsed.
4.Explain each part of this DTD line:
<!ELEMENT favorite(#PCDATA)>
5.Describe the difference in how XML data are accessed in a Document object (i.e., DOM-parsed) and via XPath. For example, describe how you would obtain the data item contained by a specific element in each case and what steps you would have to take or what knowledge would be required in each instance.
(This is meant to require a thorough, 1-2 paragraph, answer.)
6.Which of the four JDBC driver types is best? Why?
Explanation / Answer
The Document Object Model is designed by World Wide Web Consortium (W3C) and recommended parsing technique. By using it we can define an interface that enables programs to access structure and contents of XML documents. when parsing an XML document with a DOM parser, then we get tree structure that contains all of the elements. The DOM provides a variety of functions you can use to examine the contents and structure of the document.
Advantages
The main advantage of DOM is, it is a common interface for manipulating structures.
It's goal is that Java code written for one DOM-should run on any other DOM parser.
SAX parser:
Sax parser working is completely different with a DOM parser, it neither load any XML document nor create any object.The SAX parser use callback function (org.xml.sax.helpers.DefaultHandler) to informs clients of the XML document structure.
Advanatge:
SAX Parser is faster.
It and uses less memory than DOM parser.
2) Event handler handles XML SAX parsing events to implement.
6) All the four types ahvs their own benifits. It's depends on usage.
Suppose we are accessing only perticular database database It is better to use type 4.If we are accessing morethan one at a time JDBC-Net pure java is better.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.