Transformation of UML classes and attributes

In this section are specified transformation rules for UML class and attribute elements. Table 1 provides an overview of the section coverage.

Table 1. Overview of transformation rules for UML classes and attributes
UML element Rules in core ontology layer Rules in data shape layer Rules in reasoning layer Rules in JSON-LD context layer

Class

Rule C.01

Rule C.02

Rule C.03

Abstract class

Rule C.04

Attribute

Rule C.05

Rule C.07

Rule C.06

Rule C.08

Attribute type

Rule C.10

Rule C.09

Rule C.11

Attribute multiplicity

Rule C.14

Rule C.12, Rule C.13

Rule C.15

Class

In UML, a Class [uml2.5] is purposed to specify a classification of objects. UML represents atomic classes as named elements of type Class without further features. In OWL, the atomic class, owl:Class, has no intention. It can only be interpreted by its name that has a meaning in the world outside the ontology. The atomic class is a class description that is simultaneously a class axiom .

6
Figure 1. Visual representation of a class in UML (on the left) and OWL (on the right)
Rule C.01. Class — in core ontology layer

Specify an OWL Class declaration axiom for each UML Class, where the URI of the OWL class is deterministically generated from the UML Class name.

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 class at the time of its creation.
Listing 1. Class declaration in Turtle syntax
:ClassName a owl:Class .
Listing 2. Class declaration in RDF/XML syntax
<owl:Class rdf:about = "http://base.onto.uri/ClassName">
</owl:Class>
Rule C.02. Class — in data shape layer

Specify a SHACL NodeShape declaration axiom for each UML Class. The URIs of the node shape and of the OWL class they refer to, are deterministically generated from the UML Class name.

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 node shape at the time of its creation.
Listing 3. Node shape declaration in Turtle syntax
@prefix : <http://base.onto.uri/> .
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName a sh:NodeShape ;
  sh:targetClass :ClassName ;
.
Listing 4. Node shape declaration in RDF/XML syntax
<sh:NodeShape rdf:about = "http://base.shape.uri/ClassName">
    <sh:targetClass rdf:resource = "http://base.onto.uri/ClassName"/>
</sh:NodeShape>
Rule C.03. Class — in JSON-LD context layer

Specify a term for each UML class by assigning an absolute URI of the class to the class name. Define a simple term definition or, an expanded term definition if the class includes properties. Create the term mapping as a top-level entry of the context object.

The term mapping key contains the relevant class name. It does not contain a namespace prefix even if one is defined in the model. Namespace prefixes are not used as all classes defined in the model are presumed to be internal, that is belonging to the generated ontology.
If the class has attributes or related association or dependency connectors, all their term definitions are set within the single inner context object (see attribute, attribute range, attribute multiplicity, association/dependency, association/dependency range, association/dependency multiplicity).
Listing 5. Simple class term mapping in JSON-LD syntax
"ClassName": "http://base.onto.uri/ClassName"
Listing 6. Expanded class term mapping in JSON-LD syntax
"ClassName": {
  "@id": "http://base.onto.uri/ClassName"
}

Abstract class

In UML, an abstract Class [uml2.5] cannot have any instances and only its subclasses can be instantiated. The abstract classes are declared just like the regular ones (Rule C.01 and Rule C.02) and in addition a constraint validation rule is generated to ensure that no instance of this class is permitted.

OWL follows the Open World Assumption [owl2], therefore, even if the ontology does not contain any instances for a specific class, it is unknown whether the class has any instances. We cannot confirm that the UML abstract class is correctly defined with respect to the OWL domain ontology, but we can detect if it is not using SHACL constraints.

7
Figure 2. Visual representation of an abstract class in UML (on the left) and OWL (on the right)
Rule C.04. Abstract class — in data shape layer

Specify a SHACL NodeShape declaration axiom for each abstract UML Class, with a SPARQL constraint that selects all instances of this class.

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 node shape at the time of its creation.
Listing 7. Instance checking 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 a sh:NodeShape ;
  sh:targetClass :ClassName ;
  sh:sparql [
    sh:select """SELECT $this
      WHERE {
        $this a :ClassName .
      }
    """ ;
  ] ;
