0% found this document useful (0 votes)
67 views47 pages

XML For Software Engineers: Tutorial Outline

The document provides an outline for a tutorial on XML for software engineers. The tutorial will introduce XML, its applications, documents and processors, document type definitions, XML basics, and related technologies. It will also cover how XML can be used in software engineering. The outline includes sections on XML vs HTML and SGML, existing XML applications, XML documents and processors, document type definitions, XML basics, and related technologies like XLink, XSL, DOM, and namespaces.

Uploaded by

John
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)
67 views47 pages

XML For Software Engineers: Tutorial Outline

The document provides an outline for a tutorial on XML for software engineers. The tutorial will introduce XML, its applications, documents and processors, document type definitions, XML basics, and related technologies. It will also cover how XML can be used in software engineering. The outline includes sections on XML vs HTML and SGML, existing XML applications, XML documents and processors, document type definitions, XML basics, and related technologies like XLink, XSL, DOM, and namespaces.

Uploaded by

John
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
You are on page 1/ 47

XML for Software Engineers

Andrea Zisman and Anthony Finkelstein


{a.zisman, a.finkelstein}@cs.ucl.ac.uk
Software Systems Engineering Group
Department of Computer Science
University College London
1

Tutorial Outline
Introduction
XML Applications
XML Documents & Processor
Document Type Definition (DTD)
XML Basics
XML Related Technologies
. . XLink & XPointer
. . XSL
. . DOM
. . Namespace
. . XML-Data
. . XML-QL
XML & Software Engineering
2

Contract / Pre-requisite
What are you going to get out of this tutorial ?
> Know about XML and its related technologies
> Know how to use XML in Software Engineering
Pre-requisites
> Software Engineering background
> HTML and/or SGML
3

Introduction
XML - eXtensible Markup Language
XML - W3C (World Wide Web Consortium) Architecture
Domain - headed by Dan Connolly
XML - is based on SGML (Standard Generalized Markup
Language - ISO8879:1986)
XML - allows developers to create their own markup languages
XML - brings structured information to the Web and provides
a data standard that can encode the content, semantics &
schemata for a wide variety of cases
4

Development Timeline
XML 1.0
Recommendation
XML 1.0 Proposed
Recommendation
HTML 4.0
Recommendation
XML Working draft
HTML 3.2
Simplified/stripped-down
SGML draft (dubbed XML)
HTML 2.0
SGML

1986

1995
Nov

1996
Nov

(Jan

1997
1998
5
Aug Dec) Feb

Architectural Dependencies

Instances /
Domains
CKML RDF
XHTML
OFXXHTML
UXF OSD
XMI CKML
RDF CML
CML OFX
OSD CDF
CDF XMI
UXF
XML
XML

...
HTML ...
HTML

SGML
SGML

XML vs. (HTML, SGML)


XML vs. HTML

XML vs. SGML

Extensibility

Easier

Structure

Simpler (simplified version)

Validation

Less rigid

Purity: it separates structure &


presentation

Provides a small core set of easy-tolearn-and-use constructs

It allows fine-grained search facilities

It makes tool development simpler

No fixed mark up tags

Useful on the Internet and not just for


large corporate or research applications

It allows integration of data from


diverse sources

It supports easy-to-use sty le sheet


7
languages

The 10 Commandments of XML

(Goals)

Be usable over the Internet


Support a wide variety of applications
Be SGML compatible
Be easy to write
Be easy to process by program
Have no optional features (minimum)
Be human-legible and clear
Be designed quickly
Have a formal and concise design
Unambiguous markup

XML Applications
XML = Grammar
Applications =Vocabulary

On line banking
Push publishing Technology
Web automation
Database publishing
Software distribution
Scientific data

Software Engineering
9

Existing XML Applications


Horizontal-industry applications/vocabularies
> Channel Definition Format (CDF)
> Open Software Description (OSD)
> Web Interface Definition Language (WIDL)
> XML Metadata Interchange Format (XMI)

Vertical-industry applications/vocabularies
> Chemical Markup Language (CML)
> Mathematical Markup Language (MathML)
> Open Financial Exchange (OFE or OFX)
> UML eXchange Format (UXF)
10

Existing XML Applications (Cont.)


Internal applications/vocabularies
> The eXtensible HyperText Markup Language (XHTML)
> Resource Description Framework (RDF)

11

XML
XML
Specification

instantiation

Markup
Language
Definition

World-Wide
Web
Consortium

instantiation

Marked-up
Marked-up
Marked-up
Document
Marked-up
Document
Document
Document
XML User
12

XML Documents
XML
Specification

instantiation

Document
Type
Definition

World-Wide
Web
Consortium

instantiation

Marked-up
Marked-up
Marked-up
Document
XML
Document
Document
Document
XML User
13

The Big Picture

XML
Document
XML
Processor

XML
Application

XML
Document
Type
Definition
14

XML Documents
Well-formed document:

It obeys the rules for creating an XML document. The XML


processor can build a tree structure representing the document. It
does not necessarily have an associated document type definition
(DTD).

Valid document:
It has an associated DTD and each element in the document
must conform to the rules that the DTD defines.
15

XML Documents
Rules for Well-formed documents:
1) Use a single root element;
2) Use a valid XML declarative statement;
3) Keep nesting order clear;
4) Do not overlap elements;
5) Match your start and end tags;
6) Close empty elements with the empty-element tag;
7) Attribute values are always in between
If rules for well-formed
documents are violated
then
there is a fatal error !!!
16

Example of a Well-Formed-Valid document


XML Declaration

1: SELECT CREATE MEETING

: ORGANISER WINDOW
: MEETING ORGANISER
2: NEW MEETING
(MEETING DETAILS)

5: ASSOCIATE ORGANISER

: MEETING

: ORGANISER
3: NEW DATE (DATE RANGE)
4: NEW DATE (DATE)

: DATE

<!-- This is a XML document named CreateMeeting_CollDiagram-->


