Question

I am having trouble with these JDBC and XML questions. 1) The type of XML Parsing...

I am having trouble with these JDBC and XML questions.

1)

The type of XML Parsing that parses an XML document based on expression and is used extensively in conjunction with XSLT.

a) SAX Parsing

b) DOM parsing

c) StAX

d) XPath Parsing

2)

On the XML below, which XPath expression will return all of the values of title attributes?


<slideshow
title="Sample Slide Show"
date="Date of publication"
author="Yours Truly"
>
<!-- TITLE SLIDE -->
<slide type="all">
<title>Wake up to WonderWidgets!</title>
</slide>
<!-- OVERVIEW -->
<slide type="all">
<title>Overview</title>
<item>Why <em>WonderWidgets</em> are great</item>
<item>Who <em>buys</em> WonderWidgets</item>
</slide>
</slideshow>

a) //[@title]

b) //@title

c) //slide/title

d) //title

3)

Well formed XML document means

a) it contains a root element

b) it contain an element

c) it contains one or more elements

d) must contain one or more elements and root element must contain all other elements

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Q1 -> (d)

Explanation: XPath parser is recommended by W3C (World Wide Web Consortium).Information in an XML file can be extracted by using expressions. These expressions are provided by XPath for fetching the required information from the input expression.XPath parser is used alongside XSLT (standard) and fetches the data based on various components like: Path Expressions, Standard Functions and Structure Definitions.

Option a is wrong because SAX Parser is not used with XSLT and is an event based parser, it reads the XML from top to the end and receives event notifications to parse the document sequentially.

Option b is wrong because DOM Parser is also not used with XSLT instead, it creates a DOM tree that is constructed using JAVA Programming language interfaces. The required data can be fetched using the functions provided by the DOM interface.

Option c is wrong because StAX Parser is an API based on JAVA Programming language that works in a similar manner to that of a SAX parser. It is based on event model of parsing and it encounters elements as events and does the parsing.

Q2 -> (b)

Explanation: Since we are talking about title attributes here and NOT title elements hence the answer would be //@title since an attribute is selected in XML using XPath Parser using the path expression: //@attrib.This selects all the attribute with the name 'attrib' in the XML document. Here we can say that @ is used in case of attributes and // for elements.

Option a is wrong since it is incorrect way of referring to an attribute without mentioning its parent element.

Correct way would be //element[@attribute].

Option c is wrong because it refers to the attributes of the element 'slide' and there is no such element in the XML provided.

Option d is wrong because it refers to all the elements of the name title and in the question we are asked to fetch the attributes named 'title' and not elements.

Q3 -> (d)

Explanation: A Well formed XML document is the one which contains a root element and all other elements (one or more) must be enclosed within a single root element. Other rules governing the well-formedness of an XML are:

  1. Corresponding ending tag for each starting tag.
  2. Proper nesting of elements.
  3. Attributes names must be different in an element and its values be quoted.
  4. Document must have a root elements and all other elements(one or more) must be enclosed within a single root element.

Option a is wrong because mere presence of a root element does not guarantee the well formedness of a document.

Option b is wrong because it talks of including only one element that too can be root or not.

Option c is wrong because it talks of including only one or more elements but it is also important to wrap those elements in a single root element which is not mentioned in this option.

Add a comment
Know the answer?
Add Answer to:
I am having trouble with these JDBC and XML questions. 1) The type of XML Parsing...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1) In the XPath data model, a root node represents _______________? a) the document itself b)...

    1) In the XPath data model, a root node represents _______________? a) the document itself b) all within the XML declaration c) all the information within a particular namespace d) the root element 2) What is not a valid XPath data model node? a) Element b) Root c) Attribute d) Text e) Document type declaration 3) which of the following lines is the abbreviated syntax of attribute::attributename? a) %Cattributame b) &attributename c) @attributename d) #attributename 4) Axes are used to...

  • Please answer for all the subparts, explaination is not necessary, only answers will suffice. 1) How...

    Please answer for all the subparts, explaination is not necessary, only answers will suffice. 1) How many startDocument events and how many startElement events will be fired when the following XML SAX parser? <a> <b q='yyy'>zzz</b> <c>nnn</c> <d>ppp</d> </a> a) O startDocument events and 4 startElement events b) O startDocment events and 3 startElement events c) 1 startDocment events and 4 start Element events d) 1 startDocment events and 3 startElement events 2) The bracket in the following is an...

  • I am having trouble with my C++ program.... Directions: In this lab assignment, you are to...

    I am having trouble with my C++ program.... Directions: In this lab assignment, you are to write a class IntegerSet that represents a set of integers (by definition, a set contains no duplicates). This ADT must be implemented as a singly linked list of integers (with no tail reference and no dummy head node), but it need not be sorted. The IntegerSet class should have two data fields: the cardinality (size) of the set, and the head reference to the...

  • Download the library.xml file. The root element is CATALOG and contains a series of BOOK elements,...

    Download the library.xml file. The root element is CATALOG and contains a series of BOOK elements, each of which represents a single BOOK. Each BOOK element has a number of child elements such as AUTHOR, TITLE, GENRE, PRICE and so on. Python Language 3.8 Add comments for each line Thank you Write a program to read the file and print out the following information with an appropriate message: 1. (40 points) Write a function called display_book that prints the title,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT