Modeling XML Vocabularies with UML: Part III
by Dave Carlson
|
Pages: 1, 2, 3
Creating XML Schemas with hyperModel
To support an iterative modeling process, we have developed a web application that creates XML schemas from UML models. A key enabling technology is the XML Metadata Interchange (XMI) specification from the OMG that defines a standard for serializing UML models as XML documents. Many UML tools now support this standard import-export format, and some use it as their native file format. hyperModel accepts any XMI 1.0 file containing a UML 1.3 model and transforms it into either HTML or several alternative XML schema languages.
I created the purchase order model in both Rational Rose (www.rational.com) and the open source ArgoUML tools. XMI files can be exported from Rational Rose by using the add-in developed by Unisys and available for download from Rational Software. ArgoUML uses XMI as its native file format. When the purchase order model from either tool is uploaded to hyperModel, the HTML view shown in Figure 2 is displayed in a Web browser.
![]() Figure 2: An HTML view of UML in hyperModel |
hyperModel uses XSLT stylesheets to transform the XMI files into other representations, including HTML and XSD schemas. It allows individual classes or entire packages to be transformed and displayed in a browser. When the output transformation is changed to XSD, then the schema representation of the selected class is displayed, as shown in Figure 3. Selecting a UML package, e.g. PO or Address, will display the complete schema for a module in our vocabulary design.
![]() Figure 3: Transformation of a UML class to XML Schema |
We have found this application to be a tremendous help in learning about and refining an object-oriented approach to the analysis and design of XML schemas. We also use this tool as an integral part of our training classes on modeling XML vocabularies. Even if you don't use UML as a primary design tool in your project, experimenting with schema models and alternative UML profile customizations is a productive way to understand XML schema structures and design guidelines.
Schema Modularity and Reuse
One of the benefits gained by using UML as part of our XML development process is that it enables a thoughtful approach to modular, maintainable, reusable application components. In the first two parts of this series, the PurchaseOrder and Address elements were specified in two separate diagrams, implying reusable submodels. UML includes package and namespace structures for making these modules explicit and also specifying dependencies between them.
Figure 4 illustrates a UML package diagram of this purchase order model. A package, shown as a file folder in a diagram, defines a separate namespace for all model elements within it, including additional subpackages. These UML packages are a very natural counterpart to XML namespaces. A dashed line arrow between two packages indicates that one is dependent on the other.
When used in a schema definition, each package produces a separate schema file. The implementation of dependencies varies among alternative schema languages. For DTDs they might become external entity references. For the W3C XML Schema, these package dependencies create either <include> or <import> elements, based on whether or not the target namespaces of related packages are equal. A dependency is shown from the PO package to the XSD_Datatypes package, but an import element is not created because this datatype library is inherently available as part of the XML Schema language.
![]() Figure 4: UML package diagram showing schema integration |
This object-oriented approach to XML schema design facilitates modular
reuse, just as one would do when using languages such as Java or C++. A new
vocabulary module could import our current Address package and define a new
subclass of Address or further specialize USAddress with a new subclass. For
example, BusinessUSAddress might be created with a new mailstop
attribute. When transformed to XML Schema, this new subtype would
automatically become available as valid content for the shipTo
or billTo elements in a purchaseOrder. This is
conceptually similar to the way one would create a new Java subclass within
a new application-specific package; other libraries are reused by importing,
and possibly extending, their classes.
Tips for Success
In order to help you when applying these ideas to your own e-business projects, I offer the following tips for success:
- Plan for reuse; shortsighted design leads to short-term use. Many of the same principles developed over the past decade for object-oriented and component-based reuse can be applied to XML applications. New web services standards, such as WSDL and WSFL, add the behavioral interface of reusable modules, complementing the structure defined by schema information models.
- Follow a consistent set of design guidelines. Whenever possible, set model-level default properties in the UML profile and avoid overriding the mappings for individual classes, attributes, and associations.
- Choose UML tools that provide complete support for the XMI model interchange standard. It often not practical or desirable to be locked into one design tool. In particular, code generation and reverse engineering tools can be built around the XMI document format that leverages the strength and flexibility of general-purpose XML tools.