Document Type Declaration
<?xml version=1.0?>
<!DOCTYPE Model SYSTEM UML.dtd>
Root
<Model>
<TaggedValue>
<Tag>Title<Value>Create Meeting Collaboration Diagram
</Value></Tag>
<Tag>Author<Value>Peter John</Value></Tag>
</TaggedValue>
<Package NAME=Create Meeting>
<CollaborationDiagram>
<Collaboration NAME=Create Meeting>
<Instance CLASS=Meeting Organiser />
<Instance CLASS=Organiser Window />
<Instance CLASS=Organiser />
<Instance CLASS=Meeting />
<Instance CLASS=Date />
<Message TYPE=sync
SENDER=Meeting Organiser
RECEIVER=Organiser Window>
<Label SEQUENCE_EX=1
MESSAGE_NAME=select create meeting />
</Message>
...
</Collaboration>
</CollaborationDiagram>
</Package>
17
</Model>

XML Tree Structure


Model

Create
Meeting
CollDiagram
.xml

TaggedValue
Tag

Package

Value
CollaborationDiagram

XML
Processor

Collaboration
Instance Instance

Message Messag e

UML.dtd
Label Label

18

Document Type Definition (DTD)


UML.dtd

<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT

Model
(TaggedValue?, Package*)>
TaggedValue
(Tag*)>
Tag
(#PCDATA, Value*)>
Value
(#PCDATA)>
Note
(#PCDATA)>
Package (TaggedValue?,Note*,
Dependency*,ClassDiagram?,
CollaborationDiagram?)>

<!ATTLIST Package NAME CDATA #REQUIRED>


<!ENTITY % ObjectElements "(TaggedValue?,
(Attribute|Operation|
Generalization|Association
|Dependency|Note)* )">
<!ENTITY % ClassDiagram SYSTEM
"class_diagram.dtd">
%ClassDiagram;
<!ENTITY % CollaborationDiagram SYSTEM
"collaboration_diagram.dtd">
%CollaborationDiagram;

19

Document Type Definition (DTD)


CollaborationDiagram.dtd

<!ELEMENT CollaborationDiagram (TaggedValue?,


Collaboration*)>
<!ELEMENT Collaboration (TaggedValue?, (Instance
| Interaction | Message | Note)*)>
<!ATTLIST Collaboration
NAME
CDATA #REQUIRED
CLASSIFIER CDATA #IMPLIED
OPERATION CDATA #IMPLIED>
<!ELEMENT Instance (Note*)>
<!ATTLIST Instance
NAME
CDATA #IMPLIED
CLASS
CDATA #REQUIRED
CONSTRAINT CDATA #IMPLIED>
<!ELEMENT Interaction (Message)*>
<!ATTLIST Interaction
NAME
CDATA #REQUIRED
CONREXT CDATA #IMPLIED>
<!ELEMENT Message (Label)>
<!ATTLIST Message
NAME
CDATA #IMPLIED
TYPE
(sync|async|others) sync
SENDER
CDATA #REQUIRED
RECEIVER CDATA #REQUIRED
ACTIVATOR CDATA #IMPLIED
ACTION
CDATA #IMPLIED>
<!ELEMENT Label EMPTY>
<!ATTLIST Label
PREDECESSOR CDATA #IMPLIED
SEQUENCE_EX CDATA #IMPLIED>

20

Why Create a DTD?


To ensure that your documents conform to a given structure

To provide visual XML editors with information needed to


guide authors

To enable the use of entities

To enable others to make use of the vocabulary you have


created
21

Where to find a DTD?


External DTDs (external DTD subset):
- files with .dtd extension;
- private or public;
Ex.:

<?xml version=1.0?>
<!DOCTYPE Model SYSTEM UML.dtd>
<?xml version=1.0?>
<!DOCTYPE RED-BOOK PUBLIC -//W3C//DTD HTML 4.0//EN
http://www.rivendell.org/bilbo/red-book.dtd>

Internal DTDs (internal DTD subset):


- it cannot be used by another XML document;
- it is more convenient for testing;
Ex.:

<?xml version=1.0?>
<!DOCTYPE Model
[<!ELEMENT Model (TaggedValue?, Package*)>
<!ELEMENT TaggedValue (Tag)*>
. . . ]>

22

XML Basics
Elements:
start tag, body (content), and end tag
<!ELEMENT Collaboration (TaggedValue?, (Instance
| Interaction | Message | Note)*)>
<!ELEMENT Interaction EMPTY>
<!ELEMENT Note ANY>
<!ELEMENT Process (#PCDATA))
<Collaboration> <TaggedValue>Create Meeting</TaggedValue>
</Collaboration>
<Interaction></Interaction>
<Interaction/>
<Note> Here you can write <Anything/> respecting the <well-formed><rules/>
</well-formed></Note>
<Process> Here we can write any text </Process>

23

XML Basics (Cont.)


Attributes:
(attribute, value) pairs associated with elements
Types:
1) String attributes
2) Tokenized attributes
3) Enumerated attributes
<!ATTLIST Message
NAME
CDATA
MESS_IDT ID
TYPE
(sync|async|others)
SENDER
CDATA
LINKED_EL CDATA
Name

Type

#IMPLIED
#REQUIRED
sync
#REQUIRED
#FIXED
Instance >
Default value

24

XML Basics (Cont.)


Tokenized Attributes:

- ID: unique identifier for the element within the document;


- IDREF: reference to an element with a specific ID;
- IDREFS: reference to multiple elements with specific IDs;
- ENTITY(IES): points to an external entity;
- NMTOKEN(S): takes a value that is any mixture of letters,
digits, and punctuation characteres.
25

XML Basics (Cont.)


<!ENTITY instance_address SYSTEM http://www.inst.com>
...
<!ATTLIST Instance
INST_ID
ID
#REQUIRED
ADDRESS
ENTITY
#REQUIRED
DATE
NMTOKEN #REQUIRED>
...
<!ATTLIST Message
INST_REF
IDREFS
#REQUIRED>
<Instance
INST_ID=inst01
ADDRESS=instance_address
DATE=11-06-99/>
<Instance
INST_ID=inst02
ADDRESS=instance_address
DATE=12-06-99/>
...
<Message
INST_REF=inst01 inst02/>