.
Listing 8. Instance checking constraint in RDF/XML syntax
<sh:NodeShape rdf:about = "http://base.shape.uri/ClassName">
    <sh:targetClass rdf:resource = "http://base.onto.uri/ClassName"/>
    <sh:sparql rdf:parseType="Resource">
        <sh:select>SELECT $this
          WHERE {
          $this a :ClassName .
        }
        </sh:select>
    </sh:sparql>
</sh:NodeShape>

Attribute

The UML attributes [uml2.5] are properties that are owned by a Classifier, e.g. Class. Both UML attributes and associations are represented by one meta-model element – Property. OWL also allows one to define properties. A transformation of UML attribute to OWL data property or OWL object property is done based on its type. If the type of the attribute is a primitive type it should be transformed into OWL data property. However, if the type of the attribute is a structured datatype, class or enumeration, it should be transformed into an OWL object property. These cases are illustrated in Figure 3.

8
Figure 3. Visual representation of class attributes in UML (on the left) and OWL properties (on the right)

Attributes can also be reused across multiple classes (i.e. multiple UML classes can own the same attributes), as illustrated in Figure 4. In such cases there should be special logic applied when defining the domain and range of these properties (see rules Rule C.06, Rule C.09).

8b
Figure 4. Visual representation of reused class attributes in UML (on the left) and OWL properties (on the right)
Rule C.05. Attribute — in core ontology layer

Specify declaration axiom(s) for attribute(s) of a UML Class as OWL data or object properties, deciding based on their types. The attributes with primary types should be treated as data properties, whereas those typed with classes or enumerations should be treated as object properties.

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 9. Data property declaration in Turtle syntax
:attribute1 a owl:DatatypeProperty ;
.
Listing 10. Data property declaration in RDF/XML syntax
<owl:DatatypeProperty rdf:about = "http://base.onto.uri/attribute1">
</owl:DatatypeProperty>
Listing 11. Object property declaration in Turtle syntax
:attribute2 a owl:ObjectProperty .
Listing 12. Object property declaration in RDF/XML syntax
<owl:ObjectProperty rdf:about = "http://base.onto.uri/attribute2">
</owl:ObjectProperty>

Attribute owner

Rule C.06. Attribute domain — in reasoning layer

Specify data (or object) property domains for attribute(s). The domain of properties created for attributes that are reused in multiple classes should be the union of all the classes where the attribute is reused.

Listing 13. Data property domain specification in Turtle syntax
:attribute1
  rdfs:domain :ClassName ;
.
Listing 14. Data property domain specification in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/attribute1">
    <rdfs:domain rdf:resource = "http://base.onto.uri/ClassName"/>
</rdf:Description>
Listing 15. Object property domain specification in Turtle syntax
:attribute2
  rdfs:domain :ClassName ;
.
Listing 16. Object property domain specification in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/attribute2">
    <rdfs:domain rdf:resource = "http://base.onto.uri/ClassName"/>
</rdf:Description>

For reused attributes, like the ones depicted in Figure 4, the generated output should have the following form.

Listing 17. Data property domain specification for reused attributes in Turtle syntax
:attribute1
  rdfs:domain [
    rdf:type owl:Class ;
    owl:unionOf (
      :ClassName1
      :ClassName2
    )
  ]
.
Listing 18. Data property domain specification for reused attributes in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/attribute1">
    <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>
Listing 19. Object property domain specification for reused attributes in Turtle syntax
:attribute2
  rdfs:domain [
    rdf:type owl:Class ;
    owl:unionOf (
      :ClassName1
      :ClassName2
    )
  ]
.
Listing 20. Object property domain specification for reused attributes in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/attribute2">
    <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>
Rule C.07. Class attribute — in data shape layer

Specify a SHACL PropertyShape declaration axiom for each attribute.

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 shape at the time of its creation.
Listing 21. PropertyShape declaration for attributes 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-attributeName ;
.
shape:ClassName-attributeName a sh:PropertyShape ;
  sh:path :attributeName ;
