Transformation of UML connectors

In this section are specified transformation rules for UML association, generalisation and dependency connectors. Table 1 provides an overview of the section coverage.

Table 1. Transformation rules overview for UML connectors
UML element Rules in core ontology layer Rules in data shape layer Rules in reasoning layer Rules in JSON-LD context layer

Association

Rule R.01

Rule R.02

Rule R.03

Association domain

Rule R.04

Association range

Rule R.06

Rule R.05

Rule R.07

Association multiplicity

Rule R.10

Rule R.08, Rule R.09

Rule R.11

Association asymmetry

Rule R.13

Rule R.12

Association inverse

Rule R.14

Dependency

Rule R.01

Rule R.02

Rule R.03

Dependency domain

Rule R.04

Dependency range

Rule R.16

Rule R.15

Rule R.07

Dependency multiplicity

Rule R.10

Rule R.08, Rule R.09

Rule R.11

Class generalisation

Rule R.17

Property generalisation

Rule R.18

Class equivalence

Rule R.19

Property equivalence

Rule R.20

Realisation

Rule R.21

Unidirectional association

A binary Association specifies a semantic relationship between two member ends represented by properties. Please note that in accordance with specification [uml2.5], the association end names are not obligatory. However, we adhere to the UML conventions , where specification of at one member ends, for unidirectional association, and two member ends, for bidirectional association, is mandatory. Moreover, provision of a connector (general) name is discouraged.

10
Figure 1. Visual representation of a UML unidirectional association (on the left) and an OWL property with cardinality restriction on domain class (on the right)
Rule R.01. Unidirectional association — in core ontology layer

Specify object property declaration axiom for the target end of the association/dependency.

Ideally, in the implementation, this rule would be combined with the relevant rules (those for the core ontology layer) in the Transformation of UML descriptors section, to provide labels and documentation for the property at the time of its creation.
Listing 1. Property declaration in Turtle syntax
:relationName a owl:ObjectProperty .
Listing 2. Property declaration in RDF/XML syntax
<owl:ObjectProperty rdf:about = "http://base.onto.uri/relationName">
</owl:ObjectProperty>
Rule R.02. Unidirectional association — in data shape layer

Specify PropertyShape declaration axiom for each association/dependency.

Ideally, in the implementation, this rule would be combined with the relevant rules (those for the data shape layer) in the Transformation of UML descriptors section, to provide labels and documentation for the property shape at the time of its creation.
For handling bidirectional associations refer to the Bidirectional association section.
Listing 3. PropertyShape declaration for associations in Turtle syntax
@prefix : <http://base.onto.uri/> .
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName
  sh:property shape:ClassName-relationName ;
.
shape:ClassName-relationName a sh:PropertyShape ;
  sh:path :relationName ;
.
Listing 4. PropertyShape declaration for associations in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName">
    <sh:property rdf:resource = "http://base.shape.uri/ClassName-relationName"/>
</rdf:Description>
<sh:PropertyShape rdf:about = "http://base.shape.uri/ClassName-relationName">
    <sh:path rdf:resource = "http://base.onto.uri/relationName"/>
</sh:PropertyShape>
Rule R.03. Association & dependency — in JSON-LD context layer

For each UML association/dependency, specify an object property by creating a property URI mapping with an absolute URI of a target end in a node object. Set the term definition as a top-level entry inside the class’s inner context object. For bidirectional connectors, additionally specify an extended term definition for the source end.

Listing 5. Association/dependency term mapping in JSON-LD syntax
"ClassName": {
 "@context": {
    "relatesTo": {
      "@id":"http://base.onto.uri/relatesTo"
    },
    "dependencyName": {
      "@id":"http://base.onto.uri/dependencyName"
    }
  }
}

Association source

Rule R.04. Association source — in reasoning layer

Specify object property domain for the target end of the association/dependency.

Listing 6. Domain specification in Turtle syntax
:relationName
  rdfs:domain :ClassName ;
