Abdulrahman A. Mohamed Mobile: +254 713 500 814 Email: abdulrehman@tum.ac.
ke
TECHNICAL UNIVERSITY OF MOMBASA
CCI 4301: ADVANCED DATABASE MANAGEMENT SYSTEMS
WEEK 9: XML AND WEB DATA
OUTLINE
• 1. Introduction to XML and Semi-structured Data
• 2. Overview of XML
• 3. XML Schema
• 4. XML Query Languages
1. Introduction to XML and Semi-structured Data:
Definition: XML (eXtensible Markup Language) is a markup language used to structure and
store data in a hierarchical format. Semi-structured data refers to data that does not
conform to a rigid structure like traditional databases but still has some structure and
organization.
Explanation:
• XML as a Hierarchical Structure: XML is designed to represent data in a hierarchical
manner, using elements enclosed in tags. It provides a flexible way to structure and
store data, making it suitable for representing various types of information.
• Semi-Structured Data: Unlike structured databases where data follows a fixed
Abdulrahman A. Mohamed Mobile: +254 713 500 814 Email: abdulrehman@tum.ac.ke
schema, semi-structured data allows for variations in data structure. For example,
different XML documents can have different elements or attributes, yet they can still
be processed.
Examples, Scenarios, and Practical Applications:
• Scenario: An e-commerce website stores product information in XML format. Each
product listing may have different attributes, such as name, price, manufacturer, and
product reviews, but they all conform to a common XML structure.
• Practical Application: XML is widely used in data interchange, including web
services, configuration files, and data exchange between heterogeneous systems. For
instance, a web service that provides weather data can deliver XML-formatted
responses to clients, allowing them to extract relevant information.
2. Overview of XML:
Definition: An overview of XML includes understanding its basic syntax, elements,
attributes, and the use of tags to structure data.
Explanation:
• Basic Syntax: XML documents consist of text data enclosed in tags. Tags are used to
define elements, attributes, and their relationships. Tags are enclosed in angle
brackets, e.g., <element>.
• Elements and Attributes: Elements are the building blocks of XML documents and
can contain text data or other elements. Attributes provide additional information
about elements and are specified within the opening tag of an element.
Examples, Scenarios, and Practical Applications:
• Scenario: An online book catalog uses XML to represent book listings. Each <book>
Abdulrahman A. Mohamed Mobile: +254 713 500 814 Email: abdulrehman@tum.ac.ke
element contains attributes like title, author, and <price> elements for book
information.
• Practical Application: XML is commonly used in configuration files for software
applications. For example, an XML configuration file for a content management
system may specify settings like database connection details, caching options, and
user access controls.
3. XML Schema:
Definition: XML Schema defines the structure, data types, and constraints that XML
documents must adhere to. It provides a schema definition language for validating XML
data.
Explanation:
• Structure Definition: XML Schema specifies the structure of XML documents,
including the elements and attributes that are allowed, their order, and their
cardinality (e.g., whether an element can appear once or multiple times).
• Data Type Validation: XML Schema can enforce data type constraints, ensuring that
data within elements and attributes adhere to specified data types (e.g., strings,
numbers, dates).
Examples, Scenarios, and Practical Applications:
• Scenario: An online order processing system uses XML Schema to validate incoming
order data. The schema defines the structure and data types for customer
information, product details, and pricing.
• Practical Application: XML Schema is employed in industries such as healthcare,
where HL7 (Health Level Seven) XML schemas define the structure of medical
Abdulrahman A. Mohamed Mobile: +254 713 500 814 Email: abdulrehman@tum.ac.ke
records and messages exchanged between healthcare systems and providers.
4. XML Query Languages:
Definition: XML Query Languages enable the retrieval and manipulation of data from XML
documents. Common XML query languages include XPath and XQuery.
Explanation:
• XPath: XPath is a query language that allows you to navigate through an XML
document to select elements and attributes based on their paths and conditions.
• XQuery: XQuery is a more powerful query language that can perform complex
queries, aggregations, and transformations on XML data. It's especially useful for
querying XML databases.
Examples, Scenarios, and Practical Applications:
• Scenario: An e-commerce website uses XPath to extract product details, such as the
names and prices of all products in a specific category, from an XML-based product
catalog.
• Practical Application: XQuery can be used in content management systems to
extract and transform XML content for presentation on websites. For example, it
can extract news articles from an XML database, apply formatting, and display them
on a news portal.
These concepts and tools in XML play a significant role in various domains, including web
development, data exchange, data modeling, and document management, offering
flexibility and structure for data representation and manipulation.