.
Listing 22. PropertyShape declaration for attributes in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName">
    <sh:property rdf:resource = "http://base.shape.uri/ClassName-attributeName"/>
</rdf:Description>
<sh:PropertyShape rdf:about = "http://base.shape.uri/ClassName-attributeName">
    <sh:path rdf:resource = "http://base.onto.uri/attributeName"/>
</sh:PropertyShape>
Rule C.08. Attribute — in JSON-LD context layer

For each UML class attribute, specify a datatype property by creating a property URI mapping with an absolute attribute URI in a node object. Set the term definition as a top-level entry inside the class’s inner context object.

The term definition key contains the attribute and the relevant class names. It does not contain a namespace prefix even if one is defined in the model. Namespace prefixes are not used as all classes defined in the model are presumed to be internal, that is belonging to the generated ontology.
Listing 23. Class attribute term mapping in JSON-LD syntax
"ClassName": {
  "@context": {
    "attribute1": {
      "@id": "http://base.onto.uri/attribute1"
    }
  }
}

Attribute type

Rule C.09. Attribute type — in reasoning layer

Specify data (or object) property range for attribute(s). The range of object properties created for attributes that are reused in multiple classes should be the union of all the classes specified as values for those attributes.

Listing 24. Data property range specification in Turtle syntax
:attribute1
  rdfs:range xsd:string;
.
Listing 25. Data property range specification in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/attribute1">
    <rdfs:range rdf:resource = "http://www.w3c.org...#string"/>
</rdf:Description>
Listing 26. Object property range specification in Turtle syntax
:attribute2
  rdfs:range :OtherClass;
.
Listing 27. Object property range specification in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/attribute2">
    <rdfs:range rdf:resource = "http://base.onto.uri/OtherClass"/>
</rdf:Description>

For reused attributes, like the ones depicted in Figure 4, the generated output should have the following form.

Listing 28. Object property range specification for reused attributes in Turtle syntax
:attribute2
  rdfs:range [
    rdf:type owl:Class ;
    owl:unionOf (
      :OtherClass1
      :OtherClass2
    )
  ]
.
Listing 29. Object property range specification for reused attributes in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/attribute2">
    <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 C.10. Attribute type — in data shape layer

Within the SHACL PropertyShape corresponding to an attribute of a UML Class, specify property constraints indicating the range class or datatype.

Listing 30. Property datatype constraint in Turtle syntax
# @prefix : <http://base.onto.uri/> .
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

shape:ClassName-attribute1
  sh:datatype xsd:string ;
.
Listing 31. Property datatype constraint in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-attribute1">
    <sh:datatype rdf:resource = "http://www.w3c.org...#string"/>
</rdf:Description>
Listing 32. 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-attribute2
  sh:class :OtherClass ;
.
Listing 33. Property class constraint in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-attribute2">
    <sh:class rdf:resource = "http://base.onto.uri/OtherClass"/>
</rdf:Description>
Rule C.11. Class attribute type — in JSON-LD context layer

For each UML class attribute, specify its range by creating a type coercion entry with an absolute URI of the attribute datatype in a node object. Set the term definition as a top-level entry inside the class’s inner context object.

Listing 34. Class attribute type definition in JSON-LD syntax
"ClassName": {
  "@context": {
    "attribute1": {
      "@type": "http://www.w3.org/2001/XMLSchema#string"
    }
  }
}

Attribute multiplicity

In [uml2.5], multiplicity bounds of multiplicity element are specified in the form of [<lower-bound> .. <upper-bound>]. The lower-bound, also referred here as minimum cardinality or min is of a non-negative Integer type and the upper-bound, also referred here as maximum cardinality or max, is of an UnlimitedNatural type (see Section Primitive datatype). The strictly compliant specification of UML in version 2.5 defines only a single value range for MultiplicityElement. However, in practice, there might be a need to specify more than a single interval. Therefore, the below UML to OWL mapping covers a wider case – a possibility of specifying more value ranges for a multiplicity element. Nevertheless, if the reader would like to strictly follow the current UML specification, the particular single lower..upper bound interval is therein also comprised.

