Transformation of UML datatypes

In this section are specified transformation rules for UML datatypes and enumerations. Overview of transformation rules for UML datatypes provides an overview of the section coverage.

Table 1. Overview of transformation rules for UML datatypes
UML element Rules in core ontology layer Rules in data shape layer Rules in reasoning layer

Primitive datatype

Example D.01

Structured datatype

Example D.02

Enumeration

Example D.03

Example D.04

Enumeration item

Example D.05

Example D.06

Primitive datatype

The UML primitive type defines a predefined datatype without any substructure. The UML specification [uml2.5] predefines five primitive types: String, Integer, Boolean, UnlimitedNatural and Real. Here we extended those to the list provided in Mapping of UML primitive types to XSD datatypes.

16
Figure 1. Visual representation of a UML Datatype (on the left) and an OWL Datatype (on the right)
Example D.01. Datatype — in core ontology layer

Specify datatype declaration axiom for UML datatype as follows:

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 datatype at the time of its creation.
Table 2. Mapping of UML primitive types to XSD datatypes
UML datatype XSD datatype

Boolean

xsd:boolean

Float

xsd:float

Integer

xsd:integer

Char

xsd:string

String

xsd:string

Short

xsd:short

Long

xsd:long

Decimal

xsd:decimal

Real

xsd:float

Date

xsd:date

Numeric

xsd:integer

Text

xsd:string

UML primitive datatype declaration (String) in Turtle syntax
xsd:string a rdfs:Datatype .
Turtle
UML primitive datatype declaration (String) in RDF/XML syntax
<rdfs:Datatype rdf:about = "http://www.w3.org/2001/XMLSchema#string">
</rdfs:Datatype>
XML
XSD and RDF(S) datatype declaration in Turtle syntax
xsd:boolean a rdfs:Datatype .
Turtle
XSD and RDF(S) datatype declaration in RDF/XML syntax
<rdfs:Datatype rdf:about = "http://www.w3.org/2001/XMLSchema#boolean">
</rdfs:Datatype>
XML
Model specific datatype declaration in Turtle syntax
:DatatypeName a rdfs:Datatype .
Turtle
Model specific datatype declaration in RDF/XML syntax
<rdfs:Datatype rdf:about = "http://base.onto.uri/DatatypeName">
</rdfs:Datatype>
XML

Structured datatypes

The UML structured datatype [uml2.5] has attributes and is used to define complex data types. The structured datatypes should be treated as classes.

Example D.02. Structured Datatype — in core ontology layer

Specify OWL class declaration axiom for UML structured datatype.

See applicable rules in Section on Class Rules.

Enumeration

UML Enumerations [uml2.5] are kinds of datatypes, having zero or more values that correspond to one of user-defined literals. They are transformed into SKOS [skos-spec] concept schemes comprising enumeration values represented as SKOS concepts.

Two possible cases of UML enumerations can be identified:

  1. enumeration without items: such an enumeration is used as a reference to an externally defined controlled list.

  2. enumeration with items: such an enumeration serves as a complete representation of a controlled list defined within the UML model.

20
Figure 2. Visual representation of a UML Enumeration without items
17
Figure 3. Visual representation of a UML Enumeration with items
18
Figure 4. Visual representation of a SKOS concept scheme with concepts
Normally, the controlled list represented by UML Enumerations will be defined externally and represented as an enumeration without items in the UML model. In order to be able to validate some data against the generated SHACL shapes, these controlled lists need to be imported. Moreover, the restriction module should be also imported into the SHACL module, alongside the OWL core module.
Example D.03. Enumeration — in core ontology layer

Specify SKOS concept scheme instantiation axiom for a UML enumeration.

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/individual representing the enumeration at the time of its creation.
Concept scheme instantiation in Turtle syntax
:EnumerationName a skos:ConceptScheme .
Turtle
Concept scheme instantiation in RDF/XML syntax
<skos:ConceptScheme rdf:about = "http://base.onto.uri/EnumerationName">
</skos:ConceptScheme>
XML
The tool does not generate SHACL shapes for concept schemes (skos:ConceptScheme) used to represent controlled lists. It is recommended to download the SHACL shapes for SKOS [skos-shacl] and use these for validation purposes.
Example D.04. Enumeration — in reasoning layer

For a UML enumeration, specify an equivalent class restriction covering the set of individuals that are skos:inScheme of this enumeration.

In-scheme equivalent class in Turtle syntax
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
:EnumerationName a owl:Class ;
  owl:equivalentClass [
    rdf:type owl:Restriction ;
    owl:allValuesFrom :EnumerationName ;
    owl:onProperty skos:inScheme ;
  ] ;
  rdfs:subClassOf skos:Concept;
.
Turtle
In-scheme equivalent class in RDF/XML syntax
<owl:Class rdf:about = "http://base.onto.uri/EnumerationName">
    <owl:equivalentClass>
        <owl:Restriction>
            <owl:onProperty rdf:resource = ".../02/skos/core#inScheme"/>
            <owl:hasValue rdf:resource = "http://base.onto.uri/EnumerationName"/>
        </owl:Restriction>
    </owl:equivalentClass>
    <rdfs:subClassOf rdf:resource = ".../02/skos/core#Concept"/>
</owl:Class>
XML
Example D.05. Enumeration items — in core ontology layer

Specify SKOS concept instantiation axiom for each UML enumeration item.

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 individual representing the enumeration item at the time of its creation.
Concept scheme items instantiation in Turtle syntax
:itemA a skos:Concept ;
  skos:inScheme :EnumerationName ;
.

:itemB a skos:Concept ;
  skos:inScheme :EnumerationName ;
.
Turtle
Concept scheme items instantiation in RDF/XML syntax
<skos:Concept rdf:about = "http://base.onto.uri/itemA">
    <skos:inScheme rdf:resource = "http://base.onto.uri/EnumerationName"/>
</skos:Concept>

<skos:Concept rdf:about = "http://base.onto.uri/itemB">
    <skos:inScheme rdf:resource = "http://base.onto.uri/EnumerationName"/>
</skos:Concept>
XML
Example D.06. Enumeration item — in data shape layer

Specify a restrictive SHACL NodeShape for items of an enumeration for each UML Enumeration in the defining mode (based on the constraint level set for the UML Enumeration as defined in rule:enumeration-constraint-level). The URIs of the node shape is deterministically generated from the UML Enumeration name. Set a constraint for the enumeration item belonging to a concept scheme represented by the enumeration URI.

Restrictive shape in Turtle syntax
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

@prefix : <http://base.onto.uri/> .
@prefix shape: <http://base.shape.uri/> .

shape:EnumName-itemShape a sh:NodeShape ;
    sh:property [
        sh:path skos:inScheme ;
        sh:hasValue :EnumName ;
    ] .
Turtle
Restrictive shape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/EnumName-itemShape">
  <rdf:type rdf:resource = "http://...shacl#NodeShape"/>
  <sh:property rdf:parseType = "Resource">
    <sh:path rdf:resource = "http://...skos/core#inScheme"/>
    <sh:hasValue rdf:resource = "http://base.onto.uri/EnumName"/>
  </sh:property>
</rdf:Description>
XML