Navigation in UML class diagrams and XML schemas












- Slides: 12

Navigation in UML class diagrams and XML schemas Karl Lieberherr UBS AG Northeastern University

Overview • Translation from UML cds to XML schemas • Navigation through XML documents (and object structures): Structure-shy traversal pattern – DJ library: email exchange with Mike Mannion

Comparison • XML schema – defines • language • structure of objects (documents) • UML class diagram – defines • structure of objects – summarizes program • all classes – interfaces

Processing of Objects • XML • UML – XSLT, JSP – programs (Java etc. ) • Document Object Model – provides a standard set of objects for representing XML documents • Fine grained model: one element - one class, JDOM • SAX – programs (Java etc. )

What brings XML? • Agreement at syntax level – several proposals to write schemas – useful to have unified, simple approach to define mark-up languages • Still need agreement at semantic level – hard data integration problems not eliminated

Commonality Generate a visitor library from class graph for copying, displaying, printing, checking, comparing and tracing of objects. XML schemas structure of objects, Java processing UML class diagrams

What can OO designers learn from XML? • It is useful to separate the structure of your design from the implementation – E. g. , XSLT descriptions are distinct from schemas • It is useful to view an OO design as a grammar that defines application specific objects

What are the basic elements of XML? • Sequence – <!ELEMENT Compound (Op , Exp )> • Disjunction – <!ELEMENT Exp (Simple | Compound )> • Repetition – <!ELEMENT Author (Person , Publication* )>

What are the basic elements of UML class diagrams? • Sequence - Concrete Classes – Compound = (op Op , arg 1 Exp , arg 2 Exp ) • Disjunction - Abstract Classes – Exp = (Simple | Compound ) • Repetition - Collection classes – Author = (Person , Publication* )

Avoid duplication! • We should define a systematic process to generate XML schemas from UML class diagrams • Has many benefits: – more flexible – easier to maintain

How do we have to write UML class diagrams? • To make the translation easy (and to improve the UML class diagram) – Classes are partitioned into abstract classes and concrete classes. Abstract classes have at least one subclass. – Follow the Abstract Super Class rule (ASR). That means that all super classes should be abstract.

UML Cd to XML Schema The translation algorithm roughly proceeds as follows: • Flatten the UML class diagram, i. e. , push all parts of abstract classes down to concrete classes. Replace undirected associations by two directed associations. Follow the ordering of parts and the ordering policy. – Concrete classes are translated into a schema element A of the form (B 1, B 2, B 3, . . . ). – Abstract classes are translated into a schema element of the form A (B 1 | B 2 | B 3 |. . . ). – An optional part B is represented as B? . A repeated part B is represented as B+ or B*.