1 / 22

Tutorial 02

Tutorial 02. Document Type Definition. Contents. The Cyber Shop Problem Solution. The Cyber Shop Problem. The head office of Cyber Shop sends the information about its products to the branch offices. The products details must be store in a consistent format at all branches.

duncan-shaw
Télécharger la présentation

Tutorial 02

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tutorial 02 Document Type Definition

  2. Contents • The Cyber Shop Problem • Solution

  3. The Cyber Shop Problem • The head office of Cyber Shop sends the information about its products to the branch offices. • The products details must be store in a consistent format at all branches. • Restrictions must be placed on the kind of data that can be saved in the data store to ensure uniformity and consistency of information. • The products sold by Cyber Shop are organized into two categories, toys and books. • The product details comprise the name of the product, a brief description about it, the price of the product, and the quantity available in stock. • Every product is uniquely indentified by a product ID.

  4. Solution • Analysis and Design • Implementation • Viewing data on a browser

  5. 1. Analysis and Design 1.1 Identifying the elements required for storing structured data 1.2 Identifying the attributes

  6. 1.1 Identifying the elements required for storing structured data

  7. 1.2 Identifying the attributes • The unique identification number is an intangible and abstract property, which can be used to retrieve the details about a particular product. Therefore, PRODUCTID can be defined as an attribute of the PRODUCT element. • Category of product classifies a product as a book or toy. So CATEGORY can also be defined as an attribute of the PRODUCT element.

  8. 2. Implementation 2.1 Declaring Elements 2.2 Storing Elements

  9. 2.1 Declaring Elements 2.1.1 Creating a new DTD file 2.1.2 Declaring the root element 2.1.3 Declaring the parent element 2.1.4 Declaring the child elements 2.1.5 Declaring the attributes

  10. 2.1.1 Creating a new DTD file Open XML Spy > File > New > Choose DTD > OK

  11. 2.1.2 Declaring the root element The + symbol means that there can be multiple PRODUCT element.

  12. 2.1.3 Declaring the parent element The PRODUCT element will have 4 child elements: PRODUCTNAME, DESCRIPTION, PRICE, QUANTITY.

  13. 2.1.4 Declaring the child elements The data type of each element is #PCDATA, it means Parsable Character Data and is used to represent character content.

  14. 2.1.5 Declaring the attributes The attribute type # REQUIRED is used when the value for that attribute must be specified each time the element is used. Save the file as products.dtd.

  15. 2.2 Storing Elements 2.2.1 Creating a new XML file 2.2.2 Inserting the DTD file into the XML file 2.2.3 Inserting data

  16. 2.2.1 Creating a new XML file Create a new XML file and save it as products.xml in the same folder with the DTD file.

  17. 2.2.2 Inserting the DTD file into the XML file

  18. 2.2.3 Inserting data Insert three products as below:

  19. 3. Viewing data on a browser Open the XML file on a web browser to check again.

  20. Exercise The branches of Cyber Shop send information about books sold by them to the head office. The book details must be stored in a consistent format. Restriction must be placed on the kind of data that can be saved in the data store to ensure uniformity and consistency of information. The details of books consist of the name of the book, ISBN, first and last name of the author of the book, the price, and the category of the book. The ISBN should be unique for each book. In addition, you need to ensure that the book category contains HISTORY, SCIENCE, or FICTION as its valid. Create a DTD for declaring the elements to be used for storing book details in an XML document. The XML file must have at least 3 stored books.

  21. References • New Perspectives on Creating Web Pages with HTML and XML (Patrick Carey & Mary Kemper) - Course Technology Publisher • Creating Cool Web Sites with HTML, XHTML and CSS - Taylor, Dave, Wiley

More Related