Experiments With XMI Based Transformations of Software Models

10 downloads 11564 Views 25KB Size Report
different software/database paradigms both in forward and reverse engineering. .... of database applications benefits from business rules being encoded as part ...
Experiments With XMI Based Transformations of Software Models Birgit Demuth Heinrich Hussmann

Sven Obermaier sd&m AG software design & management 81737 Muenchen, Germany

Department of Computer Science Dresden University of Technology 01062 Dresden, Germany {demuth,hussmann}@inf.tu-dresden.de

[email protected]

Abstract The eXtensible Markup Language (XML) and its related technologies provide a promising tool for the implementation of transformations of UML models, not only for research prototypes but also for the interaction of different commercial CASE tools. We report on our experiments with XML query and transformation languages in the context of object-oriented software development. Especially we use the XML Metadata Interchange Format (XMI) as a tool for the transformation of object-oriented models. We outline XMI based scenarios in the forward and reverse engineering of different applications. As an example, we show how XMI and a standardized XML query/transformation language such as XSLT can be used for the generation of SQL database schemas based on UML models, and for design recovery from legacy code.

1 Introduction Since the Unified Modeling Language (UML) is rapidly becoming an accepted standard for software modeling, technologies for mechanical transformations of UML models become increasingly important. There are many different applications for transformation of UML models, e.g. for bridging between different subsets or variants of the language, for code generation in forward engineering, or for capturing model information in backwards engineering. In this paper, we report on experiments on a general technology applicable for all these purposes. The XML Metadata Interchange Format (XMI) was proposed in response to an Object Management Group (OMG) Request for a Stream-based Model Interchange format. The main purpose of XMI is to enable easy interchange of data and metadata between UML modeling tools and between tools and metadata repositories in distributed heterogeneous environments. XMI integrates three key industry standards: (1) XML - eXtensible Markup Language, a W3C standard [23] that provides the universal format for structured documents and data on the Web; (2) UML - Unified Modeling Language, the OMG modeling standard [4], [19] for specification, visualization, construction, and documentation of object-oriented systems; (3) MOF - Meta Object Facility, a CORBA-compliant architecture for defining and sharing semantically rich metadata in distributed heterogeneous environments which is used as OMG modeling and metadata repository standard [18]. Our intention is to use XMI for bridging the gap between different CASE tools and different software/database paradigms both in forward and reverse engineering. We present

1

our ideas and some of our experimental results with the XMI based scenarios in the forward and reverse engineering of different applications. The paper is organized as follows. In section 2, we outline the implementation of XMI based transformations using XSLT. Then we present two XMI based scenarios, one in the forward engineering of relational database applications and the other one in the reverse engineering of legacy code. Section 3 summarizes the results of our experiments.

2 XMI Based Scenarios in the Software Development XMI is the basic language that helps us to perform transformations among UML models as well as between UML models and other notations (especially code and other modelling languages). We evaluated the following scenarios: •

UML based code generation as a forward engineering secenario (UML-to-Any-Code transformation)



Generation of UML models for legacy code as a reverse engineering scenario (AnyCode-to-UML transformation)

Both XMI based scenarios are based on code transformations as well as metadata repository support. What we therefore need are •

a handy code generation framework for XMI documents. In [16], different approaches to code generation are described .



facilities for easy access to metadata.

To realize XMI transformations it must be possible to get structured data out of the XMI documents. A promising approach is to use a standardized XML query or transformation language. We evaluated several such languages [6], [9] and chose the Extensible Stylesheet Language Transformations (XSLT) [24], [25] for the experiments described below. 2.1 Implementation of XMI based transformations using XSLT We decided to use XSLT for the implementation of XMI based transformations because XSLT and the related XML Path Language (XPath) [26] are particularly designed for transforming XML documents. XSLT is a simple and very powerful language to declare transformation rules. XPath opens a wide range of navigation functionality for XML documents as well as mathematical and string operations. One of the particularly interesting aspects of XSLT is that the language is itself defined as an XML application; so the scripts are XML files again. The basic architecture of our solution is shown in the following figure. program (translator) source (e.g. XMI)

import

rules in an easy to read language (XSLT)

XSLT processor import

export

destination documents (e.g. SQL statements)

Figure 1 – XSLT interpreter solution for code generation

2

