UML-to-XSD transformations

In UML, you can create a visual representation of an Extensible Markup Language (XML) schema and then use the UML-to-XSD transformation to generate an XML Schema Definition (XSD) file.

Two UML-to-XSD transformations are available: UML-to-XSD and UML-to-XSD (Deprecated). The UML-to-XSD transformation replaces UML-to-XSD (Deprecated); no new features are planned for the UML-to-XSD (Deprecated) transformation.

The following features are included in the UML-to-XSD transformation, but not UML-to-XSD (Deprecated):
Note: Throughout the online help, the UML-to-XSD and UML-to-XSD (Deprecated) transformations are referred to simply as the "UML-to-XSD transformation." In cases where a specific transformation is indicated, the phrases "UML-to-XSD transformation only" or "UML to XSD (Deprecated) only" are used to distinguish the intended transformation.

XSD files

An XSD file is an instance of an XML schema that is written in the XML Schema language. An XSD file, or schema, describes the structure of an XML file. It also defines the elements and attributes that can be included in an XML schema, the relationships between the elements and attributes, as well as the constraints on the elements and attributes. You first model the structure of an XML schema by applying a set of UML-to-XSD mapping rules. You then apply the UML-to-XSD transformation to the model to generate an XSD file, which you can use to validate an XML file.

An XSD file is useful in the following situations:
  • To validate data by checking for items such as required tags
  • To generate a description of the structure of an XML file that you can use as a data content standard between teams
  • To generate system documentation by annotating the schema to provide additional information
  • To specify default values that an application can use if a given XML file does not specify all the values that an application requires
  • To identify the information that is specific to a given application and that the application uses to process an XML document

Guidelines for modeling an XML schema in UML

You can use UML to create a visual representation of an XML schema, and then you can run the UML-to-XSD transformation to generate an XSD file. A model can contain elements that represent XSD elements, as well as elements that are not related to XSD.

Use the following guidelines when you create UML models that represent XML schemas:

How the transformation transforms UML elements into XSD schema elements

The UML-to-XSD transformation uses a set of properties to determine how the transformation generates output from source model elements. You must define the value of properties in a UML-to-XSD transformation configuration. The transformation uses these property values to determine the following information:
  • The target namespace of the generated schema
  • The prefix for the target namespace of the generated schema
  • Whether to overwrite transformation output files without warning
  • How to transform nested classes
  • Whether to transform a class that does not have a stereotype or keyword
  • Whether to generate a schema for a package that does not have a stereotype or keyword
  • (UML-to-XSD transformation only) Whether to generate all the XSD files in "schema" folder or in a folder that follows the package name
  • (UML-to-XSD transformation only) Whether to generate all classes in the same package in one XSD file or each class in different XSD file

By default, the transformation generates a schema for each package and its contents that you select in the source model. You can specify whether the UML-to-XSD transformation generates a schema for packages that do not have the «schema» stereotype or schema keyword. The transformation does not generate a schema for a nested package.

By default, the transformation processes all classes contained in the packages that you select as the source of the transformation. You can specify whether the UML-to-XSD transformation processes classes that do not have a stereotype or keyword.

Valid sources for the UML-to-XSD transformation

The UML-to-XSD transformation generates XSD files from the following UML sources: You can select multiple valid elements as the source of the transformation.

Valid targets for the UML-to-XSD transformation

You can specify any project or folder in your workspace as the target for the output of the UML-to-XSD transformation.

Location of transformation output

The XSD file that the UML-to-XSD (Deprecated) transformation generates is stored in a directory, called schema, in the project that you specify as the target for the transformation output. The file that contains the schema has the same name as the package in the source model. The generated schema has .xsd as its file name extension. The transformation displays the generated schema in the Navigator view.

The location of the UML-to-XSD transformation output depends on the value set for the Target folder property. The additional options enable the output to be created in a package name or names of your choice and enable the creation of separate files for each data type to support IBM® WebSphere® Integration Developer projects.

UML elements that transform into elements of an XSD schema

You can model several XSD elements in UML. The transformation uses a set of mapping rules to determine how to generate XSD elements from their corresponding UML elements.

The following table lists how the UML-to-XSD transformation transforms UML model elements in XSD elements.

UML model element XSD schema element
Package Single namespace with a prefix
Class Types and reusable groups:
  • Attribute group, named model group, and substitution group
  • Complex type
  • Global element, attribute
  • Simple type
Enumeration Restriction of an XSD string simple type with enumeration facets that are equal to the UML enumeration literals
Note: This differs from a UML class with the «enumeration» stereotype from the UML-to-XSD transformation profile. A stereotyped UML class provides additional general XSD enumerations.
Properties of a class Attributes of an attribute group

Elements and attributes of a complex type

Elements and attributes of a named model group

Property with attribute stereotype Attribute of the complex type, if the property is a simple type and has a multiplicity of [0..1]; otherwise, converted into an element
Association (Aggregation) Child element of a contained element (complex type)
Generalization Derivation by extension of complex type

Integration with team support

The transformation provides integration functionality with IBM Rational® Team Concert, CVS, Rational ClearCase®, and Rational ClearCase LT version control systems, which enables you to automatically check out files or add new files. You must enable team capabilities to work with configuration management systems.


Feedback