assignment 1-eece 652

Upload: mounir-boustany

Post on 03-Jun-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Assignment 1-EECE 652

    1/15

    Mounir Boustany

    13

    EECE 652 AssignmentXML Assignment

    Mounir Boustany

  • 8/12/2019 Assignment 1-EECE 652

    2/15

    Mounir Boustany | EECE 652Assignment 1

    2

    Table of ContentsTable of Figures ............................................................................................................................... 2

    Question 1 ....................................................................................................................................... 3

    Question 2 ....................................................................................................................................... 4

    Question 3 ....................................................................................................................................... 5

    Question 4 ....................................................................................................................................... 7

    Question 5 ....................................................................................................................................... 9

    Question 6 ..................................................................................................................................... 10

    Question 7 ..................................................................................................................................... 11

    Question 8 ..................................................................................................................................... 14

    Table of FiguresFigure 1: XML Store Code ................................................................................................................ 3

    Figure 2: XML Store Validation ........................................................................................................ 4

    Figure 3XML Store Code with DTD .................................................................................................. 5

    Figure 4: Validation Error of DTD Code ........................................................................................... 6

    Figure 5: Correct Validation of DTD Code ....................................................................................... 6

    Figure 6: Schema Store Code .......................................................................................................... 7

    Figure 7: Validation Error for Schema Code .................................................................................... 8

    Figure 8: Correct Validation of Schema Code .................................................................................. 8

    Figure 9: XML Plant Code ................................................................................................................ 9

    Figure 10: XML Query Outputs ...................................................................................................... 10

    Figure 11: XSLT Code ..................................................................................................................... 11

    Figure 12: HTML Code ................................................................................................................... 12

    Figure 13: Mozilla Firefox Print Screen .......................................................................................... 13

    Figure 14: XSLT Code for Sunny Plants .......................................................................................... 14

    Figure 15: HTML Code for Sunny Plants ........................................................................................ 15

    Figure 16: Mozilla Firefox Screenshot for Sunny Plants ................................................................ 15

    http://win2k.aub.edu.lb/files/homem/meb07/my%20documents/Doc11121844%20(1).docx%23_Toc368127397http://win2k.aub.edu.lb/files/homem/meb07/my%20documents/Doc11121844%20(1).docx%23_Toc368127399http://win2k.aub.edu.lb/files/homem/meb07/my%20documents/Doc11121844%20(1).docx%23_Toc368127402http://win2k.aub.edu.lb/files/homem/meb07/my%20documents/Doc11121844%20(1).docx%23_Toc368127402http://win2k.aub.edu.lb/files/homem/meb07/my%20documents/Doc11121844%20(1).docx%23_Toc368127399http://win2k.aub.edu.lb/files/homem/meb07/my%20documents/Doc11121844%20(1).docx%23_Toc368127397
  • 8/12/2019 Assignment 1-EECE 652

    3/15

    Mounir Boustany | EECE 652Assignment 1

    3

    Question 1

    I decided to write an XML document describing a retail store with multiple sections and

    subsections ending with a description of the actual products. The root node is the store

    under it I presented 2 sections each with an attribute describing the content; the first

    was electronics and under falls multiple TVs and laptops with their specifications (brand,size, price, quantity, color). The other section is the food section and under it we have

    dairy food which is composed of labneh and cheese with a description for each (price,

    brand, characteristics, expiry) and a soft drink label. The code (75 lines) is as follows:

    Figure 1: XML Store Code

  • 8/12/2019 Assignment 1-EECE 652

    4/15

    Mounir Boustany | EECE 652Assignment 1

    4

    Question 2

    To check if my code was well formed I used the online based validator

    www.xmlvalidation.com . The code is well formed and this shown by the screenshot

    below clearly stating No errors were found.

    Figure 2: XML Store Validation

    http://www.xmlvalidation.com/http://www.xmlvalidation.com/http://www.xmlvalidation.com/
  • 8/12/2019 Assignment 1-EECE 652

    5/15

    Mounir Boustany | EECE 652Assignment 1

    5

    Question 3

    I updated my code starting it with a DTD then again used the validator twice, once while

    commenting the attribute declaration line to get an error and the other the correct code

    to make sure everything is right. The results follow:

    Figure 3XML Store Code with DTD

  • 8/12/2019 Assignment 1-EECE 652

    6/15

    Mounir Boustany | EECE 652Assignment 1

    6

    Figure 4: Validation Error of DTD Code

    Figure 5: Correct Validation of DTD Code

  • 8/12/2019 Assignment 1-EECE 652

    7/15

    Mounir Boustany | EECE 652Assignment 1

    7

    Question 4

    The same was repeated for the Schema. The outcomes were:

    Figure 6: Schema Store Code

  • 8/12/2019 Assignment 1-EECE 652

    8/15

    Mounir Boustany | EECE 652Assignment 1

    8

    Figure 7: Validation Error for Schema Code

    Figure 8: Correct Validation of Schema Code

  • 8/12/2019 Assignment 1-EECE 652

    9/15

    Mounir Boustany | EECE 652Assignment 1

    9

    Question 5

    The code I chose I got from www.w3schools.comwhich describes a catalog of plants.

    Each plant has a common, a botanical, a zone, a light, a price and an availability

    element. The code is 292 lines but due to the limited space I am only showing the first

    60 lines. The root node here is the catalog followed by several plants each with itscharacteristics. A screenshot of the first 60 lines follow:

    Figure 9: XML Plant Code

    http://www.w3schools.com/http://www.w3schools.com/http://www.w3schools.com/
  • 8/12/2019 Assignment 1-EECE 652

    10/15

    Mounir Boustany | EECE 652Assignment 1

    10

    Question 6

    After a quick search on the web I found many articles that recommended XML Notepad

    as the best querying tool. I downloaded it and opened my code on it. The following was

    displayed (due to the limited size of the screen only 6 outputs are shown):

    Figure 10: XML Query Outputs

  • 8/12/2019 Assignment 1-EECE 652

    11/15

    Mounir Boustany | EECE 652Assignment 1

    11

    Question 7

    The following XSLT code takes the plant catalog and outputs it into a simple table. This

    will transform it into an HTML code which part of it is displayed below (since it is really

    large) and the output Mozilla Firefox also follows:

    Figure 11: XSLT Code

  • 8/12/2019 Assignment 1-EECE 652

    12/15

    Mounir Boustany | EECE 652Assignment 1

    12

    Figure 12: HTML Code

  • 8/12/2019 Assignment 1-EECE 652

    13/15

    Mounir Boustany | EECE 652Assignment 1

    13Figure 13: Mozilla Firefox Print Screen

  • 8/12/2019 Assignment 1-EECE 652

    14/15

    Mounir Boustany | EECE 652Assignment 1

    14

    Question 8

    Finally I updated the previous XSLT to output the plants which only grow in a sunny

    weather by using the xsl:if and testing when the LIGHT component is equal to the string

    Sunny. This has many applications, say a customer lives in a sunny area and we want to

    only show him what can grow in his land. The XSLT code, the HTML code and the outputin Mozilla Firefox are showed below:

    Figure 14: XSLT Code for Sunny Plants

  • 8/12/2019 Assignment 1-EECE 652

    15/15

    Mounir Boustany | EECE 652Assignment 1

    15

    Figure 15: HTML Code for Sunny Plants

    Figure 16: Mozilla Firefox Screenshot for Sunny Plants