0% found this document useful (0 votes)
8 views11 pages

ITEC60 - Module 2

This lesson covers data mapping and exchange, focusing on the importance of metadata and XML in facilitating data transfer between systems. It explains the processes of data mapping, data exchange, and the role of XML and DTD in ensuring structured data. Additionally, it discusses challenges in data mapping, types of metadata, and the use of XSLT and XPath for transforming and formatting XML documents.

Uploaded by

クリス
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views11 pages

ITEC60 - Module 2

This lesson covers data mapping and exchange, focusing on the importance of metadata and XML in facilitating data transfer between systems. It explains the processes of data mapping, data exchange, and the role of XML and DTD in ensuring structured data. Additionally, it discusses challenges in data mapping, types of metadata, and the use of XSLT and XPath for transforming and formatting XML documents.

Uploaded by

クリス
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ITEC 60 – Integrated Programming Languages

Lesson 2

DATA MAPPING AND EXCHANGE


Objectives
After completing this chapter, students should be able to:
1. Explain how metadata summarizes basic information about data.
2. Identify different types of metadata.
3. Discuss how XML works.

Data mapping and exchange is the process of transferring information between different
systems or databases. It involves two key steps:

1. Data Mapping:
• This is the heart of the process, where you define the relationships between
corresponding data elements in the source and destination systems.
• Imagine it like creating a bridge between two islands. You need to identify which
roads on one island connect to which roads on the other.
• Data mapping involves tasks like:
o Matching fields with similar meanings across systems (e.g., "customer name"
in system A might map to "client ID" in system B).
o Transforming data formats (e.g., converting dates from one format to
another).
o Defining data filtering or validation rules (e.g., ensuring only certain types of
data are transferred).

2. Data Exchange:
• Data exchange refers to the process of transferring data between systems,
applications, or organizations in a structured manner. This often involves
standardized formats and protocols (e.g., JSON, XML, CSV, API-based transfers) to
ensure smooth interoperability
• Once the mapping is defined, the actual transfer of data takes place.
• This can involve various methods like:
o File transfers (e.g., sending a CSV file from one system to another).
o Real-time data feeds (where data is continuously streamed between
systems).
o Application Programming Interfaces (APIs) that allow programmatic access
and exchange of data

Why is Data Mapping and Exchange Important?


In today's data-driven world, organizations often have information scattered across
various databases and applications. Data mapping and exchange allows them to:
• Consolidate data: Integrate data from different sources to gain a holistic view of
operations, customers, or trends.
• Improve decision-making: Access and analyze combined data sets for better
insights and informed choices.

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

• Automate workflows: Eliminate manual data entry and streamline processes by


exchanging data automatically.
• Enhance collaboration: Share data securely with partners or internal teams for
improved communication and efficiency.

Challenges of Data Mapping and Exchange


• Data inconsistency: Different systems might store data in different formats or
structures, requiring careful mapping.
• Data quality issues: Inaccurate or incomplete data in the source system can lead to
errors in the destination.

2.1 Metadata

What is Metadata?
In data mapping and exchange, metadata plays a critical role by acting as "data about
data." Understanding metadata is essential for ensuring successful exchange and utilization
of information between different systems. Metadata provides a descriptive layer about the
data itself. It answers questions like:
• What does this data represent? (e.g., customer names, sales figures)
• How was this data created? (e.g., data collection method, software used)
• When was this data created and last modified?
• What is the format of the data? (e.g., CSV, XML)
• What are the units of measurement used? (e.g., dollars, meters)
• What are the access restrictions for this data? (e.g., confidential, public)
Think of metadata as a label on a box. It tells you what's inside, when it was packed, and
any special handling instructions.

Importance of Metadata in Data Mapping and Exchange


