[1.1] the combination of XMI and UML to develop business models in enterprise applications

Source: Internet
Author: User
Tags xslt

As XML becomes mainstream, people are increasingly concerned about XML applications.Program. More specifically, many organizations want to combine the design of XML applications with their other application designs. Using a common method-or at least a set of common tools-is worth considering.

For XML, the design activities mainly focus on data modeling. In fact, XML is a markup language that only involves information organizations. This is different from other languages. For example, Java simultaneously processes data modeling (class inheritance) and Data Operations (methods ).

Use XMLNew series of ColumnsArticleWe will discuss the use of UML modeling tools to design XML applications, such as IBM Rational Rose and XSLT. This is the first article. In this introductory article, I will discuss the basic principles of Data Modeling and introduce the technologies that will be used in the next three articles.

Data Modeling

Concise Oxford Dictionary(Oxford University Press, 2001) there are at least seven definitions of the term "model. For this series of articles, the following definition is the most appropriate: "The System and Its Simplified (typically mathematical) Description to help with computing and prediction ." This definition has three keywords:Simplified,DescriptionAndHelp.

According to this definition, the model is about the systemDescription. This argument is very important. The model is not the system itself, but a formal system.Indicates. In XML, the system consists of documents encoded according to a specific vocabulary.

The second aspect of this definition is that the model isSimplified. It is not as complex or rich as the modeled system. Many systems are designed to solve complex problems, so they are inherently complex. For example, take a look at a complicated vocabulary like docbook: it is designed to publish technical data and documents (the Linux documents are published using docnook ). Because technical books and documents are complex, docbook is also complex.

In addition, the amount of information that people can simultaneously process is limited. Most people like (or need) to break it down into smaller, easier-to-manage problems when solving a complex problem. The model is created to meet this need. A model simplifies a complex system by exposing only some specific aspects of the system.

The last keyword in the definition isHelp. A model is not created out of thin air, but serves very specific goals. It is just a tool that is more effective in achieving specific goals. The goal is never to build a model, but to process a system.

The operation features of the target are closely related to the simplification described above.SimplifiedThis means you need to select the components that need to be included in the system and those that should be put aside. Choose to be controlled by the model's target, such as the calculation and prediction that are trying to help.

Simplified and modeled

Regardless of the model, the actual system is simplified. Similarly, it is impossible to solve a complex system unless it is divided into smaller and simpler components. In practice, a model is often insufficient. A complex system can be represented by multiple models ranging from simple to complex.

The modeling process can start with a system sketch on a legendary napkin (a whiteboard or a cut of paper is a good alternative. The first model is usually very rough and ignores most aspects of the system. Only a few aspects that the designer considers important may be complicated or key features of the system.

This rough model will be refined into one or more elaborate and complex models. Each iteration introduces more components from the actual system until all relevant aspects are introduced into the model. In the end, you will reach the implementation stage of the data model and define all aspects that can be managed by the system.

For XML, implement an XML schema. Other options include DTD, Relax NG, or WSDL. Although there are technical differences between these implementations, however, in this series of articles, I will regard them as variants of the XML schema.

There are two different opinions on the relationship between the model and the XML model in the industry. Some authors draw a clear line between the design model and the XML model. The design model is usually a UML model or an entity-link model, which is considered abstract, the XML mode is considered to contain a lot of implementation details. This difference helps to clearly divide modeling activities and implementation activities. Modeling is usually done by business analysts, and implementation is the responsibility of technical personnel. This division of work imitates the division of labor between analysts and developers in typical application development.

Although I think this division is reasonable for programming, it cannot be guaranteed that it also applies to XML modeling-which leads me to the second view of this relationship. The XML mode is a document model. You will see in the next article that it is not significantly different from a good UML model in terms of complexity. There is no doubt that the XML model contains a large amount of technical information, but the UML model that describes the same amount of technical information is not uncommon. Therefore, I tend to regard the XML schema as part of the continuous unity of the model from the high-level model to the underlying model.

If the auxiliary modeling tool is installed-I will introduce it in other articles in this series-It is especially appropriate to regard the mode as just another model.

Simplified and graphic

The most effective simplified method used in modeling is graphics. Compared with a long string of complex commands, people find that the brain is easier to process graphics. Most modeling methods are built on Visual languages, such as UML, object-relationship diagram, or flowchart.

There are two different ideas about what makes the best visual language specific to the XML mode. One method is to use a language specific to XML, and the other is to use a more general modeling language. XML spy or turboxml (see references) these products use custom Graphic Tree Representation to process XML patterns. A visual presentation may be similar to Figure 1:

Figure 1. Visualized XML structure

Therefore, standard modeling languages such as UML can also be used. Figure 2 is a UML model similar to Figure 1:

Figure 2. UML for modeling XML

Each method has its own advantages and disadvantages. The symbols used for XML are exactly the same as the XML structure, which can easily mark the XML order, XML selection, elements, and attributes. You can also define all technical information in a simple and natural way. Until recently, many XML application designers have recommended this method because it is simple and effective.

The price is that modeling and tools often cannot be well integrated with other development work. Although this method is still applicable to small XML projects, it is not very scalable. This method is also difficult to use for large projects that combine XML, Java, Web Services, and SQL, because others in the team may use UML.

There are two factors that make UML the most suitable for medium and large projects:

    1. UML is applicable to Java, C ++, Python, PHP, SQL, Web Services, and almost any other subordinate technology. Its uniformity reduces the need for training (a language for everyone) and makes it easier to share the design within the team.
    2. A uml diagram can display more or less information as needed, so you can use the same tool to prepare multiple complex layers of models.

The main disadvantage of UML is that it is unfriendly to the underlying aspects of modeling. For example, it is easy to sort a group of elements in the tree, but many techniques are required in UML.

UML and XML

I plan to discuss this topic in a few more articles. Now, It is enough to point out that multiple mappings can be established between the XML mode and the UML model. UML supports multiple diagrams, including use case diagram, package diagram, sequence diagram, and activity diagram.

Class charts are most suitable for Object-Oriented data models.

Figure 3 shows a very simple UML Model for person. It includes two classes, one representing the basic data ("person") of person, and the other representing the "Address" of person )". A rectangle represents a Class symbol and is divided into three parts: Class Name, attribute, and method. Because we need to model data rather than behavior, we can ignore the method section.

