Friday, 24 February 2017

LABSHEET 1

QUESTION 1

Adharizq Enterprise has a phone directory that records the first and last name, phone number and email address of every staff in the company. Departments are the main organizing unit of the company so the phone directory is typically displayed in department order and shows for each department the phone no, fax number and email address. Create an XML file containing some directory data.

ANSWER :

<company>
  <companyname>Adharizq Enterprise</companyname>
    <itdepartment>
      <staff>
        <firstname>wan nur zahirah</firstname>
        <lastname>wan zakaria</lastname>
        <phoneno>012983456</phoneno>
        <phonedepno>099871234</phonedepno>
        <faxno>099871236</faxno>
        <email>wzahirah@gmail.com</email>
   
        <firstname>siti fatimah nurah</firstname>
        <lastname>ithnin</lastname>
        <phoneno>019983789</phoneno>
        <phonedepno>099871712</phonedepno>
        <faxno>099871256</faxno>
        <email>nurah00ithnin@gmail.com</email>
      </staff>
    </itdepartment>
  </company>

QUESTION 2

A) Give an XML-document (by not using attributes), which includes the information that the first name of a person is Zahra, her last name is Adib, and her professions are doctor, therapist and surgeon

ANSWER A :

<person>
    <fistname>Zahra</fistname>
    <lastname>Adib</lastname>
    <profession>doctor</profession>
    <profession>therapist</profession>
    <profession>surgeon</profession>
</person>

B) Give the tree diagram of the document given in 2A

ANSWER B :



C) Modify the document given in exercise 2A such that the “first” and “last” are the attributes of the name element.

ANSWER C :



QUESTION 3

A) Give an XML-document (by not using attributes), which includes the following information: the social security number (123456789A), the first name of a person is Adha, and his last name is Hadif, his address is composed of postcode (86400), city (Batu Pahat) and street (Jalan Puding), and his telephone numbers are 12345 and 67890.

ANSWER :

<information>
  <securityno>123456789A</securityno>
  <name>
     <firstname>Adha</firstname>
     <lastname>Hadif</lastname>
  <address>
     <postcode>86400</postcode>
     <city>Batu Pahat</city>
     <street>Jalan Puding</street>
  </address>
  <contactinfo>
     <firstno>12345</firstno>
     <secondno>67890</secondno>
  </contactinfo>
</information>

B) Give the tree diagram of the document given in exercise 3a.

ANSWER :



C) Give a DTD (Document Type Definition) for the XML-document specified in 3a.

ANSWER : 

<?xml version=1.0>
<DOCTYPE information [
  <!ELEMENT information (securityno, name, address, contactinfo)>
  <!ELEMENT securityno (#PDATA)>
  <!ELEMENT name (firstname, lastname)>
  <!ELEMENT firstname (#PDATA)>
  <!ELEMENT lastname (#PDATA)>
  <!ELEMENT address (postcode, city, street)>
  <!ELEMENT postcode (#PDATA)>
  <!ELEMENT city (#PDATA)>
  <!ELEMENT street (#PDATA)>
  <!ELEMENT contactinfo (firstno, secondno)>
  <!ELEMENT firstno (#PDATA)>
  <!ELEMENT secondno (#PDATA)>
]>


D) Give an XML Schema for the information specified in exercise 3a

ANSWER : 

<xs:schema xlms:xs="">
<xs:element name ="information">
<xs:complexType>
<xs:sequence>
<xs:element name ="securityno" type="xs:string"/>
</xs:sequence></xs:complexType></xs:element>
<xs:element name ="name">
<xs:complexType>
<xs:sequence>
<xs:element name ="firstname" type=" "/>
<xs:element name ="lastname" type=" "/>
</xs:sequence></xs:complexType></xs:element>
<xs:element name ="address">
<xs:complexType>
<xs:sequence>
<xs:element name ="postcode" type="xs:string"/>
<xs:element name ="city" type=" "/>
<xs:element name ="street" type=" "/>
</xs:sequence></xs:complexType></xs:element>
<xs:element name ="contactinfo">
<xs:complexType>
<xs:sequence>
<xs:element name ="firstno" type="xs:integer"/>
<xs:element name ="secondno" type="xs:integer"/>
</xs:sequence></xs:complexType></xs:element>
<xs:schema>



No comments:

Post a Comment