9-1
Figure 5. Visual representation of class attributes with multiplicity in UML
9-2
Figure 6. Visual representation of OWL class specialising an anonymous restriction of properties

It should be noted that upper-bound of UML MultiplicityElement can be specified as unlimited: ``*''. In OWL, cardinality expressions serve to restrict the number of individuals that are connected by a property expression to a given number of instances of a specified type [owl2]. Therefore, UML unlimited upper-bound does not add any information to OWL ontology, hence it is not transformed. The UML to OWL mapping supports qualified cardinality restrictions (owl:*qualifiedCardinality), which impose constraints on a specific type associated with a property. Both object properties and datatype properties are supported.

Rule C.12. Attribute multiplicity — in reasoning layer

For each attribute/relation multiplicity of the form ( min .. max ), where min and max are different than ``*'' (any), specify a subclass axiom where the OWL class, corresponding to the UML Class, specialises an anonymous restriction of properties formulated according to the following cases:

  1. exact cardinality, e.g. [2..2]

  2. minimum cardinality only, e.g. [2..*]

  3. maximum cardinality only, e.g. [*..2]

  4. maximum and maximum cardinality, e.g. [1..2]

  5. at least one occurence: [1..*]

The restriction describes a constraint that is formulated with respect to the range type of the defined OWL property, that is one of the following:

  1. class

  2. datatype

For the special case of multiplicity [1..*], specify the existential constraint using the owl:someValuesFrom property instead of a cardinality constraint with owl:minQualifiedCardinality.

Listing 35. Exact cardinality constraint for datatype property in Turtle syntax
:ClassName
  rdfs:subClassOf [ a owl:Restriction ;
    owl:onProperty :property1 ;
    owl:onDataRange xsd:string ;
    owl:qualifiedCardinality "2"^^xsd:nonNegativeInteger;
  ] ;
.
Listing 36. Exact cardinality constraint for datatype property 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/property1"/>
            <owl:onDataRange rdf:resource = "http://www.w3.org...#string"/>
            <owl:qualifiedCardinality rdf:datatype="http://...#nonNegativeInteger" >2</owl:qualifiedCardinality>
        </owl:Restriction>
    </rdfs:subClassOf>
</rdf:Description>
Listing 37. Exact cardinality constraint for object property in Turtle syntax
:ClassName
  rdfs:subClassOf [ a owl:Restriction ;
    owl:onProperty :property5 ;
    owl:onClass :Prop5Class ;
    owl:qualifiedCardinality "2"^^xsd:nonNegativeInteger;
  ] ;
.
Listing 38. Exact cardinality constraint for object property 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/property5"/>
            <owl:onClass rdf:resource = "http://base.onto.uri/Prop5Class"/>
            <owl:qualifiedCardinality rdf:datatype="http://...#nonNegativeInteger" >2</owl:qualifiedCardinality>
        </owl:Restriction>
    </rdfs:subClassOf>
</rdf:Description>
Listing 39. Min cardinality constraint for datatype property in Turtle syntax
:ClassName
  rdfs:subClassOf [ a owl:Restriction ;
    owl:onProperty :property2 ;
    owl:onDataRange xsd:string ;
    owl:minQualifiedCardinality "1"^^xsd:nonNegativeInteger;
  ] ;
.
Listing 40. Min cardinality constraint for datatype property 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/property2"/>
            <owl:onDataRange rdf:resource = "http://www.w3.org...#string"/>
            <owl:minQualifiedCardinality rdf:datatype="http://...#nonNegativeInteger" >1</owl:minQualifiedCardinality>
        </owl:Restriction>
    </rdfs:subClassOf>
</rdf:Description>
Listing 41. Min cardinality constraint for object property in Turtle syntax
:ClassName
  rdfs:subClassOf [ a owl:Restriction ;
    owl:onProperty :property6 ;
    owl:onClass :Prop6Class ;
    owl:minQualifiedCardinality "2"^^xsd:nonNegativeInteger;
  ] ;