During data mapping and exchange, metadata plays a crucial role in several ways:
• Facilitates Data Discovery: Accurate metadata allows users to search and identify
relevant datasets efficiently. It acts as a catalog, helping users find information based
on specific criteria.
• Improves Data Integration: When exchanging data between different systems,
metadata helps bridge the gap between disparate formats and structures. It enables
systems to understand the meaning and context of the data being transferred.
• Ensures Data Quality: Complete and accurate metadata helps identify potential
errors or inconsistencies within the data. This is crucial for maintaining data integrity
and trustworthiness.
• Enhances Data Governance: Detailed metadata allows for better data governance
by establishing ownership, access control, and usage guidelines for the data.

Types of Metadata
There are various types of metadata, each serving a specific purpose:
• Descriptive Metadata: Provides general information about the data content, such as
title, author, subject, and keywords.

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

• Structural Metadata: Describes the organization and structure of the data, including
data types, relationships between elements, and hierarchy within the dataset.
• Administrative Metadata: Focuses on the management aspects of the data,
including creation date, modifications, access control, and usage rights.
• Technical Metadata: Details the technical specifications of the data, such as file
format, encoding standards, and compression methods.

Data Mapping and Metadata Standards


For seamless data exchange, standardized metadata formats are crucial. Here are some
common examples:
• Dublin Core: A widely used set of metadata elements for describing resources, often
used for library catalogs and online resources.
• Extensible Markup Language (XML): A flexible language for structuring data and
metadata, allowing for custom elements and definitions.
• SDMX (Statistical Data and Metadata Exchange): An international standard
specifically designed for exchanging statistical data and related metadata.

2.2 XML and DTD (DOCTYPE Declaration)

XML: The Foundation for Structured Data

XML (Extensible Markup Language) is a markup language designed to encode data in a


human-readable and machine-processable format. It utilizes tags to define the structure and
hierarchy of data, making it platform-independent and ideal for data exchange.

Structure: An XML document consists of:


o Elements: Represent data containers identified by opening and closing tags
(e.g., <title>My Book</title>). Elements can have attributes (name-value
pairs) to provide additional details (e.g., <book genre="fantasy">).
o Attributes: Provide descriptive information about elements (e.g.,
author="J.R.R. Tolkien").
o Content: Textual data resides within elements (e.g., the actual book title
within <title> tags).

XML SYNTAX

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

Nesting: Elements can contain other elements, creating a hierarchical structure. This
nesting must be properly balanced, where each opening tag has a corresponding closing
tag. Imagine it like a set of boxes; you can't close a box that wasn't opened.

Root Element: Every XML document must have a single root element that encloses all
other elements. This element represents the entire document's content.

XML Prolog: Optional, and is written at the first line.

Case Sensitivity: XML is case-sensitive. So <heading> is different from <HEADING>.

Whitespace: While whitespace (spaces, tabs, newlines) is generally preserved in XML, it's
often ignored. This means multiple spaces might collapse into a single space

XML Declaration: This declaration specifies the XML version and character encoding used
in the document. It's typically the first line in the prolog and looks like this:

<?xml version="1.0" encoding="UTF-8"?>

Entity References:
Character Entity Reference Description

< &lt; Less than sign

> &gt; Greater than sign

& &amp; Ampersand (&)

" &quot; Double quote (")

' &apos; Apostrophe (')

© &copy; Copyright symbol ©

® &reg; Registered trademark symbol ®

€ &euro; Euro symbol €

™ &trade; Trademark symbol ™

§ &sect; Section sign §

¥ &yen; Yen symbol ¥

… &hellip; Ellipsis (...)

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

DTD (DOCTYPE Declaration): Defining the Rules for XML

Definition:DTD (Document Type Definition) acts as a set of rules that define the legal
structure of an XML document. It specifies the elements, their attributes, their nesting order,
and their content types.

Functionality: DTD acts as a blueprint for valid XML documents, ensuring data consistency
and adherence to a specific format. This enables data validation during processing and
helps prevent errors.

Components: A DTD typically includes:


