Presentation is loading. Please wait.

Presentation is loading. Please wait.

Document Type Definition

Similar presentations


Presentation on theme: "Document Type Definition"— Presentation transcript:

1 Document Type Definition
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
Description PRODUCTDATA Indicates that data specific to various products is being stored in the document. Acts as the root element for all other elements. PRODUCT Represents the details (product name, description, price, and quantity) for each product. PRODUCTNAME Represents the name of each product. DESCRIPTION Represents the description of each product. PRICE Represents the price of each product. QUANTITY Represents the quantity of each product.

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. Attribute Description PRODUCTID Represents a unique identification value for each product. It must be specified for every product. CATEGORY Represents the category of a product and specifies whether a product is a TOY or BOOK.

8 2. Implementation 2.1 Declaring Elements 2.2 Storing Elements

9 2.1 Declaring Elements 2.1.1 Creating a new DTD file Declaring the root element Declaring the parent element Declaring the child elements 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 Inserting the DTD file into the XML file 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

22


Download ppt "Document Type Definition"

Similar presentations


Ads by Google