.
Listing 7. Domain specification in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/relationName">
    <rdfs:domain rdf:resource = "http://base.onto.uri/ClassName"/>
</rdf:Description>
Listing 8. Object property domain specification for reused relations in Turtle syntax
:relationName
  rdfs:domain [
    rdf:type owl:Class ;
    owl:unionOf (
      :ClassName1
      :ClassName2
    )
  ]
.
Listing 9. Object property domain specification for reused relations in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/relationName">
    <rdfs:domain>
        <owl:Class>
            <owl:unionOf rdf:parseType="Collection">
                <rdf:Description rdf:about="http://base.onto.uri/ClassName1"/>
                <rdf:Description rdf:about="http://base.onto.uri/ClassName2"/>
            </owl:unionOf>
        </owl:Class>
    </rdfs:domain>
</rdf:Description>

Association target

Rule R.05. Association target — in reasoning layer

Specify object property range for the target end of the association.

Listing 10. Range specification in Turtle syntax
:relationName
  rdfs:range :ClassName ;
.
Listing 11. Range specification in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/relationName">
    <rdfs:range rdf:resource = "http://base.onto.uri/ClassName"/>
</rdf:Description>
Listing 12. Object property range specification for reused relations in Turtle syntax
:relationName
  rdfs:range [
    rdf:type owl:Class ;
    owl:unionOf (
      :OtherClass1
      :OtherClass2
    )
  ]
.
Listing 13. Object property range specification for reused relations in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/relationName">
    <rdfs:range>
        <owl:Class>
            <owl:unionOf rdf:parseType="Collection">
                <rdf:Description rdf:about="http://base.onto.uri/OtherClass1"/>
                <rdf:Description rdf:about="http://base.onto.uri/OtherClass2"/>
            </owl:unionOf>
        </owl:Class>
    </rdfs:range>
</rdf:Description>
Rule R.06. Association range shape — in data shape layer

Within the SHACL PropertyShape corresponding to an association relation linked to a given source UML Class, specify property constraints indicating the range class.

Listing 14. Property class constraint in Turtle syntax
@prefix : <http://base.onto.uri/> .
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName-relationName
  sh:class :OtherClass ;
.
Listing 15. Property class constraint in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-relationName">
    <sh:class rdf:resource = "http://base.onto.uri/OtherClass"/>
</rdf:Description>
Rule R.07. Association & dependency range — in JSON-LD context layer

For each UML association/dependency, specify the object property range by creating a type coercion entry in a node object. Set the fixed @id keyword as a value to indicate that that the value of the term should be interpreted as an URI. Set the term definition as a top-level entry inside the class’s inner context object. For bidirectional connectors, additionally specify the object property range for the source end.

Listing 16. Type coercion for association & dependency in JSON-LD syntax
"ClassName": {
 "@context": {
    "relatesTo": {
      "@type":"@id"
    },
    "dependencyName": {
      "@type":"@id"
    }
  }
}

Association multiplicity

Rule R.08. Association & dependency multiplicity — in reasoning layer

For the association/dependency target multiplicity, where min and max are different than ``*'' (any) and multiplicity is not [1..1], specify a subclass axiom where the source class specialises an anonymous restriction of properties formulated according to cases provided by rule:attribute-rc-multiplicity. For dependency relations, the property range is always defined as skos:Concept.

Listing 17. Min cardinality restriction for association in Turtle syntax
:ClassName
  rdfs:subClassOf [ a owl:Restriction ;
    owl:onProperty :relationName ;
    owl:onClass :AnotherClass ;
    owl:minQualifiedCardinality "2"^^xsd:nonNegativeinteger;
  ] ;
.
Listing 18. Min cardinality restriction for association in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/ClassName">
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource = "http://base.onto.uri/relationName"/>
            <owl:onClass rdf:resource = "http://base.onto.uri/AnotherClass"/>
            <owl:minQualifiedCardinality rdf:datatype="http://...#nonNegativeinteger" >2</owl:minQualifiedCardinality>
        </owl:Restriction>
    </rdfs:subClassOf>
