Semester
Subject
Year
Tribhuwan University
2081
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 used to store and transport data in a structured, self-descriptive format that is both human-readable and machine-readable.
<name>...</name>) or be self-closing (e.g., <br/>).<Name> and <name> are different.<b><i>text</i></b> is correct).<?xml version="1.0"?>.<, >, & should be used directly in content — use entity references (<, >, &).<!-- comment --> and cannot appear inside tags.<?xml version="1.0" encoding="UTF-8"?>
<library>
<book id="101" category="fiction">
<title>The Alchemist</title>
<author>Paulo Coelho</author>
<price>350.00</price>
<publisher>
<name>HarperCollins</name>
<country>USA</country>
</publisher>
</book>
<book id="102" category="science">
<title>A Brief History of Time</title>
<author>Stephen Hawking</author>
<price>500.00</price>
<publisher>
<name>Bantam Books</name>
<country>UK</country>
</publisher>
</book>
</library>
Explanation:
library — Root elementbook — Element with attributes (id, category)title, author, price — Simple type elements (contain only text)publisher — Nested element containing child elements (name, country)<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="price" type="xs:decimal"/>
<xs:element name="publisher">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:integer" use="required"/>
<xs:attribute name="category" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Key Points of XSD:
xs:string, xs:decimal, xs:integer — Simple types for elementsxs:complexType — Used for elements that have child elements or attributesxs:sequence — Ensures child elements appear in a specific orderxs:attribute — Defines attributes with use="required" to make them mandatorymaxOccurs="unbounded" — Allows multiple book elementsXML provides a flexible way to structure data with strict well-formedness rules. XSD validates the structure, data types, and constraints of an XML document, ensuring data integrity and consistency.
Short Answers Questions