Wednesday, March 9, 2016

Semantic Web - Lab 1

Assalamualaikum Dr. Hanayanti

Kami : NOOR IZZATI BT MOHAMAD ADNAN
       HAFIZAH SYAFIQAH BT HARUM
       MUHAMAD RAIMI B MOHD RAFLI

Kami menggunakan http://www.freeformatter.com/ untuk mengesahkan jawapan kami sama ada betul atau salah. Kami telah menyediakan screenshot semakan jawapan daripada website tersebut.  


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.

Answer :

<?xml version="1.0" encoding="UTF-8"?>
<company>
<companyname>Haneena and Co.</companyname>
<department category="Designer">
<employee>
<firstname>Raimi</firstname>
<lastname>Rafli</lastname>
<phone>017-9340650</phone>
<email>raimirafli4@gmail.com</email>
</employee>
<employee>
<firstname>Hafizah</firstname>
<lastname>Harum</lastname>
<phone>017-9341234</phone>
<email>hafizahharum@gmail.com</email>
</employee>
<contactNo>07-3123664</contactNo>
<email>designerdepartment@gmail.com</email>
<faxNo>07-9831234</faxNo>
</department>
<department category="Programmer">
<employee>
<firstname>Izzati</firstname>
<lastname>Adnan</lastname>
<phone>017-7836002</phone>
<email>izzatiadnan@gmail.com</email>
</employee>
<contactNo>07-3123664</contactNo>
<email>programmerdepartment@gmail.com</email>
<faxNo>07-8363076</faxNo>
</department>

</company>


Validation Answer :





Question 2

a. Give an XML-document (by not using attributes), which includes the information that the first name of a person is Adi, his last name is Maulud, and his professions are doctor, therapist and surgeon.

Answer :

       <person>
          <firstname> Adi </firstname>
          <lastname> Maulud </lastname>
          <profession>doctor</profession>
          <profession>theraphist </profession>
          <profession> surgeon </profession>
       </person>

Validation Answer :





b.  Give the tree diagram of the document given in 2a.

Answer :


    


c.  Modify the document given in exercise 1 such that the “first” and “last” are the attributes of the name element

Answer :

       <person>
                 <firstname category="Adi"></firstname>
                 <lastname category="Maulud"></lastname>
                 <profession>doctor</profession>
                 <profession>theraphist </profession>
                 <profession> surgeon </profession>
             </person>

Validation Answer :




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 :

        <securityInformation>
            <securitynum>123456789A</securitynum>
            <fname>Adha</fname>
            <lname>Hadif</lname>
            <address>
                <poscode>86400</poscode>
                <city>Batu Pahat</city>
                <street>Jalan Puding</street>
            </address>
            <phonenum>
                <firstnum>12345</firstnum>
                <secondnum>67890</secondnum>
            </phonenum>
        </securityInformation>

Validation Answer :



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 securityInformation 
[
<!ELEMENT securityInformation (securitynum,fname,lname,address,phonenum)> 
<!ELEMENT securitynum (#PCDATA)>
<!ELEMENT fname (#PCDATA)>
<!ELEMENT lname (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT phonenum (#PCDATA)>
]>

<securityInformation>
    <securitynum>123456789A</securitynum>
    <fname>Adha</fname>
    <lname>Hadif</lname>
    <address>
        <poscode>86400</poscode>
        <city>Batu Pahat</city>
        <street>Jalan Puding</street>
    </address>
    <phonenum>
        <firstnum>12345</firstnum>
        <secondnum>67890</secondnum>
    </phonenum>
</securityInformation>


Validation Answer :


d.  Give an XML Schema for the information specified  in exercise 3a.

Answer :

         <securityInformation>
             <securitynum>123456789A</securitynum>
             <fname>Adha</fname>
             <lname>Hadif</lname>
             <address>
                <poscode>86400</poscode>
                <city>Batu Pahat</city>
                <street>Jalan Puding</street>
             </address>
             <phonenum>
                <firstnum>12345</firstnum>
                <secondnum>67890</secondnum>
             </phonenum>
         </securityInformation>


Validation Answer :

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="securityInformation">
    <xs:complexType>
      <xs:sequence>
        <xs:element type="xs:string" name="securitynum"/>
        <xs:element type="xs:string" name="fname"/>
        <xs:element type="xs:string" name="lname"/>
        <xs:element name="address">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:int" name="poscode"/>
              <xs:element type="xs:string" name="city"/>
              <xs:element type="xs:string" name="street"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="phonenum">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:short" name="firstnum"/>
              <xs:element type="xs:int" name="secondnum"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>












































No comments: