Semester
Subject
Year
Tribhuwan University
2079
Bachelor Level / Third Year / Fifth Semester / Science
(Web Technology)
Full Marks: 60
Pass Marks: 24
Time: 3 Hours
Candidates are required to give their answers in their own words as for as practicable.
The figures in the margin indicate full marks.
Long Answers Questions
XML (eXtensible Markup Language) is a markup language designed to store, transport, and structure data in a format that is both human-readable and machine-readable.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library SYSTEM "library.dtd">
<library>
<book id="101">
<title>Web Technology</title>
<author>
<firstname>John</firstname>
<lastname>Smith</lastname>
</author>
<price>450.00</price>
<year>2020</year>
</book>
<book id="102">
<title>XML Fundamentals</title>
<author>
<firstname>Mary</firstname>
<lastname>Jones</lastname>
</author>
<price>350.50</price>
<year>2021</year>
</book>
</library>
Explanation of Element Types:
Simple Type Elements — Elements that contain only text/data and no child elements:
<title>, <firstname>, <lastname>, <price>, <year>Complex Type Elements — Elements that contain other elements or attributes:
<library> — contains <book> child elements<book> — contains child elements and has attribute id<author> — contains <firstname> and <lastname> child elements<!ELEMENT library (book+)>
<!ELEMENT book (title, author, price, year)>
<!ATTLIST book id CDATA #REQUIRED>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (firstname, lastname)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT year (#PCDATA)>
Explanation of DTD:
| DTD Declaration | Meaning |
|---|---|
<!ELEMENT library (book+)> |
library contains one or more book elements |
<!ELEMENT book (title, author, price, year)> |
book is a complex type with child elements |
<!ATTLIST book id CDATA #REQUIRED> |
book has a required attribute id |
<!ELEMENT title (#PCDATA)> |
title is a simple type containing text only |
<!ELEMENT author (firstname, lastname)> |
author is a complex type with child elements |
<!ELEMENT firstname (#PCDATA)> |
firstname is a simple type |
<!ELEMENT price (#PCDATA)> |
price is a simple type |
XML provides a flexible, platform-independent way to structure and exchange data. Simple type elements hold only text data (#PCDATA), while complex type elements contain other child elements or attributes. DTD defines the legal structure and rules for the XML document, ensuring data validity.
Short Answers Questions