</rdf:Description>
Listing 19. Min cardinality restriction for dependency in Turtle syntax
:ClassName
  rdfs:subClassOf [ a owl:Restriction ;
    owl:onProperty :relationName ;
    owl:onClass skos:Concept ;
    owl:minQualifiedCardinality "2"^^xsd:nonNegativeinteger;
  ] ;
.
Listing 20. Min cardinality restriction for dependency in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/ClassName">
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource = "http://base.onto.uri/relationName"/>
            <owl:onClass rdf:resource = "http://www.../skos/core#Concept"/>
            <owl:minQualifiedCardinality rdf:datatype="http://...#nonNegativeinteger" >2</owl:minQualifiedCardinality>
        </owl:Restriction>
    </rdfs:subClassOf>
</rdf:Description>
Rule R.09. Association & dependency multiplicity "one" — in reasoning layer

If the association/dependency multiplicity is exactly one, i.e. [1..1], specify a functional property axiom like in rule:attribute-rc-multiplicity-one.

Listing 21. Declaring a functional property in Turtle syntax
:relationName a owl:FunctionalProperty .
Listing 22. Declaring a functional property in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/relationName">
    <rdf:type rdf:resource = "http://...owl#FunctionalProperty"/>
</rdf:Description>
Rule R.10. Association & dependency multiplicity — in data shape layer

Within the SHACL PropertyShape corresponding to an association/dependency relation linked to a given source UML Class, specify property constraints indicating minimum and maximum cardinality, according to cases provided by rule:attribute-ds-multiplicity.

Listing 23. Min cardinality constraint in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName-relationName
  sh:minCount 1 ;
.
Listing 24. Min cardinality constraint in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-relationName">
    <sh:minCount rdf:datatype="http://www.w3.org...#integer"
      >1</sh:minCount>
</rdf:Description>
Rule R.11. Association & dependency container — in JSON-LD context layer

Specify a default container type for each UML association/dependency that can accept more than a one value by setting the fixed @set keyword as a value for the @container key. Set the container type entry for an association/dependency target end, inside a term definition created as a top-level entry inside the class’s inner context object. For bidirectional connectors, additionally specify the container type for the source end.

Listing 25. Association & dependency container definition in JSON-LD syntax
"ClassName": {
  "@context": {
    "relatesTo": {
      "@container": "@set"
    },
    "dependencyName": {
      "@container": "@set"
    }
  }
}

Recursive association

In case of recursive associations, that are from one class to itself, (depicted in Figure 2), the transformation rules must be applied as in the case of regular unidirectional association, which are from Rule R.01 to Rule R.09. In addition, the association must be marked as asymmetric expressed in Rule R.13 and Rule R.12.

11
Figure 2. Visual representation of a UML recursive association (on the left) and OWL recursive properties with cardinality restrictions on domain class (on the right)
Rule R.12. Association asymmetry — in reasoning layer

Specify an asymmetric object property axiom for each end of a recursive association.

Listing 26. Declaring an asymmetric property in Turtle syntax
:relatesTo a owl:AsymmetricProperty .
Listing 27. Declaring an asymmetric property in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/relatesTo">
    <rdf:type rdf:resource = "http://...owl#AsymmetricProperty"/>
</rdf:Description>
Rule R.13. Association asymmetry — in data shape layer

Within the SHACL Node Shape corresponding to the UML Class, specify SPARQL constraint selecting instances connected by the object property in a reciprocal manner.

Listing 28. Adding details to a NodeShape for an asymmetric property in Turtle syntax
@prefix : <http://base.onto.uri/> .
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName
  sh:sparql [
    sh:select """
      SELECT ?this ?that
      WHERE {
        ?this :relatesTo ?that .
        ?that :relatesTo ?this .
      }
    """ ;
  ] ;
