Tribhuwan University

Institute of Science and Technology

2079

Bachelor Level / Third Year / Fifth Semester / Science

B.Sc in Computer Science and Information Technology (CSC329)

(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.

Section A

Long Answers Questions

Attempt any TWO questions.
[2*10=20]
1.
What is the use of XML? Create a XML file with simple type and complex type elements. Write its equivalent DTD.[10]

Use of XML with Simple Type, Complex Type Elements and DTD

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.


Uses of XML

  • Data Storage — Stores data in a structured, self-describing format
  • Data Transport — Used to exchange data between incompatible systems (e.g., between different applications or platforms)
  • Configuration Files — Many applications use XML for settings and configuration
  • Web Services — SOAP-based web services use XML for request/response messages
  • Separation of Data from Presentation — XML stores data; HTML/CSS handles display
  • Platform Independent — Can be used across different operating systems and programming languages
  • Document Representation — Used in formats like DOCX, SVG, RSS feeds

XML File with Simple Type and Complex Type Elements

<?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

Equivalent DTD (Document Type Definition)

<!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

Conclusion

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.

2.
Create an HTML file containing form elements textbox for username, password field and a checkbox for hobbies. Now write javascript function for the form validation. You should validate for username to be empty, password should be of length at least 5, and the check box should be checked.[10]
3.
How database connection is created in PHP? Write a PHP program to create a form and insert values in to the database table. The form should contain at least two input fields.[10]
Section B

Short Answers Questions

Attempt any Eight questions.
[8*5=40]
4.
Write a HTML script to generate following list of items; 1. Coffee : I. Black coffee II. Green coffee 2. Tea A: Black tea B. Green tea [5]
5.
Create a HTML page containing a div having id 'div1'. The div should contain canvas element. The id of canvas should be 'mycanvas'. The height and width of canvas should be 200 and 300. [5]
6.
What are the usages of class and id selectors in CSS? Illustrate with example. [5]
7.
What is word-wrap property in CSS? Write an HTML script to illustrate the word-wrap property. [5]
8.
Describe the jQuery Animate() method. Write an html script to create a div with id 'mydiv'. The position of the div should be set to absolute. Now show the use of animate method to the div element to right by 300px. [5]
9.
What is XML Namespace? How is it used to avoid element name conflict in XML? Justify with an example. [5]
10.
How can you define class and objects in PHP? Write a PHP script to create class and its object. [5]
11.
How can you define array in PHP? Write a PHP function to create an array of type integer and print its elements. [5]
12.
Differentiate Web 1.0 from Web 2.0. [5]