1. Extensible Markup Language
Objectives
In this session, you will learn to:
Create an XML schema
Declare attributes in an XML schema
Identify the need for XML namespaces
Ver. 1.0 Session 2 Slide 1 of 36
2. Extensible Markup Language
Introducing XML Schema
An XML schema defines the list of elements and attributes
that can be used in an XML document.
An XML schema specifies the order in which the elements
appear in the XML document, and their data types.
Microsoft has developed the XML Schema Definition (XSD)
language to define the schema of an XML document.
Ver. 1.0 Session 2 Slide 2 of 36
3. Extensible Markup Language
Advantages of XML Schema Created Using XSDs
Some of the advantages of creating an XML schema by
using XSD are:
XSD provides control over the type of data that can be
assigned to elements and attributes.
XSD enables you to create your own data types.
XSD enables you to specify restrictions on data.
The syntax for defining an XSD is the same as the syntax used
for XML documents.
XML schema content models can be used to validate mixed
content.
XML schema is extensible.
XML schema is self documenting.
Ver. 1.0 Session 2 Slide 3 of 36
4. Extensible Markup Language
Support for XML Schemas in Various Parsers
Parsers that provide support for XML schemas are:
– IBM XML4J: Validates XML documents against several types
of XML schemas.
– MSXML 6.0: Enables loading of XML data from anonymous or
untrusted sources in a secured manner.
Ver. 1.0 Session 2 Slide 4 of 36
5. Extensible Markup Language
Data Types in XML Schemas
In an XML schema created using XSD, every element must
be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived
Atomic
List
Union
Ver. 1.0 Session 2 Slide 5 of 36
6. Extensible Markup Language
Data Types in XML Schemas (Contd.)
In an XML schema created using XSD, every element must
be associated with a data type.
XSD provides the following list of predefined data types:
Do not contain elements or attributes.
Primitive
Contain only values.
Derived
Atomic
List
Union
Ver. 1.0 Session 2 Slide 6 of 36
7. Extensible Markup Language
Data Types in XML Schemas (Contd.)
In an XML schema created using XSD, every element must
be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived Are defined by using other data types
called base types.
Atomic
Can be built-in or user-defined.
List
Union
Ver. 1.0 Session 2 Slide 7 of 36
8. Extensible Markup Language
Data Types in XML Schemas (Contd.)
In an XML schema created using XSD, every element must
be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived
Atomic Cannot be broken down into smaller
units.
List
Can be primitive or derived.
Union
Ver. 1.0 Session 2 Slide 8 of 36
9. Extensible Markup Language
Data Types in XML Schemas (Contd.)
In an XML schema created using XSD, every element must
be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived
Atomic
List Are derived data types that contain a set
of values of atomic data types.
Union
Elements referring to a list data type can
contain a value only from that defined
set.
Ver. 1.0 Session 2 Slide 9 of 36
10. Extensible Markup Language
Data Types in XML Schemas (Contd.)
In an XML schema created using XSD, every element must
be associated with a data type.
XSD provides the following list of predefined data types:
Primitive
Derived
Atomic
List
Union Are derived from the atomic and list data
types.
Ver. 1.0 Session 2 Slide 10 of 36
11. Extensible Markup Language
Elements in XML Schemas
There are two types of elements, simple and complex that
can be defined in a schema.
Simple Element
A simple element does not contain any child elements or
attributes.
It contains only values, such as numbers, strings, and dates.
You can specify restrictions on elements by defining a new
simple data type from an existing data type using facet values.
You can also associate an element with a simple data type.
Let us look at the syntax for declaring a simple element.
Ver. 1.0 Session 2 Slide 11 of 36
12. Extensible Markup Language
Elements in XML Schemas (Contd.)
<xsd:element name= The name attribute specifies the name of
the element declared.
“element-name"
type="data type" The type attribute specifies the data
min0ccurs="nonNegativeInteger" type of the element declared.
max0ccurs="nonNegativeInteger| minOccurs specifies the minimum
unbounded"/> number of times the element can occur.
maxOccurs specifies the maximum
number of times the element can
appear.
Ver. 1.0 Session 2 Slide 12 of 36
13. Extensible Markup Language
Elements in XML Schemas (Contd.)
Complex Element
A complex element contains other elements, attributes, and
mixed content.
To declare a complex element, you need to first define a
complex data type.
After defining the complex data type, you can declare a
complex element by associating this data type with the
element.
Let us look at the syntax for declaring a complex element.
Ver. 1.0 Session 2 Slide 13 of 36
14. Extensible Markup Language
Elements in XML Schemas (Contd.)
<xsd:complexType name="data The complexType element is used to
type name"> declare a new complex data type.
Content model declaration The name attribute specifies the name of
</xsd:complexType> the new complex data type.
The Content model declaration
contains the declaration for the elements
and attributes that make up the content
of the complex type.
Ver. 1.0 Session 2 Slide 14 of 36
15. Extensible Markup Language
Demo: Creating an XML Schema
Problem Statement:
CyberShoppe, a toy and book store in the United States, sends
its product information from the head office to the branch
offices. The product details must be stored in a consistent
format. Restrictions must be placed on the type of data that
can be saved in the data store, in order to ensure uniformity
and consistency of information.
The product details include the product name, a brief
description, product price, and the available quantity on hand.
The price of the product must always be greater than zero.
Ver. 1.0 Session 2 Slide 15 of 36
16. Extensible Markup Language
Declaring Attributes in a Schema
Attributes in an XML schema are declared in the same way
as elements.
Declaring attributes in an XML schema facilitates the
assimilation of information for an XML document.
Attribute declarations can be defined in two ways:
– Simple type definitions: Facilitates local validation of the
attribute information.
– Global attribute declarations: Enables reuse of attributes.
Ver. 1.0 Session 2 Slide 16 of 36
17. Extensible Markup Language
Attribute Element
• In XSD, an attribute for a user-defined element is declared
using the attribute element.
• The syntax for declaring an attribute in XSD is:
<attribute name="attributename"
ref="attributename"
type="datatypename" use="value" value="value">
</attribute>
• The attribute element contains attributes that are used
to further qualify and restrict the scope and usage of the
user-defined attribute.
Ver. 1.0 Session 2 Slide 17 of 36
18. Extensible Markup Language
Attribute Element (Contd.)
• The attribute element consists of the following
attributes:
name
ref
type
use
Ver. 1.0 Session 2 Slide 18 of 36
19. Extensible Markup Language
Attribute Element (Contd.)
• The attribute element consists of the following
Is used to specify the name of a
attributes: user-defined attribute.
a name Must be used when the schema element
a ref is the parent element of the attribute
element.
a type
Colon (:) should not be included in the
a use value of the name attribute.
Ver. 1.0 Session 2 Slide 19 of 36
20. Extensible Markup Language
Attribute Element (Contd.)
• The attribute element consists of the following
attributes:
Is used to refer to a user-defined
a name attribute declared either in the same or in
a ref any other XSD document.
a type
a use
Ver. 1.0 Session 2 Slide 20 of 36
21. Extensible Markup Language
Attribute Element (Contd.)
• The attribute element consists of the following
attributes:
a name
a ref Takes a value that specifies the data
type of the user-defined attribute.
a type
a use
Ver. 1.0 Session 2 Slide 21 of 36
22. Extensible Markup Language
Attribute Element (Contd.)
• The attribute element consists of the following
attributes:
a name
a ref
a type Specifies the way in which an attribute
can be used in an XML document.
a use
Values that can be assigned to the use
attribute are optional, default,
required, and fixed.
Ver. 1.0 Session 2 Slide 22 of 36
23. Extensible Markup Language
Global Attributes
Global attributes are declared outside all element
declarations.
Global attributes facilitate attribute reusability.
Global attributes can be associated with simple and
complex data types.
Global attributes have the schema element as the parent
element.
Ver. 1.0 Session 2 Slide 23 of 36
24. Extensible Markup Language
Restricting Attributes Values
In order to restrict values that can be assigned to an
attribute:
a Declare the attribute and associate it with a user-defined
simple data type.
a Create a simple data type by using the XSD simpleType
element.
a Use the XSD restriction element within the simpleType
element to restrict the values that can be assigned to the
elements or attributes that use the simple data type.
Ver. 1.0 Session 2 Slide 24 of 36
25. Extensible Markup Language
Demo: Declaring Attributes in an XML Schema
Problem Statement:
The Marketing Manager at CyberShoppe sends its product
information from its head office to the branch offices. The
branch offices update this file and send it back to the head
office on a routine basis. The product details must be stored in
a consistent format at all branches. Restrictions must be
placed on the type of data that can be saved in the data store,
to ensure uniformity and consistency of information.
CyberShoppe sells two categories of products, books and toys.
Product details include the product name, a brief description,
product price, and the available quantity on hand. The product
price must always be greater than zero. In addition to these
details, the data store needs to store the category and product
ID.
Ver. 1.0 Session 2 Slide 25 of 36
26. Extensible Markup Language
Introducing XML Namespaces
In XML, a namespace is a virtual space that is assigned or
recognized by a Uniform Resource Identifier (URI).
A namespace is a string that uniquely identifies the
elements and attributes from different schemas.
A namespace is a unique identifier used to resolve conflicts
between elements that have the same names.
The following guidelines ensure the uniqueness of a URI:
Using a URI that is controlled by the developer.
Using a relative URI.
Ver. 1.0 Session 2 Slide 26 of 36
27. Extensible Markup Language
Declaring Namespaces
• A namespace can be declared in an XSD document by
using the xmlns keyword.
• The general form of the xmlns keyword is:
xmlns is the name of the attribute.
xmlns:prefix="URI"
prefix is an optional namespace.
• There are two types of namespace declarations:
Default Declaration: Declares a default namespace for a
document without specifying the prefix for a default
namespace.
Explicit Declaration: Enables xmlns keyword to associate a
prefix with a namespace.
Ver. 1.0 Session 2 Slide 27 of 36
28. Extensible Markup Language
Practice Questions
Harry is creating an XML schema using XSD. To associate
each element, he is using a data type that specifies the type
of content that an element can hold. Harry wants to use
such data types that are defined using base data types.
Base data types can either be primitive or derived data
types. Which of the following data types should Harry use to
accomplish this task?
a. Primitive
b. Union
c. List
d. Derived
Answer:
d. Derived
Ver. 1.0 Session 2 Slide 28 of 36
29. Extensible Markup Language
Practice Questions
Which one of the following code snippets can be considered
well-formed?
a. <EMPLOYEE empid=e001>
<EMPNAME> Alice Peterson</EMPNAME>
<BASICPAY> $2000 </BASICPAY>
</EMPLOYEE>
b. <EMPLOYEE empid=“e001”>
<EMPNAME> Alice Peterson<BASICPAY> $2000
</EMPNAME>
</BASICPAY>
</EMPLOYEE>
c. <EMPLOYEE empid=“e001”>
<EMPNAME> Alice Peterson<BASICPAY> $2000
</BASICPAY></EMPNAME>
</EMPLOYEE>
Ver. 1.0 Session 2 Slide 29 of 36
30. Extensible Markup Language
Practice Questions (Contd.)
d. <EMPLOYEE empid=“e001”>
<EMPNAME> Alice Peterson<BASICPAY> $2000
</BASICPAY></EMPNAME>
</employee>
Answer:
c. <EMPLOYEE empid=“e001”>
<EMPNAME> Alice Peterson<BASICPAY> $2000
</BASICPAY></EMPNAME>
</EMPLOYEE>
Ver. 1.0 Session 2 Slide 30 of 36
31. Extensible Markup Language
Practice Questions
You have been assigned the task of developing an XML
schema file for a new Web application in an organization.
The application aims to deliver financial news to its
subscribers. Financial news comprises the date, the name
of the organization, and the pertinent financial information.
What should you use to represent the financial news in the
XML schema?
a. Complex type element
b. Simple type element
c. Element
d. Attribute
Answer:
a. Complex type element
Ver. 1.0 Session 2 Slide 31 of 36
32. Extensible Markup Language
Practice Questions
Joe wants to specify a user-defined attribute in an XML
schema. He wants to use the use attribute in the XML
schema, but does not want to set the value for the attribute
in his XML document. Which of the following values of the
use attribute should Joe use in his XML schema?
a. optional
b. default
c. required
d. fixed
Answer:
a. optional
Ver. 1.0 Session 2 Slide 32 of 36
33. Extensible Markup Language
Practice Questions
• You have created a global attribute named color. Which of
the following attributes of the xsd:attribute element will
you use to access color?
a. use
b. name
c. ref
d. type
Answer:
c. ref
Ver. 1.0 Session 2 Slide 33 of 36
34. Extensible Markup Language
Summary
In this session, you learned that:
An XML schema can be used to specify the list of elements
and the order in which these elements must appear in the XML
document.
The XSD language is used to describe the structure of the
elements in a schema.
The data types supported by an XML schema can be
categorized as follows:
Primitive
Derived
Atomic
List
The simpleType XSD element allows you to create
user-defined simple data types.
The complexType XSD element allows you to create complex
data types.
Ver. 1.0 Session 2 Slide 34 of 36
35. Extensible Markup Language
Summary (Contd.)
The restriction element can be used to specify constraints
on the values that can be stored in elements and attributes.
The attribute element is used to declare an attribute in an
XSD document.
The attribute element has the following attributes:
name: Specifies the name of the user-defined attribute.
ref: Contains a reference to a global attribute.
use: Specifies whether the use of the user-defined attribute is
mandatory or optional. In addition, it allows you to specify the
default value for an attribute.
type: Specifies the data type of the attribute.
value: Specifies the default or fixed value for a user-defined
attribute.
The use attribute of the attribute element can take optional,
default, fixed, or required as its value.
Ver. 1.0 Session 2 Slide 35 of 36
36. Extensible Markup Language
Summary (Contd.)
A global attribute is used to declare an attribute that is not
associated with any element and can be reused within a
schema.
A namespace is used to avoid naming conflicts between
elements having the same name.
A namespace is declared using the xmlns keyword.
Ver. 1.0 Session 2 Slide 36 of 36
Notas do Editor
Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
Hold a two- three minute discussion on the different types of system-related crimes that the students have experienced or heard. At the end of the discussion, give additional examples of system-related crimes.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
Elaborate on the role that system forensics plays in an organization, based on the discussion in the previous slide and the information given on this slide.
Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
Reiterate the concepts taught earlier by asking the given question.
Reiterate the concepts taught earlier by asking the given question.
Reiterate the concepts taught earlier by asking the given question.
Reiterate the concepts taught earlier by asking the given question.
Reiterate the concepts taught earlier by asking the given question.
Reiterate the concepts taught earlier by asking the given question.