There are situations where it would be desirable to restrict the values of a datatype when it appears in a profile. This is a proposal to use XML Schema constraining facets to define such restrictions.
Background
It is current practice to restrict allowed values of an association or enumeration attribute in a profile. In an OWL representation, these are the ObjectProperty definitions.
In contrast, the values of an ordinary attribute are defined by the schema (the CIM) and are not restricted in profiles. In OWL, these are the DatatypeProperty definitions.
OWL does not provide a language for datatype restrictions but XML Schema does and those concepts can be borrowed for profile definitions.
Use Cases
The the following general use cases are envisaged:
- Restricting a string value to a set of allowed values or to a given form.
- Limiting the length or precision of a value.
- Limiting the range of a numeric value.
The following specific scenarios illustrate the use cases:
Organisation.currentStatusis defined in UML with type String. WhenSchedulingCoordinatorinherits this definition and it is then used in a profile, it would be appropriate to restrictcurrentStatusto an enumeration of strings specific to that application.IdentifiedObject.descriptionis defined in the UML with type String. When used in the CPSM profile its length is restricted to 256 characters.StaticVarCompensator.capacitiveRatingis defined asReactance, which is defined a float in the UML. When used in the CPSM profile its value should be greater than 0.
Solution
The proposed solution is to allow a profile definition to include XML Schema constraining facets which are defined section 4.3 of the W3C XML Schema Part 2 Recommendation: http://www.w3.org/TR/xmlschema-2/#rf-facets
Constraining Facets
The constraining facets proposed for use in profiles and their XML Schema Part 2 sections are:
4.3.1 length
4.3.2 minLength
4.3.3 maxLength
4.3.4 pattern
4.3.5 enumeration
4.3.7 maxInclusive
4.3.8 maxExclusive
4.3.9 minExclusive
4.3.10 minInclusive
4.3.11 totalDigits
4.3.12 fractionDigits
Facet Annotations in OWL Profiles
When a profile is represented as OWL, a constraining facet, except enumeration, will appear as an Annotation Property on the associated profile Datatype definition. The Annotation Property will have the same name and namespace as the XML Schema element and accept the same values as the value attribute of that element.
A fragment of an OWL profile definition illustrates this for the minInclusive facet:
<owl:Restriction>
<owl:onProperty resource="&cim;IdentifiedObject.description"/>
<owl:allValuesFrom>
<rdfs:Datatype>
<rdfs:subClassOf resource="&cim;Reactance"/>
<xsd:minInclusive>0.0</xsd:minInclusive>
</rdfs:Datatype>
</allValuesFrom>
</owl:Restriction>
Enumeration Facet in OWL Profiles
An enumeration facet will be represented by an OWL oneOf definition.
<owl:Restriction>
<owl:onProperty resource="&cim;Organisation.currentStatus"/>
<owl:allValuesFrom>
<owl:DataRange>
<rdfs:subClassOf resource="&xsd;string"/>
<owl:oneOf>
<rdf:List>
<rdf:first>AllowedStatusValue1</rdf:first>
<rdf:rest>
...
<rdf:rest>
</rdf:List>
</owl:oneOf>
</rdfs:DataRange>
</allValuesFrom>
</owl:Restriction>
Shared Definitions
It is anticipated that a datatype definition could be used in more than one place within in a profile or throughout a family of related profiles. Therefore it will be possible to name datatype definitions in profiles.
Notes
- The whiteSpace facet (4.3.6) is not proposed for use in profiles.
- Not all facets apply to all datatypes. The details are given here: http://www.w3.org/TR/xmlschema-2/#defn-coss
CIMTool Implementation
- CIMTool will provide an editor for datatype restrictions based on XML schema constraining facets. For each facet except enumeration, CIMTool will prove a data entry box and allow a valid value to be entered.
- For enumeration facets, CIMTool will provide an editor that allows enumeration values to be created and deleted.
- The facet editor will observe the XML Schema constraints on facet types and only enable applicable facets for the given datatype.
- It will be possible to give names to the resulting datatype definitions so that they can be used in more than one place in a profile. They will then appear at the top level of the profile outline.
- It will be possible to create a library of datatype definitions and place it in the project schema where it will be available to all profiles in the project.
- It will be possible to interpret a UML class with a specific stereotype as an enumerated datatype definition.
- The constraining facets will be emitted as part of the generated XML schema for the
Rationale and Alternatives
Use of XML Schema Datatypes
The solution assumes that profile datatypes are defined in terms of the XML Schema recommendation. This is the current practice for OWL profile definitions and it is clearly an acceptable choice if the ultimate implementation will use RDF or XML Schema.
When some other implementation technology is used, a mapping will be required between its native datatypes those in the profile.
In the latter case, the XML Schema recommendation is a good candidate for a canonical set of datatypes. The datatypes are well defined, widely used, and do not depend on any other aspects of XML technology.
Use of a Rule Language
An alternative to the proposed solution would be to introduce a rule language. Such a language has been discussed among CIM tool implementers as a more powerful alternative to schema languages for describing restrictions on profiles. Several validation tools use a bespoke rule language internally.
However, the proposed solution continues the schema-oriented approach and merely adds definitions. This has the advantage of simplicity and consistency with current profile definitions.
This style of definition can also be used for a variety purposes in addition to validation, for example, to generate a database schema or an XML schema. The facet definitions can in the profile be trivially converted to rules for validation.