26

XML Basics (Cont.)


Entities:
Internal: The replacement text of the entity is provided with
the declaration;
External: The replacement text of the entity is in another
storage unit; the content portion of the entitys
declaration refers to this external storage unit;
Ex.: <!ENTITY % String CDATA>
<!ENTITY % Chapter1 SYSTEM chap.dtd>
...
<!ELEMENT Book ANY>
<!ATTLIST Book Title
%STRING; #REQUIRED
Chapter_list %Chapter1; #IMPLIED>
27

XML Basics (Cont.)


Parameter: Entities that are used only within the DTD;
General: Entities that can be used anywhere in a document.
This entities are referenced by & (ampersand).

Ex.:
<!DOCTYPE Model SYSTEM UML.dtd[
<!ENTITY uml Class Diagram>]>
<Model>
&uml;
</Model>
28

XML Basics (Cont.)


Other Definitions:
Comments

<!-- Attention, this is a comment -->

White Space:

space, tab, carriage return, and line feed

CDATA Section:

<![CDATA[This text is insulated from


attention of the parser]]>

29

Exercise
1) In the extract of DTD and XML documents below there are 9 different types
of syntax errors. Identify these errors and write the correct DTD and XML
documents.
<! ELEMENT ClassDiagram (Class | Interface)*>
<!element Class ((Attribute+, (Operation|Generalization|
Association|Dependency)*)>
<!element Interface EMPTY>
<!ATTLIST Class
%id;
NAME
CDATA #REQUIRED
ABSTRACT (true|false) false
VISIBILITY (public|private) #REQUIRED
ACTIVE
CDATA
#FIXED>
<!ELEMENT Attribute ANY>

.. .

<?xml version=1.0?>
<!ENTITY %id ID CDATA
#REQUIRED>
<ClassDiagram>
<Class ID = C1
NAME = User>
</Class>
<Class ID = C1
NAME = Participant>
</Class>
<Interface> OrganiserWindow
</Interface>

...
</ClassDiagram>
30

Solution
3

<! ELEMENT ClassDiagram (Class | Interface)*>


<!element Class ((Attribute+, (Operation|Generalization|
Association|Dependency)*)>
<!element Interface EMPTY>
<!ATTLIST Class
%id;
NAME
CDATA #REQUIRED
ABSTRACT (true|false) false
VISIBILITY (public|private) #REQUIRED
ACTIVE
CDATA
#FIXED>
<!ELEMENT Attribute ANY>

.. .
8

2
1

<?xml version=1.0?>
<!ENTITY %id ID CDATA
#REQUIRED>
<ClassDiagram>
<Class ID = C1
5
NAME = User>
</Class>
<Class ID = C1
NAME = Participant>
6
</Class>
<Interface> OrganiserWindow
</Interface>

...
4

</ClassDiagram>
31

Solution
<!ENTITY %id ID CDATA #REQUIRED>
<!ELEMENT ClassDiagram (Class | Interface)*>
<!ELEMENT Class ((Attribute+, (Operation|Generalization|
Association|Dependency)*)>
<!ELEMENT Interface EMPTY>
<!ATTLIST Class
%id;
NAME
CDATA #REQUIRED
ABSTRACT (true|false) false
VISIBILITY (public|private) #REQUIRED
ACTIVE
CDATA
#FIXED true>
<!ELEMENT Attribute ANY>

.. .

<?xml version=1.0?>
<!DOCTYPE ClassDiagram
SYSTEM cldig.dtd">
<ClassDiagram>
<Class ID = C1
NAME = User
VISIBILITY = public>
<Attribute>Password</Attribute>
</Class>
<Class ID = C2
NAME = Participant
VISIBILITY = public>
<Attribute>Address</Attribute>
</Class>
<Interface> </Interface>

...
</ClassDiagram>
32

Exercise
2) Consider the DFD level 1 below. Construct a DTD for the DFD level 1 and
the respective XML document for the given example.
H in t:
Static/Stored data

Input or data source/


Data Flow
Output or data destination
configure
request

Control
Panel
user commands
and data

interact with
user

configure
system

configuration
data
configuration information
configuration
data

start stop

active/deact.
system

password
process
password

sensor status

monitor
sensors

sensor inf.

Control
Panel Display

configuration
display inf.
data

a/d msg

valid id msg

Sensor

Function or process

display msgs
& status

telephone number tones

Alarm
alarm type
Telephone
Line

33

Solution (DTD)
<!ELEMENT DFD (TaggedValue?, Level*)>
<!ELEMENT TaggedValue (Tag*)>
<!ELEMENT Tag (#PCDATA, Value*)>
<!ELEMENT Value (#PCDATA)>
<!ELEMENT Level (Level0?, Level1?, Level2?)>
<!ELEMENT Level1 (TaggedValue?,(DataSource
|DataDestination| DataFlow
|StoredData| Function) *)
<!ATTLIST Level 1
NAME CDATA #REQUIRED
TEAM CDATA #IMPLIED
DATE
CDATA #IMPLIED>
<!ELEMENT DataSource (DataFlow*)>
<!ATTLIST DataSource
NAME CDATA #REQUIRED>
<!ELEMENT DataDestination (DataFlow*)>
<!ATTLIST DataDestination
NAME CDATA #REQUIRED>
<!ELEMENT DataFlow EMPTY>
<!ATTLIST DataFlow

LABEL
CDATA #REQUIRED
RECEIVER CDATA #REQUIRED
SENDER CDATA #REQUIRED>
<!ELEMENT StoredData (DataFlow*)>
<!ATTLIST StoredData
NAME CDATA #REQUIRED>
<!ELEMENT Function (DataFlow*)>
<!ATTLIST Func tion
NAME CDATA #REQUIRED>

34

Solution (XML)
<?xml version=1.0?>
<!DOCTYPE DFD System DFD.dtd>
<DFD>
<TaggedValue>
<Tag>Title<Value>Alarm System</Value></Tag>
<Tag>Author<Value>R.Pressman</Value></Tag>
</TaggedValue>
<Level>
<Level1 NAME=SafeHome>
<DataSource NAME=Control Panel>
<DataFlow LABEL=user commands and data
RECEIVER=interact with user
SENDER=control panel/>
</DataSource>
<DataSource NAME=Sensors>
<DataFlow LABEL=sensor status
RECEIVER=monitor sensors
SENDER=Sensors/>
</DataSource>
<DataDestination NAME=Control Panel Display>
<DataFlow LABEL=display information>

RECEIVER=Control Panel Display


SENDER=display msgs & status/>
</DataDestination>
<DataDestination NAME=Alarm>
<DataFlow LABEL=alarm type
RECEIVER=Alarm
SENDER=monitor sensors/>
</DataDestination>
<DataDestination NAME=Telephone Line>
<DataFlow LABEL=telephone number tones
RECEIVER=Telephone Line
SENDER=monitor sensors/>
</DataDestination>
<StoredData NAME=configuration inf.>
<DataFlow LABEL=configuration data
RECEIVER=configuration inf.
SENDER=configure system/>
<DataFlow LABEL=configuration data
RECEIVER=display msgs & status
SENDER=configuration inf/>
<DataFlow LABEL=a/d msg
35

Solution (XML)
RECEIVER=monitor sensors
SENDER=configuration inf./>
</StoredData>
<Function NAME=interact with user>
<DataFlow LABEL=password
RECEIVER=process password
SENDER=interact with user/>
<DataFlow LABEL=start stop
RECEIVER=activate/deac. system
SENDER=interact with user/>
<DataFlow LABEL=configure request
RECEIVER=configure system
SENDER=interact with user/>
</Function>
<Function NAME=configure system>
<DataFlow LABEL=configure request
RECEIVER=configure system
SENDER=interact with user/>
<DataFlow LABEL=configuration data
RECEIVER=configuration inf.
SENDER=configure system/>

</Function>
<Function NAME=process password>
<DataFlow LABEL=password
RECEIVER=interact with user
SENDER=process password/>
</Function>
<Function NAME=activate/deac. system>
<DataFlow LABEL=start stop
RECEIVER=activate/deac. system
SENDER=interact with user/>
<DataFlow LABEL=a/d msg
RECEIVER=display msgs and status
SENDER=activate/deac. system/>
</Function>
...
</Level1>
</Level>
</DFD>

36

XML and Related Technologies

XLink

XPointer
XSL
XML

XML-QL

DOM

XML-Data Namespace

37

Linking with XML


Link: is an explicit relationship between two or more
data objects or portions of data objects.
Address: is the description of how to find the two
objects being linked
XML-LINK
XLL

Development Timeline
XLink & XPointer
W3C Work. Draft
XLink
Requirements

XLink

XLink W3C
Working Draft

XLink

XPointer

1998
Mar

1999
Feb

1999
Jul

38

XLink
Characteristics:
1) It provides a mechanism for signaling the presence of a
link (recognition)

2) It defines, partially, the intended behavior of the link

3) It extends the types of hypertext links that can be used


beyond the simple hypertext model of HTML

39

XLink Terminology
Linking element: An XML element that asserts the existence

and describes the characteristics of a link.


Resource: The addressable unit of information; anything that

you can point at on the Web (e.g. file, document,


program, image, query results, sound file).
Locator: Character string associated with a link which

identifies a resource.
Traversal: The action of using a link (accessing a resource).
Arc: A symbolic representation of traversal behavior in links
(direction, context, and timing of traversal)
40

XLink Terminology (Cont.)


Inline Link: A link that serves as one of its own resources. In

an inline link the content of the linking element


acts as a resource.
Out-of-line Link: A link whose content does not serve as one
of the resources of the link.
Multidirectional Link: A link that can be traversed from more
than one of its resources. A link that
points the user in more than one
direction. It gives the ability to move
up, down, left, right, or backward.
41

XLink

vs.

HTML

Any element can be a link

Only A and IMG as link elements

Control link behavior

One behavior for A and one for


IMG

Multi-directional links

One-way links

Multiple destinations

One link destination

Indirect links via link files

Link destination lives in source

Links to specific unit of


information

Links to the entire document

element

<A xlink:type=SIMPLE
xlink:href=www.html#root()/id(exp)
...>
W3C <\A>

<A HREF=www.html#example>
W3C </A>
42

Goals of XLink
Be usable over the Internet
Be usable by a wide variety of link usage domains and classes
of linking application software
Support HTML 4.0 linking constructs
Expression language must be XML
Be feasible to implement
Be informed by knowledge of established hypermedia systems
and standards
43

Goals of Xlink

(Cont.)

Be human-readable and human-writeable

Be designed quickly
Have a formal, concise and illustrative design
Reside within or outside the documents in which the
participating resources reside
Represent the abstract structure and significance of links

44

XLink vs. XPointer


XLink: Is the syntax used to assert link existence and to
describe link characteristics
XPointer: Is a language that supports addressing into the
internal structures of XML documents. It points to
subparts of XML resources (fragment identifier)
origin( )/child::*[position( )=2]
<?xml version=1.0?>
<beg in>
...
<!-- link to XML document-->
<D xlink:type=SIMPLE
. . . > <\D>
...
<!-- link to GIF g raphic-->
<G xlink:type=SIMPLE
. . .> <\G>
...
<\beg in>

root( )

...
<Model>
.
.
.
<\Model>

Model

TaggedValue
Tag

Package

Value
CollaborationDiagram

Collaboration

...
45

Simple Link
<!ELEMENT xlink:simple ANY>
<!ATTLIST xlink:simple
href
CDATA
role
CDATA
title
CDATA
show (new|parsed|replace)
actuate (user|auto)

#REQUIRED
#IMPLIED
#IMPLIED
replace
user>

<!ELEMENT Simple-Link ANY>


<!ATTLIST Simple-Link
xmlns:xlink CDATA
xlink:type
(simple|extended|locator|arc)
xlink:role
CDATA
xlink:href
CDATA
xlink:title
CDATA
xlink:show (new|parsed|replace)
xlink:actuate (user|auto)

#FIXED http://www.w3...
#FIXED simple
#IMPLIED
#REQUIRED
#IMPLIED
replace
user>
46

Simple Link (Example)


<xlink:simple
Descr.xml
href=http://www.uml.com/descr.xml
title=Description of UML elements
role=meeting description
show=new >Meeting
Instance: Meeting
</xlink:simple>
This is an instance of the collaboration
diagram named Create_Meeting. It
has messages 2, 3, 4, and 5 associated
to it ...

Create_meeting CollabDiagram
...
Description of UML elements
Meeting
...

47

Extended Link
<!ELEMENT xlink:extended ((xlink:arc | xlink:locator)*)>
<!ATTLIST xlink:extended
role
CDATA
#IMPLIED
title
CDATA
#IMPLIED
showdefault (new|parsed|replace) #IMPLIED
actuatedefault (user|auto)
#IMPLIED >
<!ELEMENT Extended-Link ((xlink:arc | xlink:locator)*)>
<!ATTLIST Extended-Link
xmlns:xlink
CDATA
#FIXED http://...
xlink:type
(simple|extended|locator|arc) #FIXED extended
xlink:role
CDATA
#IMPLIED
xlink:title
CDATA
#IMPLIED
xlink:showdefault (new|parsed|replace)
#IMPLIED
xlink:actuatedefault (user|auto)
#IMPLIED>
48

Extended Link (Cont.)


<!ELEMENT xlink:locator ANY>
<!ATTLIST xlink:locator
id
ID
#REQUIRED
href
CDATA #REQUIRED
role
CDATA #IMPLIED
title
CDATA #IMPLIED >

<!ELEMENT xlink:arc ANY>


<!ATTLIST xlink:arc
from IDREF #REQUIRED
to
IDREF #REQUIRED
show (new|parsed|replace) replaced
actuate
(user|auto) user >

<!ELEMENT generic_arc ANY>


<!ELEMENT Reference ANY>
<!ATTLIST generic_arc
<!ATTLIST Reference
xmlns:xlink CDATA #FIXED
xmlns:xlink CDATA #FIXED
http://www.w3.org...
http://www.w3.org...
xlink:type (arc)
#FIXED arc
xlink:type (locator) #FIXED locator
xlink:from IDREF #REQUIRED
id
ID
#REQUIRED
xlink:to
IDREF #REQUIRED
xlink:href CDATA #REQUIRED
xlink:show (new|parsed|replace)
xlink:role CDATA #IMPLIED
replaced
xlink:title CDATA #IMPLIED >
xlink:actuate (user|auto) user >
49

Extended Link (Example)


<xlink:extended

Descrorg.xml

showdefault=replace
actuatedefault=user>
<xlink:locator id=inst1
Instance: Organiser
href=http://www.uml.com/Descrmorg.htm/
title=Meeting Organiser >
This is an instance of the collaboration
<xlink:locator id=inst2
diagram named Create_Meeting. It
href=http://www.uml.com/Descrmeet.htm/
title=Meeting >
has messages 3, 4, and 5 associated
<xlink:locator id=inst3
to it ...
Descrmorg.xmlhref=http://www.uml.com/Descrorg.htm/
title=Organiser >
<xlink:arc from=inst1 to=inst3 show=new />
Descrmeet.xml
<xlink:arc
from=inst1
to=inst2 show=new/>
Instance: Meeting
Organiser
</xlink:extended>
...
Instance: Meeting
...

50

Extended Link Group


<!ELEMENT xlink:group (xlink:document*)>
<!ATTLIST xlink:group
steps
CDATA

#IMPLIED>

<!ELEMENT xlink:document EMPTY>


<!ATTLIST xlink:document
href
CDATA

#REQUIRED>

Hub
Document

51

Extended Link Group (Example)


descr1.xml
<xlink:group
step = 1 >
<xlink:document
href=http://www.uml.com/descr2.xml/>
<xlink:document
href=http://www.uml.com/descr3.xml/>
<xlink:document
href=http://www.uml.com/descr4.xml/>

descr2.
xml

descr3.
xml

</xlink:group>
descr4.
xml
52

XPointer
XPointer allows you to target a given element by number, name, type, or
relation to other elements in the document.
XPointer avoids modifications in the target document; i.e. unlike HTML it is
not necessary to insert a named anchor in the target document.

HREF = url#XPointer

or

HREF = url|XPointer

URL
HREF = http://www.cs.ucl.ac.ul/~Staff/a.zisman/uml.xml#
root()/child::Package[position()=1]/child::ClassDiagram[position()=1]
XPointer
53

XPointer

(Location Path)

- Based on XPath - XML Path Language


(W3C working draft - http://www.w3.org/1999/07/WD-xpath-19990709)

basis
LocationPath:

axis-name :: node-test[predicate]*
(/ axis-name :: node-test[predicate]*)*
54

XPointer

(Location Path - Cont.)

Absolute axes:

Relative axes:

a) root( ) - /
b) origin( )
c) id( )
d) here( )
e) unique( )

