The default mapping rules described in this article can be used to generate a complete XML schema from any UML class diagram. This might be a preexisting application model that now must be deployed within an XML web services architecture, or a new XML vocabulary model intended as a B2B data interchange standard. In either case, the default schema provides a usable first iteration that can be used immediately in an initial application deployment, although it may require refinement to meet other architectural and design requirements.
The first article in this series presented a process flow for schema design that emphasized the distinction between designing for data-oriented applications versus text-oriented applications. The default mapping rules are often sufficient for data-oriented applications. In fact, these defaults are aligned with the OMG's XML Metadata Interchange (XMI) version 2.0 specification for using XML as a model interchange format. This approach is also well aligned with the OMG's new initiative for Model Driven Architecture (MDA).
Text-oriented schemasand any other schema that might be authored by humans and used as content for HTML portalsoften must be refined to simplify the XML document structure. For example, many schema designers eliminate the wrapper elements corresponding to an association role name (but this also prevents use of the XSD <all> model group). This refinement and many others can be specified in a vocabulary model by setting a new default parameter for one UML package, which then applies to all of its contained classes.
We saw two examples of UML stereotypes in this article, which were used to indicate a specialized use of a UML class. More generally, these stereotypes and their associated property values are part of a UML profile for XML Schemas that I initially developed as part of my book on modeling XML applications. The third article in this series provides additional examples of using other stereotypes to customize the generated schema. I will also include description of a web-based tool we have developed that implements the complete UML profile for schema design and transforms any UML class model to either a W3C XML Schema or to an OASIS RELAX NG grammar.