The UML to XML Schema transformation helps create an equivalent XML schema model from a given UML model. Basically, this transformation creates a copy of a source UML model, then applies the necessary stereotypes according to the XML schema modeling rules.

Type mapping

This type map stores mapping between primitive UML data types and primitive XML Schema data types.

UML to XML schema type map.
UML to XML schema type map (Continued).

Transformation results

After the UML models have been transformed to XML schema models, you will see the following results.

  • For each class in the transformation destination set, the «XSDcomplexType» stereotype is applied, unless this class is derived from simple XML type (one of the basic types, or type, stereotyped with XSDsimpleType). In that case, an «XSDsimpleType» stereotype is applied. There are conditions when the «XSDcomplexType» and «XSDsimpleType» stereotypes are used, listed in the table below:
ConditionResult
The class is derived from another class, stereotyped as «XSDcomplexType».The «XSDcomplexContent» stereotype is applied on this class with «XSDextension» on the corresponding generalization relationship.
The class is derived from another class, stereotyped as «XSDsimpleType».The «XSDrestriction» stereotype is applied on the corresponding generalization relationship.
The class is not derived from anything, and has attributes with the XSDelement tag.The «XSDcomplexContent» stereotype is applied on this class.
The class is not derived from anything, and has no attributes with the XSDelement tag.No «XXXXContent» stereotype is applied on this class - the class has an empty content.
The UML datatypes in the transformation source set are transformed into the classes with the «XSDsimpleType» stereotype (unless after the type map this class appears to be derived from a class with the «XSDcomplexType» stereotype).The «XSDcomplexType» stereotype is used.
Each attribute of the class is not of the simple XML type (that is, one of the basic types, or type, stereotyped with the «XSDsimpleType») or has a multiplicity more than 1.The «XSDelement» stereotype is applied.
  • For each composition association, two linking classes are stereotyped as XML schema types. The stereotype on the association end is applied the same as the rules for attributes.
  • Enumerations in the UML model are transformed into the enumerations in the XML Schema model. Classes with the «XSDsimpleType» stereotype are derived by restriction from the XML string type, where all the elements of the original enumeration are converted into the attributes with an «XSDenumeration» stereotype.
  • For each package in the transformation set, the «XSDnamespace» stereotype is applied.
  • In each package, one additional class for the XML schema is created. The name of the schema class is constructed by taking the name of the package and then appending the .xsd to it (e.g. if the package in the source model set is named "user", name the schema class "user.xsd" in the destination package).
  • The targetNamespace value is added to the schema class with the name of its parent (e.g. if the schema is placed in the "http://magicdraw.com/User" package, the targetNamespace=" http://magicdraw.com/User" is set on the schema class).
  • Schema class and the namespaces http://www.w3c.org/2001/XMLSchema [XML Schema profile] and its target namespace are linked using the xmlns relationships. The names of these links are: the same as the target namespace for the link to the target namespace; and "xs" for the XML Schema namespace.
  • Class diagrams are transformed into XML Schema diagrams.
  • The model elements that have no meaning in the XML schemas are discarded. This includes (without limitation) behavioral features of classes, interfaces, actors, use cases, states, activities, objects, messages, stereotypes and tag definitions.
  • There are additional properties to choose for UML to XML Schema transformation in the Model Transformation Wizard. For more information about the wizard, see Model Transformation Wizard in MagicDraw User Guide.


Model transformation wizard for UML to XML schema transformation with Specify transformation details.


Option nameTypeDescription

Default Compositor

Combo box

Possible choices: XSDall, XSDchoice, XSDsequence

Determines element grouping in complex types of XML Schema.

Default: XSDall

Default Attribute Kind

Combo box

Determines which attribute kind (XSDelement or XSDattribute UML) the attribute will be mapped to.

Default: XSDelement