a) ancestor
b) ancestor-or-self
c) attribute
d) child
e) descendant
f) descendant-or-self
g) following
h) following-sibling
i) parent
j) preceding
k) preceding-sibling
l) self

XPointer

55

(Location Path - Cont.)

Node Tests:

Predicates:

a) *
b) node( )
c) text( )
d) comment( )
e) processing-instruction( )

a) position ( ) = integer
(<, >, !=, >=, <=)
b) position( ) = last( )
c) Count(Location Path)
d) attribute::attr_name

56

Examples
<?xml version=1.0?>
<!DOCTYPE Model SYSTEM UML.dtd>
<Model>
<TaggedValue>
<Tag>Title<Value>Create Meeting Collaboration Diagram
</Value></Tag>
<Tag>Author<Value>Peter John</Value></Tag>
</TaggedValue>
<Package NAME=Create Meeting>
<CollaborationDiagram>
<Collaboration NAME=Create Meeting>
<Instance CLASS=Meeting Organiser />
<Instance CLASS=Organiser Window />
<Instance CLASS=Organiser />
<Instance CLASS=Meeting />
<Instance CLASS=Date />
<Message TYPE=sync
SENDER=Meeting Organiser
RECEIVER=Organiser Window>
<Label SEQUENCE_EX=1
MESSAGE_NAME=select create me eting/>
</Meesage>
...
</Collaboration>
</CollaborationDiagram>
</Package>
</Model>