.
Listing 29. Adding details to a NodeShape for an asymmetric property in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName">
    <sh:sparql rdf:parseType="Resource">
        <sh:select>
          SELECT ?this ?that
          WHERE {
            ?this :relatesTo ?that .
            ?that :relatesTo ?this .}
        </sh:select>
    </sh:sparql>
</rdf:Description>

Bidirectional association

The bidirectional associations should be treated, both on source and target ends, like two unidirectional associations (see Figure 3). The transformation rules from Rule R.01 and Rule R.02, and all the other rules for unidirectional associations shown in Table 1 must be applied to both ends. In addition to those rules, the inverse relation axiom must be specified.

12
Figure 3. Visual representation of a UML bidirectional association (on the left) and OWL properties with cardinality restrictions on domain class (on the right)
Rule R.14. Association inverse — in reasoning layer

Specify an inverse object property axiom between the source and target ends of the bidirectional association.

Listing 30. Declaring an inverse property in Turtle syntax
:relatesTo owl:inverseOf :isRelatedTo .
Listing 31. Declaring an inverse property in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/relatesTo">
    <owl:inverseOf rdf:resource = "http://base.onto.uri/isRelatedTo"/>
</rdf:Description>

Unidirectional dependency

In general the UML dependency connectors should be transformed by the rules specified for UML association connectors (see Table 1).

The following two rules, concerning the transformation of dependency targets, are different from the rules for the transformation of association targets.

Rule R.15. Dependency target — in reasoning layer

Specify object property range for the target end of the dependency.

Listing 32. Range specification in Turtle syntax
:relationName
  rdfs:range skos:Concept ;
.
Listing 33. Range specification in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/relationName">
    <rdfs:range rdf:resource = ".../02/skos/core#Concept"/>
</rdf:Description>
In OWL we want to state only that the range of a Dependency connector is a skos:Concept, without committing to a specific list. We do this additional restriction in the data shape.
Rule R.16. Dependency range shape — in data shape layer

Within the SHACL PropertyShape corresponding to a dependency relation linked to a given source UML Class, constraint the range of the dependency.

Specify the suitable constraint based on the constraint level set for the UML Enumeration (as defined in rule:enumeration-constraint-level):

  1. permissive: set skos:Concept as the expected type of an enumeration item

  2. restrictive: refer to a NodeShape for an enumeration item that further restricts allowed values (see the transformation rule for enumeration item).

Listing 34. Permissive shape in Turtle syntax
@prefix : <http://base.onto.uri/> .
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

shape:ClassName-relationName a sh:PropertyShape ;
    sh:path :relationName;
    sh:class skos:Concept .
Listing 35. Permissive shape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-relationName">
  <rdf:type rdf:resource = "http://...shacl#PropertyShape"/>
  <sh:path rdf:resource = "http://base.onto.uri/relationName"/>
  <sh:class rdf:resource = "http://...skos/core#Concept"/>
</rdf:Description>
Listing 36. Restrictive shape in Turtle syntax
@prefix : <http://base.onto.uri/> .
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName-relationName a sh:PropertyShape ;
    sh:path :relationName;
    sh:node shape:EnumName-itemShape .
Listing 37. Restrictive shape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-relationName">
  <rdf:type rdf:resource = "http://...shacl#PropertyShape"/>
  <sh:path rdf:resource = "http://base.onto.uri/relationName"/>
  <sh:node rdf:resource = "http://base.shape.uri/EnumName-itemShape"/>
</rdf:Description>

Class generalisation

Generalisation [uml2.5] defines specialization relationship between Classifiers. In case of UML Classes it relates a more specific Class to a more general Class.

13
Figure 4. Visual representation of UML generalisation (on the left) and OWL subclass relation (on the right)

A UML generalisation set [uml2.5] groups generalisations. Subclasses in a generalization set are, by default, incomplete and can overlap. Generalization set properties are not supported.

Rule R.17. Class generalisation — in core ontology layer

