Modeling XSD

You can model XML schemas at two levels, using UML Class diagrams that:

  • Have no XML schema-specific implementation details, to be generated directly by Enterprise Architect's Schema Generator; the generator applies a set of default mappings to convert the abstract model Package to a W3C XML Schema (XSD) file
  • Are refined with XML schema-specific definitions using the XML Schema pages of the Diagram Toolbox, which provides the structures of the UML profile for XSD

Model an XML Schema

Step

Action

See also

1

In the Project Browser, create the top-level project structure you need (Model and Views), and click on the appropriate View.

Models Views

2

Click on the New Package icon in the Project Browser toolbar. The 'New Model Package' dialog displays.

Project Browser Toolbar

3

In the 'Name' field type the name of the new Package, and select the 'Create diagram' radio button.

Click on the OK button. The 'New Diagram' dialog displays.

Add a Package

4

In the 'Name' field type the name of the new diagram.

In the 'Select From' panel select 'UML Structural', and in the 'Diagram Types' panel select 'Class'.

Add New Diagrams

5

Click on the OK button. In the Project Browser, double-click on the icon next to the new diagram's name; the diagram opens in the Diagram View, with the Class pages displaying in the Diagram Toolbox.

At this point you can either:

  • Create a Class diagram using the Class toolbox icons, or
  • Create a tailored XML Schema diagram using the XML Schema pages of the Diagram Toolbox (continue to step 6)

Class Toolbox Diagram Toolbox XML from Abstract Class Models

6

Click on the 'More tools' option in the Toolbox and select 'Extended | XML Schema' to display the 'XML Schema' Toolbox pages.

XML Schema Toolbox

7

Click on the 'Schema' icon from the Toolbox and drag it into the Class diagram.

The 'XSD schema Properties' dialog displays.

Complete this dialog, and click on the OK button.

The 'New Diagram' dialog displays.

Schema Package

8

Again, in the 'Name' field type the name of the new diagram.

In the 'Select From' panel select 'UML Structural', and in the 'Diagram Types' panel select 'Class'.

Click on the OK button.

9

An XSDschema stereotyped Package is created in the Project Browser and on the diagram, with a child Class diagram.

Double-click on the Package on the diagram to open the child Class diagram, and use the constructs from the XML Schema Toolbox to model the XML Schema.

Complex Type Global Attribute Local Element Global Element Any Model Group Any Attribute Local Attribute Group Attribute Group Union Simple Type Enumeration

Notes

  • The UML attributes of the Classes map directly to XML elements or attributes
  • If you have modeled your XSD Schema as a straight Class diagram, you can define and generate schema from it using the Schema Composer
  • Classes in an XML Schema model have no methods since there is no meaningful correspondence between Class methods and XSD constructs
  • Modeling Restrictions - these XML Schema constructs cannot be modeled in Enterprise Architect:
         -  appinfo
         -  field
         -  key
         -  keyref
         -  notation
         -  redefine
         -  selector
         -  substitutionGroup
         -  unique

Learn more