You are on page 1of 25

Introduction to XML

Society for Technical Communication

Presented by Craig Jordan


Senior Software Analyst, Compuware
January 12, 2000

Copyright © 2000, Compuware. All rights reserved.


XML’s Place in the World

Evolution of the Web


Web Technologies
What is XML
Evolution of the Web
■ Static  Dynamic
– Files  Databases
– Retrieve  Find

■ Documents  Applications
– Marketing  Selling
– Telling  Interacting

■ Whole  Part
– Content & Presentation  Presentation
Web Technologies:
Presentation
■ HTML
– Mark-up language for formatting static content

■ DHTML
– API to formatted elements so they can be modified
dynamically

■ CSS
– Declarative format rules
Web Technologies: App
Logic
■ Scripting, Java, ActiveX
– Transport for application logic

■ ASP, CGI
– Server-based techniques for creating interactive
web sites by obtaining user responses and
dynamically generating HTML pages
What has been missing?
■ An intelligent data format that
– offers more than simple formatting
– is platform independent and portable
– isolates information from presentation

■ A format that can describe:


– Data constraints
– Complex relationships
– Application behavior
XML: Extensible Markup
Language
■ A Definition
– XML is a language for creating data-
description languages.

■ An Example
<!DOCTYPE contacts [
<!ELEMENT contacts(contact*)>
<!ELEMENT contact (name, email)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT email (#PCDATA)>
]>
XML: Key Characteristics
■ Data-Centric
■ Database/Source-Neutral
■ Open
■ Human-Readable
■ Extensible
■ Generic
XML Components
■ Document Type Definition (DTD)
– Defines data format
■ Document
– Instantiates a data format
■ Parser
– Converts a document into an internal
tree-structure
– Confirms that data conforms to DTD
XML Benefits

XML Benefits
Not Just for the Web
Conclusion
XML Benefits
Separates Content from
Formatting

– Same content can be formatted in several


different ways.

– Content can be extracted in its raw form.

– Content rather than format can be


searched.
XML Benefits
Data Interoperability

– Document Type Definition (DTD) acts as an


interface agreement between partners

– Data is self-describing

– Data is independent of original source


XML Benefits
Supports Stateless
Architectures

– Provides a transport mechanism for


structured state.

– Platform independent state representation.

– Persistence in any layer is simplified.


XML Benefits
Supports Isolation in N-Tier
Architectures Presentatio
Data Business
n
Layer Logic Layer

Typical n-tier architecture


DTD
1
Business Presentatio
Data XML Xport XML Xport n
Layer Logic Layer
DTD
2
XML enabled n-tier architecture
Not Just for the Web
Goal: Strengthen
Partnership via Shared
Information
Partner 1 Partner 2
DTD
information information

n et
XML r XML
te
In
XML Technical Overview

Document Object Model


XML Syntax
Rendering XML
XML: Document Object
Model
■ The Document Object Model presents
the content of the XML document as a
singly-rooted tree structure.

c o n ta c ts

c o n ta c t c o n ta c t

n am e e m a il n am e e m a il

J o e S m it h js m it h @ e m a il. c o m M a ry C a rn m c a rn @ y a h o o .c o m
XML Syntax: Terminology
Review
■ ELEMENT
– A conceptual name for a portion of a document
■ TAG
– The text that delineates an element.
– Normally a pair of START and END tags.
■ CONTENT
– The text contained between an element’s start and end
tags.
■ ATTRIBUTE
– A qualifier for an element
– Value may be
■ Value Set
■ Free Text
■ Empty
XML Syntax: Terminology
Review
<OPTION VALUE=“Option1” SELECTED>
First Option
</OPTION>

■ ELEMENT Option (an item in a pick-list)


■ TAGS <OPTION> and </OPTION>
■ CONTENT First Option
■ ATTRIBUTES
– Free Text VALUE=“Option1”
– Empty SELECTED
XML Syntax: New
Terminology
■ An XML document consists of 2 parts:
– prolog - declares element names, attributes, and
rules for valid markup of data
– document instance - date with markup; similar to
<BODY> in the HTML world; one ROOT element, with
all other elements as children of the root; tree
representation

■ A parsed document is either:


– well-formed - document need not have a DTD;
elements are properly nested and marked up
– valid - in addition to being well-formed, document
conforms to a DTD (internal or external); all
XML Syntax: Putting it all
together
<change ID=“1” type=“defect” status=“resolved”
visibility=“customer”>
<dateLogged>12/20/1999</dateLogged>
<reportedBy>Rick</reportedBy>
<description>…</description>
<impacts>
<impact type=“A” size=“10”>foo.asp</impact>
<impact type=“M” size=“5”>bar.asp</impact>
</impact>
<failureCause>…</failureCause>
</change>
XML Syntax: Putting it all
together
<!DOCTYPE change [
<!ELEMENT change (dateLogged, reportedBy, descr, impacts,
failureCause)>
<!ATTRLIST change ID CDATA
type (defect|change)
status (open|on-hold|resolved)
visibility (customer|system-test|unit-test|review)>
<!ELEMENT dateLogged (#PCDATA)>
<!ELEMENT reportedBy (#PCDATA)>
<!ELEMENT descr (#PCDATA)>
<!ELEMENT impacts (impact*)>
<!ELEMENT impact (#PCDATA)>
<!ATTRLIST impact type (A|M|D)
size CDATA>
<!ELEMENT failureCause (#PCDATA)>
]>
Rendering XML
XML has no native visual
representation. Some techniques
commonly used to render XML
include
– Cascading Style Sheets (CSS)
– Document Object Model + Script
– Data Binding (Microsoft-specific)
– eXtensible Style Sheets (XSL)
Rendering XML using XSL
XSL can be used to transform XML
documents in many ways. One use is to
transform XML into HTML.

Style Sheet Processor


XML
Document
Resulting
Transformation
Document
XSL
Style Sheet
Conclusions
■ XML will be a key enabling technology
for web applications in the next decade.

■ XML is a database transport technology


in much the same way that ActiveX and
Java are application logic transport
technologies.

■ XML will form the foundation for inter-


partner data exchange and will make
EDI available for the general business

You might also like