The code generation process is not as fast as a solution directly based on the DOM API [22]1, but we achieve more flexibility. Since there is no conventional programming involved any more and all transformations are expressed within XML, it is relatively easy to maintain the transformators, e.g. for a new version of the metamodel. XSLT processors are available [1], [7], [14], as well as XML and XSLT editing tools (see [17] for a survey). 2.2 UML-to-Any-Code transformation One application of XMI in a forward engineering scenario is as follows: Given an XMI document produced by the export of an UML CASE tool, we want to transform it into another document of any kind (programming language, database language or XML/XMI again). The semantics of such a transformation can be described with a set of XSLT rules each consisting of an action, which contains information how the source (XMI tags) should be transformed into the target code, and a condition under which the action should execute. Our case study for an UML-to-Any-Code-Transformation was the generation of a SQL database schema from a UML class diagram [17]. Figure 2 gives a simple example for a UML class diagram to explain the idea. Person String name String birthday

Student boolean suspended String register

0..n member

1

University String name integer semesterFee

Figure 2 – Sample UML model According to the usual class-to-table mapping [3] we have to generate a relational database schema with three tables. The most important part of a relational database schema defined by SQL [15] are definition statements for the tables (CREATE TABLE) plus referential constraints for the mapping of class relationships (inserted by ALTER TABLE). CREATE TABLE Student (OID INTEGER PRIMARY KEY, suspended BOOLEAN, register VARCHAR(255), OID_University INTEGER NOT NULL); ALTER TABLE Student ADD CONSTRAINT FK_Student_University FOREIGN KEY OID_University REFERENCES University; ALTER TABLE Student ADD CONSTRAINT FK_Student_Person FOREIGN KEY OID REFERENCES Person;

1

The “DOM compiler” solution was evaluated in [17]. Herein we built a tool that generates from an XMI DTD a Java class structure for repositories (meta data models) with lightweight functions to navigate over the document information. The disadvantage of this technique is that the exchange of rules and the DTD is expensive.

3

