Sign In/My Account | View Cart  
advertisement


Listen Print Discuss

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.

Comment on this articleGot questions about UML and XML, or any experiences using them together?
(* You must be a
member of XML.com to use this feature.)
Comment on this Article


Titles Only Titles Only Newest First
  • UML to W3C XML Schema
    2009-06-23 19:49:23 JuergT [Reply]

    Thank you David for the good article.


    FYI: We implemented a slightly different solution for the same objective: MXV: Model-driven XML Vocabulary.


    MXV marries up
    - a model-driven architecture (MDA)
    - UML and W3C XML Schema modelling
    - OASIS UBL NDR 2.0 (the OASIS XML design standard)
    - OASIS UBL NDR-like XML Component Libraries (generated from the UML model)
    - Modelling tool to generate models and codes


    MXV is suitable for data-oriented XML, where a single enterprise UML model drives many prescriptive W3C XML document schemas. The modelling tool enforces the model's formal validity, UML model complicance and XML design standard compliance.


    MXV has been successfully implemented at the New Zealand Education Sector.


    For more details, visit http://www.d-m-s.co.nz/serv_xmlschema.htm


    We welcome your comments!


    Juerg Tschumperlin
    Data Management Solutions
    Wellington, New Zealand

  • uml to xml schemas
    2005-12-05 19:24:15 xmlnewcomer [Reply]

    Hi


    We are working on a MDA architecture based project but new to xml and xmi and hypermodel etc. We are generating xml schemas from the uml models created in rational rose.


    I have two questions:


    1) How are composition, associations and inheritance (class hierarchies) of uml models represented in xml schemas; When to use type substitution vs substitution groups in xml schemas to represent the above.
    In a domain model, consider a class hierarchy with an abstract super class X, that has two or more concrete subclasses:
    a) A different class Y has an attribute whose type is X.
    b) A different class Z has association(s) with more than one concrete classes of X.
    How the above cases are represented in xml schema; is it by type substitution or substitution groups?


    2) Currently the auto generated xml schemas represent the class hierarchy of X as type substitution and at the same time has reference to substitution groups(as it is true by default in xml schemas) but expects the instance document to be user modified to enter type for xsi:type. But we thought that if substitution groups are used, manual changes to instance documents can be avoided and that the xml content is more readable. So is there a way to tweak the xml schema auto generators to produce substitution groups related code instead of type substitutions in xml schemas.


    Your input is highly appreciated as it is very crucial for my work progress.


    Thanks in advance.




  • UML - XMI Schema
    2003-06-24 23:15:51 Dhana Sekar Sugunan [Reply]

    I want to save the UML analysis model into XMI Schema, so as to work in Rational Rose. Is this possible. If yes How ?

  • UML to XSD code generator
    2003-04-26 13:58:24 Anthony Mowers [Reply]

    Hi All,


    I am one of the lead developers for AndroMDA, http://www.andromda.org, which is an open source tool that support MDA (model driven architecture).


    I am starting work on a andromda cartridge to transform UML to XSD. If there is interest in this then please visit the AndroMDA site and let us know.


    amowers

  • Using Inheritance in XML structure diagrams in Together UML tool
    2002-11-06 09:37:41 pradeep gummi [Reply]

    Sir,
    I am designing XML schema using UML tool Together 6.0. I have drawn the XML structure diagram so as to automatically generate an XML schema.
    Now my question is how can i show inheritance between two elements.
    say for example, there is a catalogItem element. and i would like to inherit its properties to Product element and to Service element.
    The XML structure diagrams do not support this. It only supports the associations.
    Any suggestions
    thanks
    pradeep


  • Mapping Executive Requirements
    2001-08-24 07:26:16 Tim Johnson [Reply]

    The UML-driven approach to planning and developing XML architectures provides an excellent communications conduit between business decision makers and the technical development staff. I find Dave's approach extremely useful in working with clients from Fortune 100 to entrepreneurs.


    Tim Johnson, Associate Director, Gartner Consulting

  • Where to put XML DTDs in UML models?
    2001-08-23 11:25:50 Rusty Williamson [Reply]

    Hello,


    How would XML DTD’s (or XML Schema) be documented or referenced within UML models and/or within the Rational Unified Process structure of project artifacts? We use Rose which allows the linking of documents within th model structure. Would the XML DTD represent communication protocols between actors and use cases?


    Thanks!
    Rusty


  • Question on representing XML trasformations in UML?
    2001-08-23 11:21:54 Rusty Williamson [Reply]

    Hi!


    I am seeking any information on representing XML documents and DTD in UML models. Especially anything on representing XSLT/XML translations in UML diagrams or associated specifications.


    Thanks!
    Rusty




    • Question on representing XML trasformations in UML?
      2001-09-04 15:56:03 Reza BFar [Reply]

      Rusty:


      I have been doing research on this with two other guys for about a year now... Will be releasing the results in a book this next year. You're welcome to e-mail me individually if you'd like and I'll send you whatever answers I can.


      Thanks,
      Reza
      rbfar@hotmail.com