XML.com: XML From the Inside Out
oreilly.comSafari Bookshelf.Conferences.

advertisement

Modeling XML Vocabularies with UML: Part I
by Dave Carlson | Pages: 1, 2

Conceptual Models of XML Vocabulary

Related Articles

Using XML Schema

W3C XML Schema Datatypes Reference

Guide to UML Class Diagrams

Design Patterns in XML Applications

Now that you understand the basics of UML class diagrams, let's apply them to a larger XML vocabulary design. We'll work with the purchase order vocabulary that is used in the XML Schema Part 0: Primer document. That example is first introduced in section 2.1 and then elaborated throughout the W3C specification. The model defined in this article adds international addresses and multi-schema support as explained in section 4.1 of the W3C specification. If you are new to XML Schema, I suggest that you review the Primer after reading this article, then compare our UML design process in these three articles with the same purchase order vocabulary in the schema specification.

The purchase order vocabulary is defined in two modules, corresponding to the core PurchaseOrder type and a separate reusable Address module specification. In UML, these modules are called packages. The first package specification is shown as a UML class diagram in Figure 3. The PurchaseOrder class has two attributes and three associations that define its structure. Several of these attributes include a multiplicity specification of [0..1], which means that those attribute values are optional, either 0 or 1 occurrences.

The Address class plays both a shipTo and billTo role in association with a PurchaseOrder. (Hint: these might become shipTo and billTo child elements in the schema.) The multiplicity of 1 means that a PurchaseOrder must have exactly one of each address role. On the Item class, notice that a quantity is of type QuantityType. This type is defined as another class in the UML model. In the same diagram, QuantityType is defined as a subclass of positiveInteger, which is annotated as coming from the XSD_Datatypes package in this UML model. Thus, a quantity is a specialized kind of positive integer.

Both QuantityType and SKU are user-defined data-types, and both include an attribute that further restricts their intended usage. The pattern and maxExclusive attributes are assigned a value that is used at later stages of the design process to guide XML Schema generation. Finally, the class name of Address is shown in italics, which means that it is an abstract class that is not intended to be used directly. As we'll see next, Address is further specified in another UML class diagram.

Figure 3: Conceptual model of purchase order vocabulary

The Address package specification, shown in Figure 4, follows a similar logic. In this diagram, both USAddress and UKAddress are specialized subtypes of Address. In ordinary common object-oriented usage, this means that both of these subtypes inherit the three attributes defined in their superclass. The exportCode attribute of UKAddress is assigned an initial value of 1.

Figure 4: Modularized Address schema component

Design Models of XML Schemas

Now that we've created a conceptual model of our XML vocabulary's content and gained approval from all business and technical stakeholders, what next? As hinted in previous sections, there are numerous alternatives available when the mapping this model to XML schema constructs. Are the UML attributes and association ends mapped to XML attributes or elements? How is UML's generalization of classes and datatypes mapped to schema definitions? How does this mapping differ when the target schema language is changed from W3C XML Schema to RELAX NG? What about DTDs?

If you refer back to the schema development process illustrated in Figure 1, the next design task depends on whether this vocabulary is data or text-oriented. Because the purchase order vocabulary is data-oriented, most of the remaining design decisions relate to deployment issues: developer conventions for using XML attributes or child elements, data type alignment with other sources and destinations of data to be exchanged using this vocabulary, and anticipated future requirements for extending this vocabulary or combining it with other XML namespaces.

If this were a text-oriented application, then content managers and authors would have further input on design choices. For example, most human authors prefer XML document structures that avoid excessive use of container elements to group related content elements, whereas this is common practice in data-oriented applications. Also, the order of elements in a document is often more important to human authors and readers than it is to data parsing.

The focus of the present article has been capturing the conceptual model of a vocabulary, which is the logical first step in the development process. The next article presents a list of design choices and alternative approaches for mapping UML to W3C XML Schema. The UML model presented in this first article will be refined to reflect the design choices made by the authors of the W3C's XML Schema Primer, where this example originated. For our purposes, these authors are the stakeholders of system requirements.

The third article will introduce a UML profile for XML schemas that allows all detailed design choices to be added to the model definition and then used to generate a complete schema automatically. The result is a UML model that is used to generate a W3C XML Schema, which can successfully validate XML document instances copied from the Schema Primer specification. Along the way, I'll introduce a web tool used to generate schemas from UML and reverse engineer schemas into UML.

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:

References

[1] David Carlson. Modeling XML Applications with UML: Practical E-Business Applications. Boston: Addison-Wesley, 2001. This book follows a full system development life-cycle based on a product catalog application design.

[2] Martin Fowler, Kendall Scott. UML Distilled, Second Edition. Boston: Addison-Wesley, 2000.

[3] Object Management Group (OMG) UML resources, http://www.omg.org/technology/uml

  1. Your e-business vocabulary defines an agreement or contract with all related business parties. Plan its specification accordingly. Get input on requirements of all key stakeholders using the visual models of UML to improve communication.
  2. Define all known terms, associations, and constraints and document their purpose, source, and usage. Do not restrict your specifications to the limited expressiveness of DTDs or even to the expanded W3C XML Schema language. Using UML, you can capture a complete specification and then transform it to one or more XML schema languages. Documentation notes added to the UML model can be automatically transformed to annotations in the XML schema.
  3. Create a common UML model that drives both the XML schema definition and other non-XML system components. Many systems use XML in a subset of their components, but the analysis must be done holistically.


1 to 10 of 10
  1. fiwedding
    2010-06-18 20:01:39 fiwedding
  2. UML to W3C XML Schema
    2009-06-23 19:49:23 JuergT
  3. uml to xml schemas
    2005-12-05 19:24:15 xmlnewcomer
  4. UML - XMI Schema
    2003-06-24 23:15:51 Dhana Sekar Sugunan
  5. UML to XSD code generator
    2003-04-26 13:58:24 Anthony Mowers
  6. Using Inheritance in XML structure diagrams in Together UML tool
    2002-11-06 09:37:41 pradeep gummi
  7. test
    2002-08-12 03:09:11 sammy yang
  8. Mapping Executive Requirements
    2001-08-24 07:26:16 Tim Johnson
  9. Where to put XML DTDs in UML models?
    2001-08-23 11:25:50 Rusty Williamson
  10. Question on representing XML trasformations in UML?
    2001-08-23 11:21:54 Rusty Williamson
1 to 10 of 10