Below we give an example for XSLT statements to perform this transformation. The rule has been simplified for better readability, for example instance methods and visibility of attributes are not shown and name conflict resolution is missing. The basic idea of the rule design is to have an XSLT rule that matches the XMI model element Foundation.Core.Class if it is a real class description and not only a reference. The first output of the rule can be the CREATE TABLE statement followed by the name of the table and the generation of a primary key mapping an object identifier (OID): CREATE TABLE (OID INTEGER PRIMARY KEY

Afterwards the attribute names and types can be generated in a similar way. Every class can be joined at one or more associations. An 1:N association can make it necessary to add an attribute to the table. N:M associations must be realized through an additional table. Then the CREATE TABLE statement can be completed. Furthermore, it must be tested whether constraints mapping associations and inheritance relationships must be added or not (ALTER TABLE statements). Besides referential constraints used to map class relationships to tables, the development of database applications benefits from business rules being encoded as part of the database schema, using assertions and triggers. The Object Constraint Language (OCL) [28] as integral part of the UML specification provides the facility to express business rules on UML model elements in a formal textual language. In [8], patterns for mapping of OCL constraints to SQL integrity constraints in form of assertions (CREATE ASSERTION) are given. We developed a modular OCL toolset [10][11] that also generates such SQL code. The OCL compiler has to check the types in the OCL constraint, that means it has to query the UML model for type information. This is an example for the above mentioned access to a metadata repository. We implemented it by a type information component of the OCL compiler based on XMI documents. We have realized a prototypical set of XSLT rules based on UML 1.1 following the ideas shown above. From our experiences, we estimate that a complete implementation of transformation rules for the UML DTD to SQL will cost approximately four to five weeks including rule and test case specification, documentation, realization, test and error correction. The result will have 1000 to 1500 lines of XSLT code and approximately 30 to 40 rules. Our experiments showed clearly that a language similar to XSLT but more specialized to the form of XMI documents would be helpful. Therefore, we designed a generic library of XSLT rules, which provides a framework for XMI transformators. Large parts of the framework can be generated automatically from an XMI DTD [2]. 2.3 Any-Code-to-UML transformation Besides the forward engineering approach from above, we also evaluated a new approach for object-oriented redesign of legacy code (Cobol et al). In [2], a MOF model has been defined which can be used as a metamodel for procedural languages like Cobol. We called the resulting XML-based language "Procedural Modeling Language (PML)". We

4

experimented in a case study with different XMI based transformations on the model level such as from Cobol to PML to UML. Classical reverse engineering algorithms can now be brought into the form of XSLT scripts. To achieve high productivity in the realization of model transformations we used the above-mentioned XSLT library for XMI. In this context, the technology of generating the XSLT library from a DTD pays back since the PML DTD is not a standard and may be updated quite frequently.

3 Summary Our experiments proved that XMI and related technologies like XSLT provide a practical way to experiment with UML model transformations (including other modeling languages and code). We showed practical applications in forward as well as in reverse engineering scenarios. We can benefit from the interoperability between different commercial tools that provide XMI export and import. Using XML and some additional XMI tools, we were able to build our own experimental transformation tools, which are completely independent of the underlying CASE platform.

Acknowledgements We thank Axel Grossmann and Ralf Wiebicke who, through their efforts, have contributed to the presented research results.

References [1]

Alphaworks, IBM, LotusXSL, http://alphaworks.ibm.com/formula/LotusXSL

[2]

Axel Grossmann, XMI für prozedurale Programmstrukturen und Transformation in UML, Diploma Thesis, Dresden University of Technology Dresden, 2000

[3]

Blaha, M., Premerlani, W., Object-Oriented Modeling and Design for Database Applications, Prentice Hall, 1998

[4]

Booch, G., Rumbaugh, J., Jacobson, I., The Unified Modeling Language User Guide, Addison-Wesley, 1999

[5]

Bruce, K., Whitenack, B., Crossing Chasms - A Pattern Language for Object-RDBMS Integration. Knowledge, Systems Corp., ftp://members.aol.com/kgb1001001/Chasms/chasms.pdf

[6]

Chawathe, S., Describing and Manipulating XML Data, in: Data Engineering, 22(1999), 3-9, IEEE Computer Society

[7]

Clark, J., XT, http://www.jclark.com/xml/xt.html

[8]

Demuth, B., Hussmann, H. Using UML/OCL Constraints for Relational Database Design, in: ’99 – The Unified Modeling Language, Second Int. Conference, Fort Collins, CO, USA, 1999, Proceedings, Springer, 1999

[9]

Deutsch, A. et al., Querying XML Data, in: Data Engineering, 22(1999)3, 10-18, IEEE Computer Society

[10] Dresden UML Toolset, http://www-st.inf.tu-dresden.de/UMLToolset, Dresden University of Technology [11] Hussmann, H., Demuth, B., Finger, F.: Modular Architecture for a Toolset Supporting OCL, in: 2000, Third Int. Conference, York, UK, October 2000, Proceedings, Springer 2000 [12] Graham, I., Quin, L., XML Specification Guide, John Wiley & Sons, New York, 1999

5

[13] Heiler, S., Lee, W.-Ch., Mitchell, G., Repository Support for Metadata-based Legacy Migration, in: Data Engineering, 22(1999)1, 37-42, IEEE Computer Society [14] Kay, M., Saxon, http://users.iclway.co.uk/mhkay/saxon/index.html [15] Melton, J., Simon, A., Understanding the New SQL:A Complete Guide, Morgan Kaufmann, 1993 [16] Obermaier, S., Entwicklung eines Frameworks für die Codegenerierung am Beispiel von SQL, Diploma Thesis, Dresden University of Technology Dresden, 2000 [17] Obermaier, S., Generic Meta Data Models, Technical Report, Dresden University of Technology Dresden, 1999 [18] OMG, Meta Object Facility (MOF 1.3) Specification (ad/99-09-04), http://www.omg.org [19] OMG, UML Specification v. 1.3 Draft, http://www.omg.org [20] OMG, XMI SMIF Revised Submission (ad/98-10-06), http://www.omg.org [22] W3C, Document Object Model Specification (DOM), http://www.w3.org [23] W3C, Extensible Markup Language (XML), http://www.w3.org [24] W3C, Extensible Stylesheet Language (XSL), http://www.w3.org [25] W3C, XSL Transformations (XSLT), http://www.w3.org [26] W3C, XML Path Language (XPath), http://www.w3.org [27] W3C, XML-QL: A Query Language for XML, http://www.w3.org [28] Warmer, J., Kleppe, A., The Object Constraint Language. Precise Modeling with UML, Addison- Wesley, 1999

6

Suggest Documents