XPointer

root( )

child::TaggedValue/child::Tag[positi
on( )=2]/child::Value[position( )=1]

descendant::Instance[position( )=3]

descendant::Message[attribute::
SENDER=Meeting Organiser]
origin( )/parent::*
57

(Cont.)

Axes:
a) range :: LocationPath , LocationPath
ex.: range::/descendant::Instance[position( )=1],
/descendant::Instance[position( )=last( )]

b) string :: 2,Meeting Organiser, 5


(selects the position before the letter i in the second occurrence of
the string Meeting Organiser)

58

Goals of XPointer
Be usable over the Internet

Address into XML documents


Be usable in URIs
Be feasible to implement
Be optimized for usability
Be human-readable and reasonably compact
Be designed quickly
Be prepared quickly
Have a formal and concise design
59

Exercise
3) Consider part of an XML document and the XPointer expressions below
and identify the respective elements.
<Model>
<TaggedValue>
<Tag>Title<Value>Business Entities Class
Diagram</Value></Tag>
<Tag>Date<Value>10/09/99</Value></Tag>
</TaggedValue>
<Package NAME=BusinessEntities>
<ClassDiagram>
<Class NAME=Meeting>
<Attribute NAME="status"
ID="attribute6"
TYPE="String"> </Attribute>
<Attribute NAME="name"
ID="attribute7"
TYPE="String"> </Attribute>
</Class></ClassDiagram> </Package></Model>

