Section 4.5 CSN rules for a domain definition


Where an attribute has a primitive type as its domain, the user may wish to limit the possible values for the attribute to a set of finite values. This may be done with a restricted clause in the new class definition. Typically the restricted clause lists the valid values for an attribute, with the values separated by vertical lines, as has been previously discussed.

An alternative involves a domain definition which is very similar to an enumeration in style. Where there are a large number of options or where it is desired to make the overall structure more modular (as with an enumeration), many users may prefer to use a domain definition.

Consider the following restricted clause dealing with two attributes defined in a class or superclass. Their domains as originally given are String and Integer, respectively. Here the possible values are further restricted.

restricted: attributeA: stringA | stringB | stringN attributeB: 10 | 11 | 12

Another way of handling this would be with the following clause:

restricted: attributeA: DomainA::Schema1 attributeB: DomainB::Schema1

In this case the permitted values would be included in the definitions of DomainA and DomainB. If attributeA and attributeB are defined in the current class definition and not inherited from a superclass, then a third alternative would be to avoid the restricted clause and instead to include the two user defined domains directly in the attributes clause:

attributes: attributeA DomainA::Schema1 attributeB DomainB::Schema1

The discussion below is in CSN and is intended to serve as a template for defining such domains. It will be followed by the definition of DomainA and DomainB, as discussed above.

// A domain definition always begins with an open, angled bracket, followed by the word Domain.

subclass: DomainName::Schema1

// A meaningful name for the domain is provided, along with the name of the external // schema to which it belongs. These names must follow the same naming conventions as // discussed earler under class and enumeration definitions.

baseType: String

// The type of primitive is given for baseType. String is used here, as this is the most // common situation, but other possible values include any of the types of Integer or Real // supported by SAIF.

validValues: stringA stringB stringN

// Any finite number of string values may be listed, provided the baseType is String. If the // baseType were some type of Integer or Real, the possible numeric values would be given, // without double quotes around each value.

comments: Comments may be given explaining the values or providing other useful information.

// Comments typically provide textual definitions of the values. However, tables and graphics // may also be included, as with classes and enumerations. (Similarly, the discussion on comments // in the earlier section on class definitions also applies here.)

>

// The definition of a domain ends with a closing, angled bracket.

DomainA and DomainB, as described at the beginning of this section, are defined below.


Links to the SAIF 3.1 Specification document and the complete SAIF class list