o Element declarations: Define valid elements, their attributes (if any), and
their content model (the allowed elements or text within them).
o Attribute declarations: Specify the attributes allowed for specific elements
and their data types.
o Entity declarations: Define shortcuts for frequently used text or elements
(not commonly used today).

Example:

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

Limitations of DTDs:
o Limited Data Type Support: DTDs primarily focus on structure and offer
limited support for defining data types (e.g., integer, date).
o Verbosity: Complex data structures can lead to verbose DTDs that are
difficult to maintain.
o Lack of Self-Description: DTDs are separate files, making it less convenient
to understand the document structure directly from the XML itself.

Data Mapping and Exchange with XML and DTD

• Data Mapping: The process of transforming data from one format (source) to
another (destination) while preserving its meaning and integrity. XML, with its
flexibility, serves as a common intermediate format for data mapping.
• DTD in Data Mapping: While DTDs define the structure, they don't explicitly specify
the mapping between source and destination formats. However, they play a crucial
role in ensuring data validity during the mapping process. A well-defined DTD for the
target format helps validate the transformed data, guaranteeing its adherence to the
expected structure.

Sample of XML and DTD (DOCTYPE) working together

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

Another sample:

2.3 Parsing XML Documents

Parsing XML Documents

Parsing XML documents refers to the process of extracting and interpreting the structured
data contained within an XML file. XML (Extensible Markup Language) is a flexible way to
represent information using tags that define the structure and meaning of the data.
Here's a breakdown of the parsing process:

• Validation (Optional): This step verifies if the XML document adheres to a set of
predefined rules outlined in a Document Type Definition (DTD) or an XML Schema
(XSD). This ensures the data is formatted correctly and adheres to a specific
structure.
• Lexical Analysis: The parser breaks down the XML document into individual tokens,
which include elements (tags), attributes, text content, and comments.
• Syntactic Analysis: The parser checks the relationships between these tokens to
see if they follow the grammatical rules of XML. This ensures the document is well-
formed and has a proper hierarchical structure.
• Building the Content Tree: The parser creates a hierarchical representation of the
data in memory, often referred to as a content tree. This tree reflects the nesting of
elements within the document.

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

• Data Extraction: Once the content tree is built, applications can access and process
the information within the XML elements and attributes. This allows programs to
understand the meaning and relationships between the data points.

Parsing XML documents is a fundamental skill for many applications that deal with
structured data exchange. It enables software to interact with data stored in XML format,
which is widely used for tasks like:
• Configuring applications
• Exchanging data between different systems
• Representing scientific data
• Storing electronic documents

Parsing Whitespaces of XML:

<message xml:space="preserve">
This is a message with multiple spaces.
</message>

<poem xml:space="default">
Roses are red,
Violets are blue.
</poem>
Explanation:
• xml:space="preserve": This attribute instructs the XML parser to preserve all
whitespace characters within the element and its child elements.
• xml:space="default": This attribute tells the parser to use its default whitespace
handling rules, which typically involve ignoring insignificant whitespace.

Output (parsed representation):


message
This is a message with multiple spaces.
poem
Roses are red, Violets are blue.

Key Points:
• The xml:space attribute affects only the element it's directly attached to and its child
elements.
• It has two possible values:
o preserve: Preserves all whitespace within the element and its children.

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

o default: Uses the parser's default whitespace handling rules.

It's often used when dealing with mixed content (text and elements), poetry, code blocks, or
any situation where whitespace is essential for the data's meaning.

2.4 XSL, XSLT, and XPath

Extensible Stylesheet Language (XSL) is a powerful suite of standards designed for