a) root( );
b) origin( )/child::Package/
child::ClassDiagram/
child::Class[position()=1]/
child::Attribute[position()=2);
c) id(attribute7);
d) origin( )/parent::*;
e) range::/descendant::Attribute
[position( )=1],/descendant::
Attribute[position( )=2];
f) /descendant::Value[position( )=2];

60

Solution

<Model>
<TaggedValue>
<Tag>Title<Value>Business Entities Class
Diagram</Value></Tag>
<Tag>Date<Value>10/09/99</Value></Tag>
</TaggedValue>
<Package NAME=BusinessEntities>
<ClassDiagram>
<Class NAME=Meeting>
<Attribute NAME="status"
ID="attribute6"
TYPE="String"> </Attribute>
<Attribute NAME="name"
ID="attribute7"
TYPE="String"> </Attribute>
</Class></ClassDiagram> </Package></Model>

a) root( );
b) origin( )/child::Package/
child::ClassDiagram/
child::Class[position()=1]/
child::Attribute[position()=2);
c) id(attribute7);
d) origin( )/parent::*;
e) range::/descendant::Attribute
[position( )=1],/descendant::
Attribute[position( )=2];
f) /descendant::Value[position()=2];
61

XSL
XSL - eXtensible Style Language
Based on ISO/IEC 10179 Document
Style Semantics and Specification
Language (DSSSL)

Development Timeline
W3C XSL
Working Draft
W3C XSL
Version 1.0
W3C XSL
Proposal

Based on W3Cs Cascading Style


Sheet (CSS) Language
.

1997
Aug

1998
Aug

1999
Apr

XSL is a language for expressing stylesheets;


XSL allows authors to transform the structure of an XML source tree
into an XML result tree (XSLT);
XSL allows authors to apply formatting and presentation operations to
62
XML elements (formatting objects vocabulary);

XSL Processor

XSL
Stylesheet
Processor

XML

XSL
stylesheet

Tree
Transform.
XSLT

Formatter
Form.
Objects

Presentation
Document

63

(Cont)

XSL
Source Tree
(XML)

XSL
Stylesheet

Result Tree

Rule

Pattern
Template

XML Document
Tree

Construction rules

Presentation
Document Tree
64

XSL (Cont.)
Tree Construction Rules (Template Rules)
Pattern: identifies the element from the XML source document

tree to which the construction rule applies


(<xsl:template>).

Template: it is instantiated to create the result tree.

Formatting Objects: the typographic units from which a


presentation is constructed.
65

Examples
XML:
<Tag gedValue>
<Tag>Title<Value>Create Meeting Collaboration Diagram</Value></Tag>
<Tag>Author<Value>Peter John</Value></Tag>
</Tag gedValue>

XSL:

Presentation Document

<xsl:stylesheet
<fo:block font-size=18pt c olor=green
xmlns:xsl=http://www.w3.org/XSL/Transform/1.0 xmlns:fo=http://Format/1.0>Title Create
xmlns:fo=http://www.w3.org/XSL/Format/1.0>
Meeting Collaboration Diagram</fo:bloc k>
<xsl:template match=Tag>
<fo:block font-size=18pt c olor=green
xmlns:fo=http://Format/1.0>Author Peter
<fo:block font-size=18pt color=green>
John</fo:block>
<xsl:apply-templates/>
Date: 11-06-99
</fo:block>
</xsl:template>
<xsl:template match=TaggedValue> Title Create Meeting Collaboration Diagram
<xsl:apply-templates/>
Author Peter John
Date: 11-06-99
Date: 11-06-99
</xsl:template>
</xsl:stylesheet>
66

Examples
XML:
<Tag gedValue>
<Tag>Title<Value>Create Meeting Collaboration Diagram</Value></Tag>
<Tag>Author<Value>Peter John</Value></Tag>
</Tag gedValue>

XSL:

Presentation Document (HTML)

<xsl:stylesheet
<DIV sty le=font-weight:bold; color:blue>
xmlns:xsl=http://www.w3.org/XSL/Transform/1.0> Title Create Meeting Collaboration Diag ram
<xsl:template match=Tag>
</DIV>
<DIV style=font-weight:bold; color:blue>
<DIV sty le=font-weight:bold; color:blue>
Author Peter John </DIV>
<xsl:apply-templates/>
<DIV sty le=color:red>
</DIV>
Date: 11-06-99</DIV>
</xsl:template>
<xsl:template match=TaggedValue>
<xsl:apply-templates/>
Title Create Meeting Collaboration Diagram
<DIV style=color:red>
Author Peter John
Date: 11-06-99</DIV>
Date: 11-06-99
</xsl:template>
</xsl:stylesheet>
67

