130 likes | 445 Vues
UML class diagrams and XML schemas. Karl Lieberherr UBS AG Northeastern University. Overview. Translation from UML cds to XML schemas Other standards beyond XML: Structure-shy object pattern Navigation through XML documents (and object structures): Structure-shy traversal pattern.
E N D
UML class diagramsand XML schemas Karl Lieberherr UBS AG Northeastern University
Overview • Translation from UML cds to XML schemas • Other standards beyond XML: Structure-shy object pattern • Navigation through XML documents (and object structures): Structure-shy traversal pattern
XML schema defines language structure of objects (documents) UML class diagram defines structure of objects summarizes program all classes interfaces Comparison
XML 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 SAX UML programs (Java etc.) Processing of Objects
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 UML class diagrams structure of objects, Java processing
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 , 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 , arg1 Exp , arg2 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 superclasses 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 (B1, B2, B3, ...). • Abstract classes are translated into a schema element of the form A (B1 | B2 | B3 | ...). • An optional part B is represented as B?. A repeated part B is represented as B+ or B*.