Group Member: Eu Lay Tien (AI140156)
Ng Su Mei (AI140151)
Question 1
Haneena and Co. has a telephone directory that records the first and last name, telephone number and email address of everyone working in the company. Departments are the main organizing unit of the company so the telephone directory is typically displayed in department order and shows for each department the contact phone and fax number and email address.
Create an XML file containing some directory data.
Answer:
<company>
<departmentname></departmentname>
<telephone>
<firstname></firstname>
<lastname></lastname>
<telephonenumber></telephonenumber>
<email></email>
<faxnumber></faxnumber>
</telephone>
</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.
b. Give the tree diagram of the document given in 2a.
c. Modify the document given in exercise 2a such that the “first” and “last” are the attributes of the name element.
Answer:
(a)
<profile>
<fname>Adi</fname>
<lname>Maulud</lname>
<profession>
<first>doctor</first>
<second>therapist</second>
<third>surgeon</third>
</profession>
</profile>
(b)
(c)
<profile>
<name first="Adi" last="Maulud"></name>
<profession>
<first>doctor</first>
<second>therapist</second>
<third>surgeon</third>
</profession>
</profile>
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.
b. Give the tree diagram of the document given in exercise 3a.
c. Give a DTD (Document Type Definition) for the XML-document specified in 3a.
d. Give an XML Schema for the information specified in exercise 3a.
Answer:
(a)
<profile>
<ssn>123456789A</ssn>
<name>
<fname>Adha</fname>
<lname>Hadif</lname>
</name>
<contact>
<address>
<postcode>86400</postcode>
<city>Batu Pahat</city>
<street>Jalan Puding</street>
</address>
<tel>
<first>12345</first>
<second>67890</second>
</tel>
</contact>
</profile>
(b)
(c)
<!ELEMENT profile (securityno, fname, lname, address+, tel+)>
<!ELEMENT securityno (#PCDATA)>
<!ELEMENT fname (#PCDATA)>
<!ELEMENT lname (#PCDATA)>
<!ELEMENT address (postcode, city, street)>
<!ELEMENT postcode (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT tel (first, second )>
<!ELEMENT first (#PCDATA)>
<!ELEMENT second (#PCDATA)>
(d)
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="profile">
<xs:complexType>
<xs:sequence>
<xs:element name="ssn" type="xs:string"></xs:element>
<xs:element name="fname" type="xs:string"></xs:element>
<xs:element name="lname" type="xs:string"></xs:element>
<xs:element name="contact">
<xs:complexType>
<xs:sequence>
<xs:element name="address">
<xs:complexType>
<xs:sequence>
<xs:element name="postcode" type="xs:int"></xs:element>
<xs:element name="city" type="xs:string"></xs:element>
<xs:element name="street" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="tel">
<xs:complexType>
<xs:sequence>
<xs:element name="first" type="xs:int"></xs:element>
<xs:element name="second" type="xs:int"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>