Other Examples
XML:
<ClassDiagram><Class>Meeting
<Attribute>status</Attribute>
<Attribute>name</Attribute>
<Method>add</Method>
<Method>remove</Method>
</Class></ClassDiagram>

<xsl:stylesheet
xmlns:xsl=http://www.w3.org/XSL/Transform/1.0>
<xsl:template match=ClassDiagram>
<DIV style=font-weight:bold; color:blue>
<xsl:apply-templates select=Method/>
</DIV>
</xsl:template>
</xsl:stylesheet>

<xsl:stylesheet
xmlns:xsl=http://www.w3.org/XSL/Transform/1.0>
<xsl:template match=ClassDiagram>
<ul>
<xsl:apply-templates select=Class>
<xsl:sort select=Attribute/>
< /xsl:apply-templates>
</ul>
</xsl:template>
</xsl:stylesheet>

68

Exercise
4) Write XSL tree construction rules for part of the XML document below
a) Element TaggedValue should be bold and red;
b) Organise element Instance in alphabetical order;
c) Element Message should be of size 20pt and green;
d) Element Label should be yellow.
<TaggedValue>
<Tag>Title<Value>Create Meeting
Collaboration Diagram</Value></Tag>
<Tag>Author<Value>Peter John</Value>
<Model>
</Tag>
</TaggedValue>
<CollaborationDiagram>
<Collaboration NAME=Create Meeting>
<Instance>Meeting Organiser</Instance>
<Instance>Organiser Window</Instance>
<Instance>Organiser</Instance>
<Instance>Meeting</Instance>
<Instance>Date</Instance>

<Message TYPE=sync
SENDER=Meeting Organiser
RECEIVER=Organiser Window>
<Label SEQUENCE_EX=1
MESSAGE_NAME=select create meeting />
</Message>
...
</Collaboration>
</CollaborationDiagram>
</Package>
</Model>
69

Solution
a)
<xsl:template match=TaggedValue>
<DIV style=font-weight:bold; color:red>
<xsl:apply-templates/>
</DIV>
</xsl:template>
b)
<xsl:template match=Instance>
<xsl:apply-templates select=Instance>
<xsl:sort select=Instance/>
< /xsl:apply-templates>
</xsl:template>
c)
<xsl:template match=Message>
<DIV style=font-size:20pt; color:green>
<xsl:apply-templates/>
</DIV>
</xsl:template>

d)
<xsl:template match=Message>
<DIV style=color:yellow>
<xsl:apply-templates select=Label>
</DIV>
</xsl:template>

70

Document Object Model (DOM)


DOM is an application programming interface (API) for
documents, i.e. HTML and XML documents.
DOM is a way to describe an XML document to another
application or programming language in an effort to manipulate
the information the way it is wanted.
DOM defines the logical structure of documents and the way a
document is accessed and manipulated.
DOM allows programmers to build documents, navigate their
structures, and add, modify, or delete elements and contents.
71

DOM
DOM Level2
W3C Working Draft

(Cont.)
Development Timeline

DOM Level1
W3C Recommen.

DOM identifies:
.

Oct
1998

Mar & Jul


1999

(a) the interfaces and objects used to represent and manipulate


a document;
(b) the semantics of these interfaces and objects (behavior and
attributes);
(c) the relationships and collaborations among these interfaces
72
and objects.

(Cont.)

DOM

DOM representation (logical structure)


Model
<Model>
<CollaborationDiagram>
<Instance>
<Name>Org aniser</Name>
<Message>Sent</Message>
</Instance>
<Instance>
<Name>Meeting </Name>
<Message>Receive</Messag e>
</Instance>
</CollaborationDiagram>
</Model>

CollaborationDiagram

Parser

Instance
Name

Organiser

Message

Sent

Instance
Name

Message

Meeting

Receiver

DOM Objects

The nodes in the tree represent objects and not data structure.
73

DOM

(Cont.)

Level 1: Methods to represent and manipulate document


structure and content.

> Core: interfaces for accessing and manipulating XML contents

> XML: interfaces for accessing and manipulating XML DTDs

> HTML: interfaces for accessing and manipulating HTML


contents
74

DOM

(Cont.)

Level 2:
> Stylesheets: interfaces for associating stylesheets with a
document
> Event model: interfaces for the design of an event system which
allows registration of event handlers, describes event
flow and provides contextual information for each event
> Query, Filters, Iterators, TreeWalker: interfaces to allow
traversal of document subtrees, node lists, or query results
> DOM Range: interfaces for accessing and manipulating a range
of content in a document.
75

Namespace
Development Timeline

It is a collection of names, identified


by a URI, which are used in XML
documents for qualifying names used
as element types and attribute names.

W3C
Recommend.
W3C
Working Draft
Sept
1998

Jan
1999

Motivation:
Applications where a single XML document contains elements
and attributes that are defined for and used by multiple software
modules.
Documents containing markup from multiple sources pose problems
of recognition and collision.
76

Namespace

(Cont.)

Declaring and Using Namespaces:


<?xml version=1.0?>
<uml:diagram xmlns:uml=http://uml.org>
<uml:class_diagram>This is a universally unique element
</uml:class_diagram>
</uml:diagram>
<?xml version=1.0?>
<uml:diagram xmlns:uml=http://uml.org
xmlns:web=http://web.org>
<uml:class_diagram
web:address=www.classdiagram.com />
</uml:diagram>

77

XML-Data
XML-Data is an XML vocabulary (syntax) for schemas;
i.e. for describing and documenting object classes.
XML-Data can describe syntax of XML documents and
conceptual relationships.
XML-Data provides developers to further specify particular
elements (a model for extending XML elements).
Development Timeline

Schemas describe the rules of an


XML document, such as element
names, elements ordering, available
attributes.

