XML For Software Engineers
XML For Software Engineers
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
1
Contract / Pre-requisite
What are you going to get out of this tutorial ?
Pre-requisites
Introduction
¥ XML - eXtensible Markup Language
2
Development Timeline
XML 1.0
Recommendation
HTML 3.2
Simplified/stripped-down
SGML draft (dubbed XML)
HTML 2.0
SGML
Architectural Dependencies
Instances /
Domains
UXF OSD
UXF OSD CDF
CDF XMI CKML RDF
XMI CKML RDF CML
CML OFX XHTML
OFXXHTML
XML
XML HTML ...
HTML ...
SGML
SGML
3
XML vs. (HTML, SGML)
XML vs. HTML XML vs. SGML
¥ Extensibility ¥ Easier
¥ Structure ¥ Simpler (simplified version)
¥ Validation ¥ Less rigid
¥ Purity: it separates structure & ¥ Provides a small core set of Òeasy-to-
presentation learn-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
languages 7
4
XML Applications
XML = Grammar
¥ On line banking Applications =Vocabulary
¥ Web automation
¥ Database publishing
¥ Software distribution
¥ Scientific data
¥ Software Engineering
9
¥Vertical-industry applications/vocabularies
10
5
Existing XML Applications (Cont.)
¥ Internal applications/vocabularies
11
XML
XML instantiation
Specification
Markup
instantiation
Language
Definition
ÒMarked-upÓ
ÒMarked-upÓ
ÒMarked-upÓ
Document
ÒMarked-upÓ
Document
Document
Document
World-Wide
Web
Consortium XML User
12
6
XML Documents
XML instantiation
Specification
Document
instantiation
Type
Definition
ÒMarked-upÓ
ÒMarked-upÓ
ÒMarked-upÓ
Document
XML
Document
Document
Document
World-Wide
Web
Consortium XML User
13
XML
Document
XML
XML
Application
Processor
XML
Document
Type
Definition
14
7
XML Documents
¥ Well-formed document:
¥ Valid document:
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
8
Example of a Well-Formed-Valid document
XML Declaration <!-- This is a XML document named CreateMeeting_CollDiagram-->
<Model> Root
: ORGANISER WINDOW
<TaggedValue>
<Tag>Title<Value>Create Meeting Collaboration Diagram
: MEETING ORGANISER </Value></Tag>
<Tag>Author<Value>Peter John</Value></Tag>
2: NEW MEETING </TaggedValue>
(MEETING DETAILS) <Package NAME=ÒCreate MeetingÓ>
<CollaborationDiagram>
<Collaboration NAME=ÒCreate MeetingÓ>
<Instance CLASS=ÒMeeting OrganiserÓ />
<Instance CLASS=ÒOrganiser WindowÓ />
: MEETING <Instance CLASS=ÒOrganiserÓ />
5: ASSOCIATE ORGANISER
<Instance CLASS=ÒMeetingÓ />
<Instance CLASS=ÒDateÓ />
<Message TYPE=ÒsyncÓ
SENDER=ÒMeeting OrganiserÓ
: ORGANISER RECEIVER=ÒOrganiser WindowÓ>
3: NEW DATE (DATE RANGE) <Label SEQUENCE_EX=Ò1Ó
4: NEW DATE (DATE)
MESSAGE_NAME=Òselect create meetingÓ />
</Message>
...
</Collaboration>
: DATE </CollaborationDiagram>
</Package> 17
</Model>
Create
Meeting TaggedValue Package
CollDiagram
.xml Tag Value
XML CollaborationDiagram
Processor
Collaboration
18
9
Document Type Definition (DTD)
<!ELEMENT Model (TaggedValue?, Package*)>
UML.dtd <!ELEMENT TaggedValue (Tag*)>
<!ELEMENT Tag (#PCDATA, Value*)>
<!ELEMENT Value (#PCDATA)>
<!ELEMENT Note (#PCDATA)>
<!ELEMENT Package (TaggedValue?,Note*,
Dependency*,ClassDiagram?,
CollaborationDiagram?)>
"collaboration_diagram.dtd">
%CollaborationDiagram; 19
1
Why Create a DTD?
1
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))
Types:
1) String attributes
2) Tokenized attributes
3) Enumerated attributes
<!ATTLIST Message
NAME CDATA #IMPLIED
MESS_IDT ID #REQUIRED
TYPE (sync|async|others) ÒsyncÓ
SENDER CDATA #REQUIRED
LINKED_EL CDATA #FIXED ÒInstanceÓ >
24
Name Type Default value
1
XML Basics (Cont.)
Tokenized Attributes:
<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
1
XML Basics (Cont.)
Entities:
Ex.: É
<!DOCTYPE Model SYSTEM ÒUML.dtdÓ[
<!ENTITY uml ÒClass DiagramÓ>]>
<Model>
¨
</Model>
28
1
XML Basics (Cont.)
Other Definitions:
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.
<?xml version=Ò1.0Ó?>
<! ELEMENT ClassDiagram (Class | Interface)*> <!ENTITY %id ÒID CDATA
<!element Class ((Attribute+, (Operation|Generalization| #REQUIREDÓ>
Association|Dependency)*)> <ClassDiagram>
<!element Interface EMPTY> <Class ID = ÒC1Ó
<!ATTLIST Class NAME = User>
%id; </Class>
NAME CDATA #REQUIRED <Class ID = ÒC1Ó
ABSTRACT (true|false) ÒfalseÓ NAME = Participant>
VISIBILITY (public|private) #REQUIRED </Class>
ACTIVE CDATA #FIXED> <Interface> OrganiserWindow
<!ELEMENT Attribute ANY> </Interface>
.. . ...
</ClassDiagram>
30
1
Solution
3 9 7 2
<! ELEMENT ClassDiagram (Class | Interface)*>
<!element Class ((Attribute+, (Operation|Generalization| 1
Association|Dependency)*)>
<!element Interface EMPTY> <?xml version=Ò1.0Ó?>
<!ATTLIST Class <!ENTITY %id ÒID CDATA
%id; #REQUIREDÓ>
NAME CDATA #REQUIRED <ClassDiagram>
ABSTRACT (true|false) ÒfalseÓ <Class ID = ÒC1Ó 5
VISIBILITY (public|private) #REQUIRED NAME = User>
ACTIVE CDATA #FIXED> </Class>
<!ELEMENT Attribute ANY> <Class ID = ÒC1Ó
.. . NAME = Participant>
</Class> 6
<Interface> OrganiserWindow
8 </Interface>
...
4 </ClassDiagram>
31
Solution
<!ENTITY %id ÒID CDATA #REQUIREDÓ>
<!ELEMENT ClassDiagram (Class | Interface)*> <?xml version=Ò1.0Ó?>
<!ELEMENT Class ((Attribute+, (Operation|Generalization| <!DOCTYPE ClassDiagram
Association|Dependency)*)>
SYSTEM Ócldig.dtd">
<!ELEMENT Interface EMPTY> <ClassDiagram>
<!ATTLIST Class <Class ID = ÒC1Ó
%id; NAME = ÒUserÓ
NAME CDATA #REQUIRED VISIBILITY = ÒpublicÓ>
ABSTRACT (true|false) ÒfalseÓ <Attribute>Password</Attribute>
VISIBILITY (public|private) #REQUIRED </Class>
ACTIVE CDATA #FIXED ÒtrueÓ> <Class ID = ÒC2Ó
<!ELEMENT Attribute ANY> NAME = ÒParticipantÓ
.. . VISIBILITY = ÒpublicÓ>
<Attribute>Address</Attribute>
</Class>
<Interface> </Interface>
...
</ClassDiagram>
32
1
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:
configure configuration
Control request configure data configuration information
Panel system Control
interact with Panel Display
user commands configuration
user data configuration
and data start stop display inf.
data
active/deact.
password
system a/d msg Alarm
process valid id msg
password display msgs
& status alarm type
sensor inf.
Sensor monitor Telephone
sensors Line
sensor status
telephone number tones
33
Solution (DTD)
<!ELEMENT DFD (TaggedValue?, Level*)> LABEL CDATA #REQUIRED
<!ELEMENT TaggedValue (Tag*)> RECEIVER CDATA #REQUIRED
<!ELEMENT Tag (#PCDATA, Value*)> SENDER CDATA #REQUIRED>
<!ELEMENT Value (#PCDATA)> <!ELEMENT StoredData (DataFlow*)>
<!ELEMENT Level (Level0?, Level1?, Level2?)> <!ATTLIST StoredData
<!ELEMENT Level1 (TaggedValue?,(DataSource NAME CDATA #REQUIRED>
|DataDestination| DataFlow <!ELEMENT Function (DataFlow*)>
|StoredData| Function) *) <!ATTLIST Func tion
<!ATTLIST Level 1 NAME CDATA #REQUIRED>
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
34
1
Solution (XML)
<?xml version=Ò1.0Ó?> RECEIVER=ÒControl Panel DisplayÓ
<!DOCTYPE DFD System ÒDFD.dtdÓ> SENDER=Òdisplay msgs & statusÓ/>
<DFD> </DataDestination>
<TaggedValue> <DataDestination NAME=ÒAlarmÓ>
<Tag>Title<Value>Alarm System</Value></Tag> <DataFlow LABEL=Òalarm typeÓ
<Tag>Author<Value>R.Pressman</Value></Tag> RECEIVER=ÒAlarmÓ
</TaggedValue> SENDER=Òmonitor sensorsÓ/>
<Level> </DataDestination>
<Level1 NAME=ÒSafeHomeÓ> <DataDestination NAME=ÒTelephone LineÓ>
<DataSource NAME=ÒControl PanelÓ> <DataFlow LABEL=Òtelephone number tonesÓ
<DataFlow LABEL=Òuser commands and dataÓ RECEIVER=ÒTelephone LineÓ
RECEIVER=Òinteract with userÓ SENDER=Òmonitor sensorsÓ/>
SENDER=Òcontrol panelÓ/> </DataDestination>
</DataSource> <StoredData NAME=Òconfiguration inf.Ó>
<DataSource NAME=ÒSensorsÓ> <DataFlow LABEL=Òconfiguration dataÓ
<DataFlow LABEL=Òsensor statusÓ RECEIVER=Òconfiguration inf.Ó
RECEIVER=Òmonitor sensorsÓ SENDER=Òconfigure systemÓ/>
SENDER=ÒSensorsÓ/> <DataFlow LABEL=Òconfiguration dataÓ
</DataSource> RECEIVER=Òdisplay msgs & statusÓ
<DataDestination NAME=ÒControl Panel DisplayÓ> SENDER=Òconfiguration infÓ/>
<DataFlow LABEL=Òdisplay informationÓ> <DataFlow LABEL=Òa/d msgÓ
35
Solution (XML)
RECEIVER=Òmonitor sensorsÓ
</Function>
SENDER=Òconfiguration inf.Ó/>
<Function NAME=Òprocess passwordÓ>
</StoredData>
<DataFlow LABEL=ÒpasswordÓ
<Function NAME=Òinteract with userÓ>
RECEIVER=Òinteract with userÓ
<DataFlow LABEL=ÒpasswordÓ
SENDER=Òprocess passwordÓ/>
RECEIVER=Òprocess passwordÓ
</Function>
SENDER=Òinteract with userÓ/>
<Function NAME=Òactivate/deac. systemÓ>
<DataFlow LABEL=Òstart stopÓ
<DataFlow LABEL=Òstart stopÓ
RECEIVER=Òactivate/deac. systemÓ
RECEIVER=Òactivate/deac. systemÓ
SENDER=Òinteract with userÓ/>
SENDER=Òinteract with userÓ/>
<DataFlow LABEL=Òconfigure requestÓ
<DataFlow LABEL=Òa/d msgÓ
RECEIVER=Òconfigure systemÓ
RECEIVER=Òdisplay msgs and statusÓ
SENDER=Òinteract with userÓ/>
SENDER=Òactivate/deac. systemÓ/>
</Function>
</Function>
<Function NAME=Òconfigure systemÓ>
...
<DataFlow LABEL=Òconfigure requestÓ
</Level1>
RECEIVER=Òconfigure systemÓ
</Level>
SENDER=Òinteract with userÓ/>
</DFD>
<DataFlow LABEL=Òconfiguration dataÓ
RECEIVER=Òconfiguration inf.Ó
SENDER=Òconfigure systemÓ/>
36
1
XML and Related Technologies
XPointer
XLink
XSL
XML
XML-QL DOM
XML-Data Namespace
37
XLink W3C
Working Draft
1
XLink
Characteristics:
39
XLink Terminology
¥ Linking element: An XML element that asserts the existence
and describes the characteristics of a link.
2
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.
<A xlink:type=ÒSIMPLEÓ
xlink:href=Òwww.html#root()/id(ÒexpÓ)Ó <A HREF=Òwww.html#exampleÓ>
...> W3C </A>
W3C <\A> 42
2
Goals of XLink
¥ Be usable over the Internet
¥ Be feasible to implement
¥ Be designed quickly
44
2
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Ó?> root( )
... Model
<beg in> <Model>
... .
.
<!-- link to XML document--> .
<D xlink:type=ÒSIMPLEÓ <\Model>
TaggedValue Package
. . . > <\D>
...
<!-- link to GIF g raphic--> Tag Value
<G xlink:type=ÒSIMPLEÓ
. . .> <\G> CollaborationDiagram
...
<\beg in>
Collaboration ... 45
Simple Link
<!ELEMENT xlink:simple ANY>
<!ATTLIST xlink:simple
href CDATA #REQUIRED
role CDATA #IMPLIED
title CDATA #IMPLIED
show (new|parsed|replace) ÒreplaceÓ
actuate (user|auto) ÒuserÓ>
2
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
2
Extended Link (Cont.)
<!ELEMENT xlink:arc ANY>
<!ELEMENT xlink:locator ANY> <!ATTLIST xlink:arc
<!ATTLIST xlink:locator from IDREF #REQUIRED
id ID #REQUIRED to IDREF #REQUIRED
href CDATA #REQUIRED show (new|parsed|replace) ÒreplacedÓ
role CDATA #IMPLIED actuate (user|auto) ÒuserÓ >
title CDATA #IMPLIED >
Instance: Meeting
... 50
2
Extended Link Group
<!ELEMENT xlink:group (xlink:document*)>
<!ATTLIST xlink:group
steps CDATA #IMPLIED>
Hub
Document
51
</xlink:group>
descr4.
xml
52
2
XPointer
XPointer allows you to target a given element by number, name, type, or
relation to other elements in the document.
URL
HREF = Òhttp://www.cs.ucl.ac.ul/~Staff/a.zisman/uml.xml#
root()/child::Package[position()=1]/child::ClassDiagram[position()=1]
XPointer
53
basis
LocationPath: axis-name :: node-test[predicate]*
(/ axis-name :: node-test[predicate]*)*
54
2
XPointer (Location Path - Cont.)
Absolute axes: Relative axes:
a) root( ) - / a) ancestor
b) origin( ) b) ancestor-or-self
c) id( ) c) attribute
d) here( ) d) child
e) unique( ) e) descendant
f) descendant-or-self
g) following
h) following-sibling
i) parent
j) preceding
k) preceding-sibling
l) self
55
a) * a) position ( ) = integer
b) node( ) (<, >, !=, >=, <=)
c) text( ) b) position( ) = last( )
d) comment( ) c) Count(Location Path)
e) processing-instruction( ) d) attribute::attr_name
56
2
Examples
<?xml version=Ò1.0Ó?>
<!DOCTYPE Model SYSTEM ÒUML.dtdÓ>
<Model> root( )
<TaggedValue>
<Tag>Title<Value>Create Meeting Collaboration Diagram
</Value></Tag>
<Tag>Author<Value>Peter John</Value></Tag>
</TaggedValue> child::TaggedValue/child::Tag[positi
<Package NAME=ÒCreate MeetingÓ>
<CollaborationDiagram> on( )=2]/child::Value[position( )=1]
<Collaboration NAME=ÒCreate MeetingÓ>
<Instance CLASS=ÒMeeting OrganiserÓ />
<Instance CLASS=ÒOrganiser WindowÓ />
<Instance CLASS=ÒOrganiserÓ />
<Instance CLASS=ÒMeetingÓ /> descendant::Instance[position( )=3]
<Instance CLASS=ÒDateÓ />
<Message TYPE=ÒsyncÓ
SENDER=ÒMeeting OrganiserÓ
RECEIVER=ÒOrganiser WindowÓ>
<Label SEQUENCE_EX=Ò1Ó descendant::Message[attribute::
MESSAGE_NAME=Òselect create me etingÓ/> SENDER=ÒMeeting OrganiserÓ]
</Meesage>
...
</Collaboration>
</CollaborationDiagram> origin( )/parent::*
</Package>
</Model>
57
XPointer (Cont.)
Axes:
(selects the position before the letter ÒiÓ in the second occurrence of
the string ÒMeeting OrganiserÓ)
58
2
Goals of XPointer
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 a) root( );
Diagram</Value></Tag> b) origin( )/child::Package/
<Tag>Date<Value>10/09/99</Value></Tag> child::ClassDiagram/
</TaggedValue>
child::Class[position()=1]/
<Package NAME=ÒBusinessEntitiesÓ>
<ClassDiagram>
child::Attribute[position()=2);
<Class NAME=ÒMeetingÓ> c) id(Òattribute7Ó);
<Attribute NAME="status" d) origin( )/parent::*;
ID="attribute6" e) range::/descendant::Attribute
TYPE="String"> </Attribute> [position( )=1],/descendant::
<Attribute NAME="name" Attribute[position( )=2];
ID="attribute7" f) /descendant::Value[position( )=2];
TYPE="String"> </Attribute>
</Class></ClassDiagram> </Package></Model>
60
3
Solution
<Model>
<TaggedValue>
<Tag>Title<Value>Business Entities Class
Diagram</Value></Tag> a) root( );
<Tag>Date<Value>10/09/99</Value></Tag> b) origin( )/child::Package/
</TaggedValue> child::ClassDiagram/
<Package NAME=ÒBusinessEntitiesÓ> child::Class[position()=1]/
<ClassDiagram> child::Attribute[position()=2);
<Class NAME=ÒMeetingÓ> c) id(Òattribute7Ó);
<Attribute NAME="status"
d) origin( )/parent::*;
ID="attribute6"
TYPE="String"> </Attribute>
e) range::/descendant::Attribute
<Attribute NAME="name" [position( )=1],/descendant::
ID="attribute7" Attribute[position( )=2];
TYPE="String"> </Attribute> f) /descendant::Value[position()=2];
</Class></ClassDiagram> </Package></Model>
61
XSL
XSL - eXtensible Style Language Development Timeline
W3C XSL
Working Draft
Based on ISO/IEC 10179 Document
Style Semantics and Specification W3C XSL
Version 1.0
Language (DSSSL)
W3C XSL
Proposal
Based on W3CÕs Cascading Style
Sheet (CSS) Language 1997 1998 1999
. Aug Aug Apr
3
XSL Processor
XSL
XML Stylesheet
Processor
Presentation
Document
Tree Formatter
Transform. Form.
XSL XSLT Objects
stylesheet
63
XSL (Cont)
Rule
Pattern
Template
3
XSL (Cont.)
Tree Construction Rules (Template Rules)
Examples
XML:
<Tag gedValue>
<Tag>Title<Value>Create Meeting Collaboration Diagram</Value></Tag>
<Tag>Author<Value>Peter John</Value></Tag>
</Tag gedValue>
3
Examples
XML:
<Tag gedValue>
<Tag>Title<Value>Create Meeting Collaboration Diagram</Value></Tag>
<Tag>Author<Value>Peter John</Value></Tag>
</Tag gedValue>
Other Examples
XML:
<xsl:stylesheet
<ClassDiagram><Class>Meeting xmlns:xsl=Òhttp://www.w3.org/XSL/Transform/1.0Ó>
<Attribute>status</Attribute> <xsl:template match=ÒClassDiagramÓ>
<Attribute>name</Attribute> <DIV style=Òfont-weight:bold; color:blueÓ>
<Method>add</Method> <xsl:apply-templates select=ÒMethodÓ/>
<Method>remove</Method> </DIV>
</Class></ClassDiagram> </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
3
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.
Solution
a)
<xsl:template match=ÒTaggedValueÓ>
<DIV style=Òfont-weight:bold; color:redÓ>
<xsl:apply-templates/>
</DIV>
</xsl:template>
b) d)
<xsl:template match=ÒInstanceÓ> <xsl:template match=ÒMessageÓ>
<xsl:apply-templates select=ÒInstanceÓ> <DIV style=Òcolor:yellowÓ>
<xsl:sort select=ÒInstanceÓ/> <xsl:apply-templates select=ÒLabelÓ>
< /xsl:apply-templates> </DIV>
</xsl:template> </xsl:template>
c)
<xsl:template match=ÒMessageÓ>
<DIV style=Òfont-size:20pt; color:greenÓ>
<xsl:apply-templates/>
</DIV>
</xsl:template> 70
3
Document Object Model (DOM)
¥ DOM is an application programming interface (API) for
documents, i.e. HTML and XML documents.
71
DOM (Cont.)
DOM Level2 Development Timeline
W3C Working Draft
DOM Level1
W3C Recommen.
3
DOM (Cont.)
<Model> CollaborationDiagram
<CollaborationDiagram>
<Instance>
Parser
<Name>Org aniser</Name> Instance Instance
<Message>Sent</Message>
</Instance>
Name Message Name Message
<Instance>
<Name>Meeting </Name>
<Message>Receive</Messag e>
</Instance> Sent Meeting Receiver
Organiser
</CollaborationDiagram>
</Model>
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.
74
3
DOM (Cont.)
¥ Level 2:
> 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
Namespace
Development Timeline
W3C
It is a collection of names, identified
Recommend. by a URI, which are used in XML
W3C documents for qualifying names used
Working Draft as element types and attribute names.
Sept Jan
1998 1999
Motivation:
3
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.
3
XML-Data (Example)
UML.xml
<?xml version=Ò1.0Ó?>
<?xml:namespace name=Òhttp://data.org/Ó
UML.dtd as=ÒdtÓ/?>
<!ELEMENT Model (Package+)>
<dt:schema>
<!ELEMENT Package (#PCDATA)>
<elementType id=ÒPackageÓ>
<string/>
</elementType>
<elementType id=ÒModelÓ>
UML.xml <element type=Ò#PackageÓ
occurs=ÒONEORMOREÓ/>
<?xml version=Ò1.0Ó?> </elementType>
<!DOCTYPE Model SYSTEM UML.dtd> </dt:schema>
<Model>
<Package>Collaboration Diagram</Package> <Model>
<Package>Class Diagram</Package> <Package>Collaboration Diagram</Package>
<Package>StateChart Diagram</Packag e> <Package>Class Diagram</Package>
</Model> <Package>StateChart Diagram</Package>
</Model>
79
XML-QL
Development Timeline
Who?
XML-QL W3C AT&T Labs
Working Draft
University of Pensilvania
1998
Aug
Data extraction
Data transformation XML-QL
Data integration 80
4
XML-QL (Cont.)
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>
<!ELEMENT publisher</result>
(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
<author> Dbs: The
$a </author>
<book year=Ò1995Ó> Third Manifesto</title> </book> in Òbib.xmlÓ
<title>An Introduction to DB Syst</title>
</result> . CONSTRUCT <result> <author> $a </>
<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>
</book> </bib> 82
4
XML-QL (Examples)
<!ELEMENT book (author+, title, publisher)> <!ELEMENT person (lastname, firstname, address?,
<!ATTLIST book year CDATA> phone?, publicationtitle*)
<!ELEMENT article (author+, title, year?,
(short|long))>
<!ATTLIST article type CDATA)>
<!ELEMENT publisher (name, address)>
<!ELEMENT author (firstname?, lastname)>
83
¥ Information interchange
¥ Consistency Management
¥ Document templates
4
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 XML
Documents Translated
Documents
Translated
86
4
Generation of Specialised Mark-up Lgs.
87
Document Templates
- User requirements documents;
- User Manual;
4
Multiple Document Views
XSL
Document XSL
XSL
89
Graphical View
UML
Model IE 5
Unisys
exporter
90
4
Exercise/Solution
Other Software Engineering applications ?
91
Final Remarks
¥ XML is a data description language, subset of SGML;
92
4
References
Books:
References (Cont.)
URLs:
1) List of Books
http://www.able-consulting.com/books_xml.htm
3) Software
http://www.xmlsoftware.com/
94