Specify subclass axiom for the generalisation between UML Classes.

Listing 38. Subclass declaration in Turtle syntax
:ClassName rdfs:subClassOf :SuperClass.
:OtherClass rdfs:subClassOf :SuperClass.
Listing 39. Subclass declaration in RDF/XML syntax
<owl:Class rdf:about = "http://base.onto.uri/ClassName">
    <rdfs:subClassOf rdf:resource = "http://base.onto.uri/SuperClass"/>
</owl:Class>
<owl:Class rdf:about = "http://base.onto.uri/OtherClass">
    <rdfs:subClassOf rdf:resource = "http://base.onto.uri/SuperClass"/>
</owl:Class>

Property generalisation

Generalisation [uml2.5] defines specialization relationship between Classifiers. In case of the UML associations it relates a more specific Association to more general Association.

14
Figure 5. Visual representation of UML property generalisation (on the left) and OWL sub-property relation (on the right)
Rule R.18. Property generalisation — in core ontology layer

Specify a sub-property axiom representing the generalisation between named roles of UML associations. Properties on the subject and object positions correspond to the association roles belonging to the same side of the association ends. Such a sub-property axiom is specified for the target side of association ends (for unidirectional associations) or for both source and target sides of the association ends (for bidirectional associations).

Listing 40. Property specialisation in Turtle syntax
:hasSister rdfs:subPropertyOf :relatesTo .
:isSisterOf rdfs:subPropertyOf :isRelatedTo .
Listing 41. Property specialisation in RDF/XML syntax
<owl:ObjectProperty rdf:about = "http://base.onto.uri/hasSister">
    <rdfs:subPropertyOf rdf:resource = "http://base.onto.uri/relatesTo"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:about = "http://base.onto.uri/isSisterOf">
    <rdfs:subPropertyOf rdf:resource = "http://base.onto.uri/isRelatedTo"/>
</owl:ObjectProperty>

Class equivalence

15
Figure 6. Visual representation of UML class equivalence (on the left) and OWL class equivalence (on the right)
Rule R.19. Equivalent classes — in reasoning layer

Specify equivalent class axiom for the generalisation with <<equivalent>> or <<complete>> stereotype between UML Classes.

Listing 42. Class equivalence in Turtle syntax
:ClassName owl:equivalentClass :SuperClass.
Listing 43. Class equivalence in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/ClassName">
    <owl:equivalentClass rdf:resource = "http://base.onto.uri/SuperClass"/>
</rdf:Description>

Property equivalence

Rule R.20. Equivalent properties — in reasoning layer

Specify equivalent property axiom for the generalisation with <<equivalent>> or <<complete>> stereotype between UML properties.

Listing 44. Property equivalence in Turtle syntax
:hasSister owl:equivalentProperty :relatesTo .
:isSisterOf owl:equivalentProperty :isRelatedTo .
Listing 45. Property equivalence in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/hasSister">
  <owl:equivalentProperty rdf:resource = "http://base.onto.uri/relatesTo"/>
</rdf:Description>
<rdf:Description rdf:about = "http://base.onto.uri/isSisterOf">
  <owl:equivalentProperty rdf:resource = "http://base.onto.uri/isRelatedTo"/>
</rdf:Description>

Realisation relations

Realisation defines a relationship between an Object element and a UML Class or Enumeration element. At the moment we only provide transformation rules for UML Realization connectors that connect to UML Classes.

Rule R.21. Class realisation — in core ontology layer

Declare an individual with a specified class as its type, for a UML Realization connector between a UML Object and a UML Class.

Listing 46. Individual declaration in Turtle syntax
:ObjectName a owl:NamedIndividual, :ClassName .
Listing 47. Individual declaration in RDF/XML syntax
<owl:NamedIndividual rdf:about="http://base.onto.uri/ObjectName">
    <rdf:type rdf:resource="http://base.onto.uri/ClassName"/>
</owl:NamedIndividual>