.
Listing 42. Min cardinality constraint for object property 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/property6"/>
            <owl:onClass rdf:resource = "http://base.onto.uri/Prop6Class"/>
            <owl:minQualifiedCardinality rdf:datatype="http://...#nonNegativeInteger" >2</owl:minQualifiedCardinality>
        </owl:Restriction>
    </rdfs:subClassOf>
</rdf:Description>
Listing 43. Max cardinality constraint for datatype property in Turtle syntax
:ClassName
  rdfs:subClassOf [ a owl:Restriction ;
    owl:onProperty :property3 ;
    owl:onDataRange xsd:string ;
    owl:maxQualifiedCardinality "2"^^xsd:nonNegativeInteger;
  ] ;
.
Listing 44. Max cardinality constraint for datatype property 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/property3"/>
            <owl:onDataRange rdf:resource = "http://www.w3.org...#string"/>
            <owl:maxQualifiedCardinality rdf:datatype="http://...#nonNegativeInteger" >2</owl:maxQualifiedCardinality>
        </owl:Restriction>
    </rdfs:subClassOf>
</rdf:Description>
Listing 45. Max cardinality constraint for object property in Turtle syntax
:ClassName
  rdfs:subClassOf [ a owl:Restriction ;
    owl:onProperty :property7 ;
    owl:onClass :Prop7Class ;
    owl:maxQualifiedCardinality "2"^^xsd:nonNegativeInteger;
  ] ;
.
Listing 46. Max cardinality constraint for object property 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/property7"/>
            <owl:onClass rdf:resource = "http://base.onto.uri/Prop7Class"/>
            <owl:maxQualifiedCardinality rdf:datatype="http://...#nonNegativeInteger" >2</owl:maxQualifiedCardinality>
        </owl:Restriction>
    </rdfs:subClassOf>
</rdf:Description>
Listing 47. Min and max cardinality constraints for datatype property in Turtle syntax
:ClassName
  rdfs:subClassOf [ a owl:Restriction ;
      owl:minQualifiedCardinality "1"^^xsd:nonNegativeInteger;
      owl:onDataRange xsd:string ;
      owl:onProperty :property4; ]
    [ a owl:Restriction ;
      owl:maxQualifiedCardinality "2"^^xsd:nonNegativeInteger;
      owl:onDataRange xsd:string ;
      owl:onProperty :property4; ]
.
Listing 48. Min and max cardinality constraints for datatype property 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/property4"/>
      <owl:onDataRange rdf:resource = "http://www.w3.org...#string"/>
      <owl:minQualifiedCardinality rdf:datatype="...#nonNegativeInteger"
      >1</owl:minQualifiedCardinality>
    </owl:Restriction>
  </rdfs:subClassOf>
  <rdfs:subClassOf>
    <owl:Restriction>
      <owl:onProperty rdf:resource = "http://base.onto.uri/property4"/>
      <owl:onDataRange rdf:resource = "http://www.w3.org...#string"/>
      <owl:maxQualifiedCardinality rdf:datatype="...#nonNegativeInteger"
      >2</owl:maxQualifiedCardinality>
    </owl:Restriction>
  </rdfs:subClassOf>
</rdf:Description>

The owl:someValuesFrom is used instead of owl:minQualifiedCardinality with a value of 1 because, while they are conceptually equivalent, they are treated differently in Description Logics. In particular, owl:minQualifiedCardinality can only be applied to simple object properties, whereas owl:someValuesFrom can also be used with non-simple ones, offering greater flexibility and avoiding certain reasoning limitations.

Listing 49. Existential and max cardinality constraints for object property in Turtle syntax
:ClassName rdfs:subClassOf
    [ a owl:Restriction ;
      owl:someValuesFrom :Prop8Class ;
      owl:onProperty :property8; ],
    [ a owl:Restriction ;
      owl:maxQualifiedCardinality "2"^^xsd:nonNegativeInteger;
      owl:onClass :Prop8Class ;
      owl:onProperty :property8; ]
