Redefining XSD schema components

You can extend or modify an XSD schema by replacing the definitions of the components in the model that represents the schema, and running the UML-to-XSD transformation to create the redefining XSD schema. A redefining schema modifies or extends another schema. Schema redefinition is useful to seed a new XSD schema from an existing XSD schema.

About this task

You can also import an XSD file into your workspace, which enables you to visualize the file into a UML model. You can redefine the schema components in the model, and run the transformation to create the redefining schema.

The schema redefine mechanism enables you to specify new definitions for schema components, thus providing more flexibility than the include mechanism, which does not enable you specify new definitions for schema components.

You can redefine the following types of components:
  • Simple types
  • Complex types
  • Named model groups
  • Attribute groups
When you redefine a schema component, you replace the original definition of the component, and references to the original component.

You must have an XSD schema in your workspace before you can redefine the schema. You must also apply the XSD transformation profile to your model, and your model must contain at least one simple or complex type, and one namespace.

The following procedure describes how to redefine a complex type named Class1 that is in a UML package named Package1. This complex type contains one attribute, named attribute1, that is of type String. In this example, you create a new package named Package2, which contains the schema that redefines Class1.

Procedure

  1. Create a package in the source UML model. For example, create a package called Package2.
  2. Apply the «schema» stereotype to the new package.
  3. Set the target namespace attribute in the «schema» stereotype as equal to the target namespace of the schema that you want to redefine.

    This image shows the Stereotypes page of the Properties view.

    Note: You can also set the target namespace property of the transformation configuration as equal to the namespace of the original schema.
  4. Create a complex type that is the same type that you want to redefine. For example, if you want to redefine Class1 in Package1, you must create a class named Class1 in Package2, and apply the «complexType» stereotype to the new version of Class1:

    This image shows a UML model, in the Modeling perspective, that contains a package with a complex type.

  5. Create a generalization relationship from the redefining type to the redefined type. For example, create a generalization relationship from Class1 in Package2 to Class1 in Package1.

    This image shows a generalization relationship in which Class1 in Package1 is the parent, and Class1 in Package2 is the child.

  6. Apply the «redefine» stereotype to the generalization relationship.

    This image shows a generalization relationship with the redefine stereotype applied; Class1 in Package1 is the parent, and Class1 in Package2 is the child.

  7. Redefine the type that you created. For example, you can change the definition of the type, or add attributes to the type. In this example, in Class1 that is located in Package2, redefine attribute1 by changing its type to UnlimitedNatural. You can also add a new attribute, named attribute2, that is of type String.

    This image shows the redefining type and the redefined type. The redefining type contains an UnlimitedNatural named attribute1, and a new String named attribute2.

  8. Click File > Save.
  9. Edit the UML-to-XSD transformation configuration. Specify the redefining schema as the source of the transformation. In this example, specify Package2 as source of the transformation.
  10. Click File > Save.
  11. Run the UML-to-XSD transformation.

What to do next

The transformation generates a redefining schema file in the target project that you specify in the transformation configuration. The redefining schema file contains the redefined schema components. The schemaLocation attribute specifies the name of the redefined schema. The following image displays the redefining schema that the transformation generates.

This image shows the XSD file that the transformation generates. Attribute1 transforms into type long, and attribute2 transforms into type string.


Feedback