Please note : This help page is for an older version of Enteprise Archtiect. The latest help can be found here.

Topic
Prev Next

Schema Compositions

A schema composition refers to a restricted set of elements taken from the model that together describe a unique entity that has no equivalent in the model. Commonly, schema compositions are used to generate schema files such as XSD files. In contrast, model compositions are used to configure the material as the basis of a subset 'transform' - for example when creating a NIEM model subset.

Define Schema Content

These steps walk you through the basic procedure of composing types in a Schema profile and show how you can restrict the content of elements to meet the message requirements.

Add Classes

Drag the required Class elements from the Project Browser into the 'Classes' panel. As you add a Class:

  • Its ancestry is listed in the 'Inheritance' section in the middle panel
  • Its attributes are listed under the 'Inheritance' section, with a blank checkbox against each one; Association and Aggregation entries are named according to the role name on the connector
  • Its model structure path is shown underneath the 'Classes' panel

Select Properties

Any time you select a Class in the 'Classes' list, its attributes and model ancestry are listed in the 'Attributes' list. Select the checkbox against each attribute to define the elements of this type. When chosen, the attribute's type is added automatically to the schema, appearing in the 'Classes' list and the 'Schema' panel to the right.

When an attribute is unchecked, the type is not automatically removed. Types can be removed using the Class context menu. It is worth noting that each time a Class is selected, all references to the Class are displayed in the status panel, enabling you to quickly review any Class usage.

Inheritance

If you favor or foresee a need for inheritance in the schema you are preparing, it would make sense to begin the composition with ancestors first, then re-use these as child Classes are added. The method is not set in stone. You can switch from an inheritance model to an aggregated composition or vice-versa at any time. Here is a brief description of the provision of inheritance in the Schema Composer.

The Schema Composer offers flexibility in dealing with inheritance. For example, you can choose to aggregate selected attributes from the Class and its parent, while choosing to inherit the grandparent. However, when you choose to use inheritance, you choose to inherit the restricted form of that type as well. When an ancestor is selected in this list, the generated XML schema would show an extension element identifying this ancestor. Only one ancestor can be selected.

Click on the Update button to validate and save your schema profile.

If there are any problems with the profile, they are identified in the status panel in the top right of the screen.

Redefined Types

One of the common issues with schema composition is the requirement to be able to vary a type description to meet various demands of the instances a schema describes. A vehicle, for example, might be described by its brand, model and price by an element of a Truck type, but by its year, model and color by an element of a Sedan type. The issue is that we might only have one actual Vehicle Class at our disposal. To address this the Schema Composer allows you to clone the Vehicle Class and give it another name. You can then assign this version of Vehicle to any property that has Vehicle as its type. The type created is only available within the domain of the schema - the model is untouched.

To create a new definition of a type, select the Class first in the 'Classes' list, then right-click on it and choose the 'Redefine Type' option. Enter a unique name for this type and press the Enter key. You can then define or restrict this type independently, the way you would for any Class.

Root elements

When the schema is generated, a single top level element representing the message is generated. The body or elements of this top level element are the Classes marked as root elements. The cardinality of these root elements can be adjusted. To mark a Class as a root element or restrict its cardinality, right-click on the Class in the list and use these context menu options.

  • Set element as root - root elements form the body of the top level element representing the message / profile
  • Edit root element cardinality - set the minimum and maximum number of instances
  • Remove root attribute from element - removes the root mark from the Class
  • Remove the selected element - delete the selected element from the schema
  • Find in Project Browser - locate and highlight the element in the Project Browser

Property Restrictions

In the 'Attributes' list, right-click on a selected property and use the context menu to add, edit or remove a property restriction. Use this feature to:

  • Modify the property cardinality
  • Redefine the type of the property
  • Enable and limit the choices available for this property
  • Mark a property to be emitted as an inline element definition
  • Mark a property to be emitted 'By Reference'

Cardinality

The cardinality of a property can be further restricted from its model counterpart, but it cannot be less restrictive. The cardinality can be changed for any root element Class and any Class property.

Type redefinition

When a Class is redefined within the Schema Composer it creates a new type. The new type is a clone of the original, but has a name that is unique to the schema. It is then possible to assign properties of other types to specify this redefined 'version'. A Payment enumeration type, for example, might be redefined as a CardPayment to better suit a restriction or serve users of the schema.

Choices

Where generalizations of a property type are present in the schema, those subtypes will be available as choice elements in the 'Restriction' dialog.

Inline Elements

A property type will be emitted as an inline definition when this box is checked.

By Reference

A property will take the 'By reference' form when emitted in the schema. The 'By reference' form emits an inline complexType that defines a single attribute named 'ref' of type 'string'.

Property Constraints - Facets

Facets are supported in the Schema Composer Generic Profile. The sources of facets are the Tagged Values on a property. Tagged Values are recognized as facets if they name a constraining facet from the XML Schema specification. JSON validation keywords are also recognized.

Constraining Facets from XML Schema:

  • length
  • minLength
  • maxLength
  • pattern
  • enumeration
  • whiteSpace
  • maxInclusive
  • maxExclusive
  • minExclusive
  • minInclusive
  • totalDigits
  • fractionDigits

Validation keywords in JSON:

- number and integer

  • multipleof
  • minimum
  • maximum
  • exclusiveMinimum
  • exclusiveMaximum

- strings

  • minLength
  • maxLength
  • pattern

- arrays

  • minItems
  • maxItems
  • uniqueItems