Docsity

XML: An Introduction to the Extensible Markup Language, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download XML: An Introduction to the Extensible Markup Language and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Introduction to XML: Part I

Overview

• What is XML?

• Why XML is popular?

• How to write a XML document?

• How to write XML DTD’s/Schemas?

Structured Data

• Structured data refers to data that is tagged

for its content, meaning, or use

• Includes: spreadsheets, address books,

databases, PDF documents, …

• Stored in binary or text format

XML Technology Model

• Data is modeled in XML

• The structure and constraints are modeled

using DTD’s or Schemas

• The document format can be modeled using

XSL (XML Style Sheets)

• REMEMBER: XML allows us to separate data

from presentation!

MyMathML

add

4

mult

5

3

MyChemML

ChemML (tracking experiments)

The compound under investigation is common water: **

** It boils at 100 degrees and freezes at 0 degrees! For more information about this amazing compound see the March 2003 issue of:

Water World

(Now the technical stuff)

XML Example

John Doe Introduction to XML 12 June 2001 121232323 XYZ

Foo Bar Introduction to XSL 12 June 2001 12323573 ABC

Well-formed vs Valid

  • Syntax & Semantic checking
  • Well-formed (syntax):
    • Properties: (1) every start tag has a matching end tag, and (2) elements are properly nested
    • an XML document might be “well-formed” without being “valid“, but a “valid” document is “well-formed”
  • Valid (semantic):
    • A valid XML document conforms to the vocabulary constraints defined in a DTD or Schema

Definition and Validation

• Two ways to define the structure of an XML

document

– DTDs

– Schemas

• Each set of rules specifies an XML vocabulary

What is a DTD?

• Document Type Definitions (DTD)

– Emphasis on the structure of the XML, what

elements and attributes can appear and their

relationships

– Difficult to work with

– No support for data types

– Not extensible

Problems with DTD’s

It's not XML syntax

  • You write your XML document using one syntax and the DTD using another syntax -> inconsistent, more work for the parsers.

Limited set of primitive datatypes

  • Desire a set of datatypes compatible with those found in databases - One of the main weaknesses of DTD is its lack of support for data types beyond character strings (PCDATA).

Limited support for applying constraints.

  • Can support only constraints like “+” (1 or more occurences), “?” (0 or 1 occurences), “*” (0 or more occurences), etc. No facility for providing constraints like those found in databases (enumerations, ranges, string length, etc.)

What are Schemas?

  • Schemas
    • More complex than DTD’s
    • Specify structure
    • Support for precise data type constraints
    • Allows for user-defined data types (complex/simple types)
    • Enhanced datatypes (unlike PCDATA in DTD’s):
      • Wider range of primitive data types, supporting those found in

databases (string, boolean, decimal, integer, date, etc.)

  • Can create your own datatypes (complexType)
  • Support namespaces for extensibility

< xsd:schema xmlns:xsd =“http://www.w3.org/2001/XMLSchema” targetNamespace="http://www.books.org" xmlns =“http://www.books.org”> **


XML Namespaces: Code-reuse

• Namespaces

– Identifies an XML vocabulary defined by a URI

(Uniform Resource Identifier)

– Allows reuse of XML markup

– Resolves problems with recognition and collision

of tags with similar names. Can happen if your

combining elements from multiple documents.

(see previous slide)