transforming and formatting XML documents. It consists of three main components that work
together:
• XSLT (XSL Transformations): The workhorse of XSL, XSLT is a language for
processing and transforming XML data. It allows you to define rules for how to
convert an XML document into another format, such as HTML, plain text, or even
another XML structure. XSLT uses XPath expressions to navigate and address
specific parts of the source XML document.
• XPath (XML Path Language): XPath is a sub-language of XSL that acts as an
addressing mechanism. It provides a syntax for navigating the hierarchical structure
of an XML document and selecting specific elements or attributes. Similar to a file
path on your computer, XPath expressions specify a path to locate data within the
XML tree.
• XSL-FO (XSL Formatting Objects): While not as widely used as XSLT and XPath,
XSL-FO provides a vocabulary for defining the formatting of an XML document. It
allows you to specify page layouts, fonts, margins, and other presentational aspects,
similar to how CSS styles web pages. XSL-FO descriptions are also written in XML
format.

XSLT Example: XML to HTML

XML ([Link]):
XML
<books>
<book>
<title>The Lord of the Rings</title>
<author>J.R.R. Tolkien</author>
</book>
<book>
<title>Pride and Prejudice</title>
<author>Jane Austen</author>
</book>
</books>

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

XSLT ([Link]):
XML
<xsl:stylesheet version="1.0" xmlns:xsl="[Link]
<xsl:template match="/">
<html>
<body>
<h1>My Books</h1>
<ul>
<xsl:for-each select="books/book">
<li>
<b><xsl:value-of select="title"/></b> by <i><xsl:value-of select="author"/></i>
</li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

This XSLT transforms the [Link] into a simple HTML list of books with titles and authors.

XPath Example: Finding Book Titles

XML (same as above):


XPath expression:
/books/book/title

This XPath expression selects all "title" elements that are children of "book" elements
within the root "books" element.

XSL-FO Example: Basic Page Layout

XSL-FO ([Link]):
XML
<fo:root xmlns:fo="[Link]
<fo:page-sequence>
<fo:block font-family="Arial" font-size="12pt">
This text will be displayed on the page.
</fo:block>
</fo:page-sequence>
</fo:root>

This XSL-FO defines a single page with a block of text using Arial
font at 12pt size.

Cavite State University Naic


ITEC 60 – Integrated Programming Languages
Lesson 2

How They Work Together:


1. Transformation with XSLT: An XSLT stylesheet defines a set of rules for
transforming the source XML document. These rules use XPath expressions to
identify specific elements and data within the source document.
2. Navigation with XPath: Within the XSLT stylesheet, XPath expressions pinpoint the
exact locations of elements and attributes that need to be processed or transformed.
3. Formatting (Optional): XSL-FO can be integrated with XSLT to define the
presentation of the transformed output. This is particularly useful for generating
printable documents.

Advantages of XSL, XSLT, and XPath:

• Separation of Concerns: XSLT separates the data (XML) from its presentation,
promoting code reusability and maintainability. Changes to the stylesheet (XSLT) can
affect the presentation without modifying the underlying data.
• Flexibility: XSLT provides a powerful and flexible way to transform XML data into
various formats. It can handle complex data structures and transformations.
• Standardization: XSL, XSLT, and XPath are all W3C standards, ensuring cross-
platform compatibility and interoperability with different XML processing tools.
• Data Extraction and Navigation: XPath allows for precise navigation and extraction
of specific data points within complex XML documents.

Disadvantages of XSL, XSLT, and XPath:

• Learning Curve: XSLT and XPath have their own syntax and can have a steeper
learning curve compared to simpler formatting languages.
• Complexity: For simple transformations, XSLT can be more complex than
necessary. Other lightweight options might be more efficient.
• Performance: While generally efficient, processing large or complex XSLT
stylesheets can impact performance.

Applications of XSL, XSLT, and XPath:

• Generating HTML from XML: A common use case is to transform XML data into
HTML for web page display. XSLT can extract and format content from the XML for
presentation in a browser.
• Data Conversion: XSLT can be used to convert data between different XML
formats, ensuring compatibility with different systems.
• Data Extraction and Reporting: By identifying specific elements with XPath, XSLT
can extract relevant data from XML for use in reports or other applications.

Cavite State University Naic

You might also like