HSLC Computer Science Solution: Chapter 5 (XML) - UJUDEBUG

HSLC Computer Science Solution: Chapter 5 (XML)

Empty Blackboard

Contents:

 

 

  • Objective Type Questions:

1. Fill in the blanks:

a. …………………. is the extension of an XML file name.
ans: .xml

b. XML attribute value should always be enclosed in ………………….
ans: double quotes

c. An XML document can only have one …………………. element.
ans: parent

d. Some characters that have a special meaning in XML are called ………………….
ans: entity

e. PCDATA stands for Parsed …………………. Data.
ans: Character

2. True and False

a. An XML document can have only a limited number of child elements.
ans: False

b. XML is not case sensitive.
ans: False

c. XML is designed to replace HTML.
ans: False

d. XML is a software and hardware dependent language used for carrying information.
ans: True

e. XML was developed as per W3C’s recommendation.
ans: True

 

3. Choose the correct option.

a. Which one of the following is a valid name for an XML element?
i. <xmldocument>
ii.. <12rollno>
iii. <customer number>
iv. <student>

ans: iv. <student>

b. Which of the following is the correct element type declaration for the occurrence of the ‘FirstName’ element and the ‘LastName’ element in order, as the child element of the ‘Name’ Element?
i.<!ELEMENT Name (FirstName)>
<!ELEMENT Name (LastName)>
ii.<!ELEMENT Name (FirstName, LastName )>
iii. <!ELEMENT Name (FirstName | LastName )>
iv. <!ELEMENT Name (FirstName / LastName )>

ans: iii. <!ELEMENT Name (FirstName | LastName )>

c. Which of the following is used to specify the attribute list of an element?
i. #ATTLIST
ii. !ATLIST
iii. *ATTLIST
iv. ?ATTLIST

ans: ii. !ATLIST

d. The characters associated with elements that control how many times an element may appear in the XML document are
i. ?
ii. *
iii. +
iv.all of these

ans: iv.all of these

e. The statement for associating external DTD declaration with ‘item.dtd’ is
i. <!DOCTYPE “item.dtd”›
ii. <!DOCTYPE SYSTEM “item.dtd”›
iii. <!DOCTYPE item SYSTEM “item.dtd”›
iv. <!DOCTYPE root SYSTEM “item.dtd”›

ans: iii. <!DOCTYPE item SYSTEM “item.dtd”›

 

  • Descriptive Type Questions

1. Short Answer Questions

a. What is DTD? List the two types of DTD?
ans: DTD stands for Document Type Definition. A DTD provides a list of elements contained in an XML document and their relationship with one another
The two types of DTD are: (1) Internal DTD & (2) External DTD

b. What is an XML parser? Define the two types of XML parsers.
ans: XML parser is a software that reads an XML document, identifies all the XML tags, and passes the data to various applications (interprets or parses the code according to the XML standard). The two types of XML parser are:
(1) Non-validating XML parser: It checks if an XML document is well-formed, i.e., if the document is properly marked up according to XML syntax rules. All browsers are non-validating XML parsers. A few other examples are OpenXML, Lark, XP, expat, XParse, and xmllib.
(2) Validating XML parser: It checks if an XML document is well-formed and also ensures that all elements in the document are exactly as specified in the DTD to which the document is bound, i.e., it checks the validity of the XML document. A few examples of validating XML parser are XML4C, XML4J, MSXML, ,Tc1XML, and xmlproc.

c. What does an attribute list declaration contain?
ans: The attribute list declaration contains the following information:
• The element to which an attribute is associated
• The name of the attribute
• The type of the attribute
• The default value of the attribute

d. What are the four default values of an attribute?
ans: The for default values of an attribute are:
• REQUIRED: The value of the attribute must be supplied.
• IMPLIED: The XML application decides which value of the attribute to use if no value is supplied.
• FIXED: The value of the attribute is included in the declaration itself. The XML document must either supply the same value or nothing.
• SUPPLIED: The DTD supplies the default value of the attribute if it is not provided in the XML document. If the value is supplied, the supplied value is used.

e. What is an entity? What are its two types?
ans: An entity is a sequence of characters used to represent another sequence of characters. There are some characters that have special interpretations in XML. For example, the greater than (>) and less than (<) characters are used to delimit tags and, therefore, cannot be placed inside the data directly.
There are two types of entities:
• Pre-defined entity
• User-defined entity

2. Long answer questions

a. List five differences between HTML and XML.
ans:

HTML

XML

1.

The static text content is placed between the tags and is never modified by any process.

The data is stored in a separate XML file and can be updated with a few lines of JavaScript.

2.

No document structure is present.

The document structure is like a tree. The root element is the parent of all other elements.

3.

HTML tags are pre-defined.

XML tags are user-defined.

4.

There are empty tags in HTML.

In XML, to satisfy the requirement for a pair of tags, the opening and closing tags are combined.

5.

Tags are not case-sensitive.

Tags are case-sensitive.

6.

The attribute values can be written without quotes, with single quotes(‘) or with double quotes(“)

The attribute value should be surrounded by double quotes only