Figure 3. UML Model of person

The relationships between classes are represented by links. In the model, the contact is expressed in a straight line. You can use a connector to differentiate a straight line. For example, the solid diamond in Figure 3 indicates a composite relationship -- in other words, the address class instance can only exist in the context of the person class.

Note: ing a UML structure to XML can have many different options. The UML attribute is a good example. In UML, attributes are fields attached to the class. There is only one rational ing method in Java: the attribute is changed to a class variable. On the contrary, attributes in XML can be mapped into sub-elements or real XML attributes. I will continue to discuss this topic in future articles.

ModeDerived

You can try different methods to draw a UML Model:

    • It can be painted on paper or whiteboard.
    • You can use Vector Plotting tools such as smartdraw or omnigraffle.
    • You can use modeling tools such as IBM Rational Rose.

In addition to the simplest model, you may prefer to use modeling tools. At first glance, the modeling tool is just a beautification drawing tool, but it actually provides more functions. Modeling tools can understand models and provide a lot of help to designers. For example, when adding a class to a graph, it can automatically draw these relationships.

Automatic Derivation

As mentioned above, I think the XML schema is only a special presentation of a detailed model. Therefore, it is important to automatically derive an XML schema from a UML model.

Looking at the UML model, it is time-consuming and error-prone to encode it into the XML mode. You may ignore some elements or attributes, and it is easy to make a wrong relationship. Fortunately, as long as a one-to-one ing is established between the UML structure and the XML schema statements, this process is easily automated.

You can find many tools used to automatically derive models from models, including:

    • Eclipse modeling framework (EMF), Formerly known as ibm xmi Toolkit
    • EMF includesCodeThe builder derives the XML schema from the UML model.
    • IBM Rational RoseThe script language rosescript can process the UML Model and save it as the XML mode.
    • VelocityA project from Apache Jakarta is a template engine used to generate code from a UML model.
    • HypermodelIs a graphical tool used to generate xml from UML.
    • Poseidon for UMLWith the built-in code generation function, it is easy to customize the XML mode for generating.
    • CodagenIs a UML tool that provides complete code generation functions.

This series of articles recommends a solution based on XSLT and XML Metadata Exchange (XMI. XMI is a standard format that can be used to derive XML from a UML model. It was originally designed to export/import models between different tools. Because XML is to be processed here, XSLT can be used for processing.

According to my research, XMI and XSLT are advantageous for the following reasons:

    • XMI is an industrial standard that is supported by all major modeling tools. Any model built on XMI can use these modeling tools.
    • XSLT is a language that effectively expresses conversion. It has many structures that make it ideal for this task.
    • XSLT can be used on all mainstream platforms, so there is a lot of room for choice.
    • The same technology can easily be extended to WSDL and other XML languages.

I have another standard that may not matter to you. I am mainly engaged in e-commerce, so the processing model is a collaborative project of multiple companies. Different companies may use different tools. Therefore, a private product cannot be used across the entire team in collaboration projects. Because XMI is an industrial standard, solutions built on XMI can work well across the entire team.

Figure 4 illustrates this process. I have written one or two style sheets to derive the XML schema from XMI documents (such as UML models.

Figure 4. derived Mode

From XML mode to XMI. This style sheet is useful when dealing with existing patterns that do not use UML modeling.

Conclusion

This is the first article in a series of new articles. I reviewed the principles behind document modeling and discussed how to create a model XML schema in UML. More importantly, I introduced a tool for Automatically Generating XML patterns from UML models. The XMI and XSLT style sheets can be automatically generated. The next article will introduce an example of this style.

References

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.