Professional Documents
Culture Documents
Documents
Objectives
In this lesson, you will learn to:
☛ Declare elements and attributes in a Document Type
Definition (DTD)
☛ Create an XML Schema
Task List
☛ Identify the elements required for storing structured
data.
☛ Identify the attributes.
☛ Identify the method for storing consistent data.
☛ Identify the method for declaring elements to be used
for storing structured data.
☛ Identify the method for declaring attributes.
☛ Identify the method to validate the structure of data.
PRODUCT Represents the details (product name, description, price, and quantity) for each
product.
PRODUCTNAME Represents the name of each product.
PRODUCT Element content Contains details of other products, and hence will contain other
elements like PRODUCTNAME, DESCRIPTION, PRICE, and
QUANTITY.
PRODUCTNAME Data content Contains regular text that represents the name of a product.
DESCRIPTION Data content Contains regular text that represents the description of a product.
PRICE Data content Contains regular text that represents the price of a product.
QUANTITY Data content Contains regular text that represents the quantity of a product.
Just a Minute…
The branches of CyberShoppe send information about
books sold by them to the head office. The book details
must be stored in a consistent format. Restrictions must
be placed on kind of data that can be saved in the data
store to ensure uniformity and consistency of
information. The details of the books sold by
CyberShoppe consist of the name of the book, ISBN of
the book, first and last names of the author of the book,
and the price 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 values. Create a DTD for declaring
the elements to be used for storing book details in an
XML document.
Task List
☛ Identify the elements required to store data.
☛ Identify the data type of the contents of an element.
☛ Identify the method for declaring a simple type
element.
☛ Identify the method for declaring a complex type
element.
☛ Create the XML schema.
☛ Create an XML document conforming to the schema.
☛ Validate an XML document against the schema.
PRODUCT Represents the details (product name, description, price, and quantity)
for each product.
PRODUCT Complex data type A complex type element that can hold other elements, attributes,
and mixed content. This element will hold a complex data type,
which will be defined in the later session.
PRODUCTNAME String A simple type element that contains values of data string type.
DESCRIPTION String A simple type element that contains values of string data type.
QUANTITY Integer A simple type element that contains values of integer data type.
Summary
In this lesson, you learned that:
☛ Document type Definition (DTD) is method for defining
the structure of the data in an XML document.
☛ There are two types of DTD:
✓ Internal DTD: It can be included as a part of the
document.
✓ External DTD: it is stored as a separate file having
the declaration of all elements and attributes that
can be used in an XML document.
☛ There are three types of elements: empty,
unrestricted, and container.
Summary (Contd.)
☛ The <!ELEMENT> statement is used to declare an
element in a DTD.
☛ The <!ATTLIST> statement is used to declare a list of
attributes for an element in a DTD.
☛ The <!DOCTYPE statement is used in an XML
document to associate the XML document with a
DTD.
☛ Non-validating XML parsers check whether an XML
document is well-formed.
☛ Validating XML parsers are used to validate an XML
document against a DTD or a schema.
Summary (Contd.)
☛ Schema can be used to specify the list of elements
and the order in which these elements must appear in
the XML document.
☛ The language that is used to describe the structure of
the elements in a schema is called the XML Schema
Definition (XSD) language .
☛ The data types supported by schema are of the
following types:
✓ Primitive
✓ Derived
✓ Atomic
✓ List
Summary (Contd.)
☛ The simpleType element of XSD allows you to create
user-defined simple data types.
☛ The complexType element of XSD allows you to
create complex data types.
☛ The restriction element can be used to specify
constraints on values that can be stored in elements
and attributes.