XML-Data
W3C Note
Jan
1998

78

XML-Data (Example)
UML.xml
<?xml version=1.0?>
<?xml:namespace name=http://data.org/
as=dt/?>

UML.dtd
<!ELEMENT Model (Package+)>
<!ELEMENT Package (#PCDATA)>

UML.xml
<?xml version=1.0?>
<!DOCTYPE Model SYSTEM UML.dtd>
<Model>
<Package>Collaboration Diagram</Package>
<Package>Class Diagram</Package>
<Package>StateChart Diagram</Packag e>
</Model>

<dt:schema>
<elementType id=Package>
<string/>
</elementType>
<elementType id=Model>
<element type=#Package
occurs=ONEORMORE/>
</elementType>
</dt:schema>
<Model>
<Package>Collaboration Diagram</Package>
<Package>Class Diagram</Package>
<Package>StateChart Diagram</Package>
</Model>
79

XML-QL
Development Timeline
XML-QL W3C
Working Draft

Who?
AT&T Labs
University of Pensilvania

1998
Aug

How can data be extracted from large XML documents?


How can XML data be exchanged between user communities
using different ontologies?
How can XML data from multiple sources be integrated?
Data extraction
Data transformation
Data integration

XML-QL
80

XML-QL

(Cont.)

XML-QL can express queries which can extract pieces of data

from XML documents.

XML-QL can express transformations


which can map XML
.
data between DTDs and can integrate XML data from different
sources.

XML-QL supports joins and aggregates.


81

XML-QL

(Examples)

<!ELEMENT book (author+, title, publisher)>


<!ATTLIST book year
CDATA>
<result>
<!ELEMENT article (author+,
title, year?,
<author><lastname>Date</lastname></author>
(short|long))>
<title>An Introduction to DB Syst</title>
<!ATTLIST article type CDATA)>
WHERE <book>
</result>
<!ELEMENT publisher
(name, address)>
<publisher> <name>Addison-Wesley
<result>
<!ELEMENT author (firstname?, lastname)>
</name></publisher>
<author><lastname>Date</lastname></author>
<title> $t </title>
<bib>
<title>Foundation for Object/Relational
The
<author> Dbs:
$a </author>
<book year=1995>
Third Manifesto</title> </book> in bib.xml
. CONSTRUCT <result> <author> $a </>
<title>An Introduction
to DB Syst</title>
</result>
<author> <lastname>Date</lastname></author>
<title> $t </> </result>
<result>
<publisher><name>Addison-Wesley</name>
<author><lastname>Darwen</lastname></author>
</publisher></book>
<book year=1998> <title>Foundation for Object/Relational Dbs:The
Third Manifesto</title>
<title>Foundation for Object/Relational
Dbs:
</result>
The Third Manifesto</title>
<author><lastname>Date</lastname></author>
<author><lastname>Darwen</lastanme></author>
<publisher><name>Addison-Wesley</name>
</publisher>
82
</book> </bib>

XML-QL (Examples)
<!ELEMENT book (author+, title, publisher)>
<!ATTLIST book year CDATA>
<!ELEMENT article (author+, title, year?,
(short|long))>
<!ATTLIST article type CDATA)>
<!ELEMENT publisher (name, address)>
<!ELEMENT author (firstname?, lastname)>

<!ELEMENT person (lastname, firstname, address?,


phone?, publicationtitle*)

Transforming XML Data


WHERE <$> <author><firstname> $fn</>
<lastname> $ln</></>
<title> $t </>
</> in bib.xml
CONSTRUCT <person ID=PersonID($fn,$ln)>
<firstname> $fn</>
<lastname> $ln</>
<publicationtitle> $t</>
</person>
83

Software Engineering Applications


Structured information on the Web (repositories)
Information interchange
Consistency Management
Generation of specialised mark-up languages
Document templates
Multiple document views & Graphical views
Validation of semi-structured documents
84

Information Interchange
Mapped

Documents

Documents

Tool i

Tool k
XML

XML

XML

Mapped

Documents

Documents

Tool n

Tool j
XML

XML
85

Consistency Management
Consistency Rules

Documents

Documents

Consistency Links

XML
Translated

XML

Translated

Inconsistency

XML
Documents

Translated

XML

Translated

Documents
86

Generation of Specialised Mark-up Lgs.


- Mark-up language for UML Model (XMI, UXF);
- Mark-up language for Z specification (ZIF);
- Mark-up language for Data Flow Diagrams;
- Mark-up language for other design methods;

87

Document Templates
- User requirements documents;
- Software Requirements Specification (SRS IEEE);
- Architectural Design Document;
- Detailed Design Document;
- User Manual;
- Software Verification and Validation Plan;
- Software Engineering Standards (PSS-05-0);

88

Multiple Document Views


XSL

Document

XSL

XSL
89

Graphical View
UML
Model

IE 5

Unisys
exporter

XMI

BOX

VML

Netscape

90

Exercise/Solution
Other Software Engineering applications ?

91

Final Remarks
XML is a data description language, subset of SGML;
XML is designed to bring structured information to the Web;
XML provides a data standard that can encode the content,
semantics and schemata for a wide variety of cases;
XML allows identification, exchange and processing of distributed
data in a manner that is mutually understood;
XML provides extensibility, structure, and data checking needed
for a large-scale commercial document distribution and publishing.
92

References
Books:
1) The XML Handbook; C.F. Goldfarb & P. Prescod;
1998; Prentice Hall
2) XML by Example, Building E-Commerce Applications;
S. McGrath; 1998; Prentice Hall
3) XML A Primer; S. St. Laurent; 1998
4) XML Black Book; N. Pitts-Moultis & C. Kirk; 1999; Coriolis
5) XML Specification Guide; I.S. Graham & L. Quin;
1999; John Wiley & Sons, Inc.
93

References (Cont.)
URLs:
1) List of Books
http://www.able-consulting.com/books_xml.htm
2) Technical reports, working drafts, recommendations & notes
http://www.w3.org/TR
3) Software
http://www.xmlsoftware.com/

94

You might also like