.
Listing 50. Existential and max cardinality constraints for object property 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/property8"/>
      <owl:someValuesFrom rdf:resource = "http://base.onto.uri/Prop8Class"/>
    </owl:Restriction>
  </rdfs:subClassOf>
  <rdfs:subClassOf>
    <owl:Restriction>
      <owl:onProperty rdf:resource = "http://base.onto.uri/property8"/>
      <owl:onClass rdf:resource = "http://base.onto.uri/Prop8Class"/>
      <owl:maxQualifiedCardinality rdf:datatype="...#nonNegativeInteger"
      >2</owl:maxQualifiedCardinality>
    </owl:Restriction>
  </rdfs:subClassOf>
</rdf:Description>

Attributes with multiplicity exactly one correspond to functional object or data properties in OWL. If we apply the previous rule specifying min and max cardinality will lead to inconsistent ontology. To avoid that it is important that min and max cardinality are not generated from [1..1] multiplicity but only functional property axiom.

Rule C.13. Attribute multiplicity "one"  — in reasoning layer

For each attribute that has multiplicity exactly one, i.e. [1..1], specify a functional property axiom.

Listing 51. Declaring a functional property in Turtle syntax
@prefix : <http://base.onto.uri/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .

:attribute5 a owl:FunctionalProperty .
Listing 52. Declaring a functional property in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/attribute5">
    <rdf:type rdf:resource = "http://...owl#FunctionalProperty"/>
</rdf:Description>
Rule C.14. Attribute range shape — in data shape layer

Within the SHACL PropertyShape corresponding to an attribute of a UML Class, specify property constraints indicating the minimum and maximum cardinality, only where min and max are different from ``*'' (any) and multiplicity is not [1..1]. The expressions are formulated according to the following cases.

  1. exact cardinality, e.g. [2..2]

  2. minimum cardinality only, e.g. [1..*]

  3. maximum cardinality only, e.g. [*..2]

  4. minimum and maximum cardinality , e.g. [1..2]

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

shape:ClassName-attribute1
  sh:minCount 2 ;
  sh:maxCount 2 ;
.
Listing 54. Exact cardinality constraint in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-attribute1">
    <sh:minCount rdf:datatype="http://www.w3.org...#integer"
      >2</sh:minCount>
    <sh:maxCount rdf:datatype="http://www.w3.org...#integer"
      >2</sh:maxCount>
</rdf:Description>
Listing 55. Min cardinality constraint in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName-attribute2
  sh:minCount 1 ;
.
Listing 56. Min cardinality constraint in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-attribute2">
    <sh:minCount rdf:datatype="http://www.w3.org...#integer"
      >1</sh:minCount>
</rdf:Description>
Listing 57. Max cardinality constraint in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName-attribute3
  sh:maxCount 2 ;
.
Listing 58. Max cardinality constraint in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-attribute3">
    <sh:maxCount rdf:datatype="http://www.w3.org...#integer"
      >2</sh:maxCount>
</rdf:Description>
Listing 59. Min and max cardinality constraint in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName-attribute4
  sh:minCount 1 ;
  sh:maxCount 2 ;
.
Listing 60. Min and max cardinality constraint in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-attribute4">
    <sh:minCount rdf:datatype="http://www.w3.org...#integer"
      >1</sh:minCount>
    <sh:maxCount rdf:datatype="http://www.w3.org...#integer"
      >2</sh:maxCount>
</rdf:Description>
Rule C.15. Class attribute container — in JSON-LD context layer

Specify a default container type for a class attribute 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 inside a term definition created as a top-level entry inside the class’s inner context object.

Listing 61. Attribute container definition in JSON-LD syntax
"ClassName": {
  "@context": {
    "attribute1": {
      "@container": "@set"
    },
    "attribute2": {
      "@container": "@set"
    },
    "attribute3": {
      "@container": "@set"
    },
    "attribute4": {
      "@container": "@set"
    }
  }
}