b. What are the rules for defining a well-formed XML document?
ans: A well-formed XML document must meet the following requirements:
1) The ‘root’ and ‘child’ elements must be nested in a proper way.
2) Each start tag must have the corresponding end tag.
3) All empty tags must be enclosed properly.
4) As XML tags are case-sensitive, the start and end tags must be of the same spelling and case.
5) XML’s attribute values are enclosed within double quotation marks.

c. Explain the difference between comma and pipe symbols in deciding how child elements are used within an XML document.
ans: Using the comma (,) symbol the elements must appear strictly in the order in which they are defined in the element declaration.
Whereas, using the pipe (|) symbol, the elements may appear one or more times in any order.

d. What is the difference in using the character ?(question mark), *(asterisk), and +(plus) to control how many times an element appears in the XML document?
ans: • ? (Question mark) This symbol indicates that an element may not appear at all or may appear once in the XML document (0 or 1).
• * (Asterisk) This symbol indicates that an element may not appear at all or may appear any number of times in the XML document (0 or many).
• + (Plus) This symbol indicates that an element must appear at least once or any number of times in the XML document (1 or many).

e. Explain the four variations in specifying the value of an attribute by using an example each.
ans: The four default values of an attribute are:
• REQUIRED: The value of the attribute must be supplied.
• IMPLIED: The XML application decides which value of the attribute to use if no value is supplied.
• FIXED: The value of the attribute is included in the declaration itself. The XML document must either supply the same value or nothing.
• SUPPLIED: The DTD supplies the default value of the attribute if it is not provided in the XML document. If the value is supplied, the supplied value is used.

Examples:
Attribute Type Declaration in DTD code:

<!ATTLIST emp status CDATA #REQUIRED>
<!ATTLIST emp status CDATA #IMPLIED>
<!ATTLIST emp status CDATA “Permanent”>
<!ATTLIST emp status CDATA #FIXED “Permanent”>

XML Code:

<emp status = “Permanent”›
<emp/> or <emp status = “Permanent”›
<emp status/> or <emp status = “Permanent”›
<emp status = “Temporary”› or <emp status = “Contract”› or <emp status/>

 

  • Application-based Questions

1. Draw the XML tree for the code given below:

<movie>
<thriller>
<director>Amit Lalwani</director>
<releasedate>23/08/2013</releasedate>
</thriller>
<fiction>
<director>Raj Hirani</director>
<releasedate>15/12/11</releasedate>
</fiction>
</movie>

ans:

 

3. Write any two possibilities of the XML document validated against the DTD given below:

<!ELEMENT customer (name, email?, phone*)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT phone (#PCDATA)>

4. Consider the XML document and answer the following questions:

<?xml version = “1.0”?>
<customer name = “Amy”›
<address>
<addl> 13 Mahavir Enclave, South Ext. </addl>
<city> Delhi </city>
<country> India </country>
</address>
</customer>

a. What is the use of the first line of code?
ans: The first line is called the processing instructions line. It passes specific information to the browser on how to deal with the XML document.
b. Name the element that has an attribute in the above code?
ans: The customer element has an attribute in the above code
c. Name the root element in the code.
ans: <customer> is the root element in the code.
d. List the child elements of <address>.
ans: The child elements of <address> are <addl>, <city> and <country>

5. Consider the XML code given below and answer the questions following it:

<book category = “text”›
<bname> Understanding XML </bname>
<price> Rs. 375 </price>
</book>

a. How many elements are present in the above code?
ans: Three elements are present in the above code.
b. How many attributes are there in the above code? Name them.
ans: Only one attribute is there in the above code. It is the category attribute.


 

Interested? Have any questions?

support@ujudebug.com

For more info Call us

+918011624355

3 Comments

  1. Himakshi talukdar says:

    Tq soo much .. I got much help from this website ..

Leave a Reply

Your email address will not be published. Required fields are marked *

Call us now!

[one_third][/one_third][two_third]With a team of skilled software Developers, Ujudebug is the best IT Solution Company in Assam. Fully Customized Software Development services with multiple platforms. Our award winning team will we provide the best experience to customers at an affordable price.

Sales : +91-8011624355

Support : +91-8486201473

Our promise

We promise to provide exceptional service during your journey with us. Our experienced team delivers an unmatched level of client satisfaction from a broad range of software solutions, and IT consulting services. What are you waiting for:
  • - Give us a call on +918011624355
  • - Let our friendly team know your project
  • - Tell us how, when you want to start it
  • - Get it at the best possible price with all documentation
That’s it! The whole thing should only take a few minutes.[/two_third]

Call us now!

With a team of skilled software Developers, Ujudebug is the best IT Solution Company in Assam. Fully Customized Software Development services with multiple platforms. Our award winning team will we provide the best experience to customers at an affordable price.

Sales : +91-8011624355

Support : +91-8486201473

Our promise

We promise to provide exceptional service during your journey with us. Our experienced team delivers an unmatched level of client satisfaction from a broad range of software solutions, and IT consulting services. What are you waiting for:

  • - Give us a call on +918011624355
  • - Let our friendly team know your project
  • - Tell us how, when you want to start it
  • - Get it at the best possible price with all documentation

That’s it! The whole thing should only take a few minutes.