Transformation of UML datatypes

In this section are specified transformation rules for UML datatypes and enumerations. Table 1 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

Rule D.01

Structured datatype

Rule D.02

Enumeration

Rule D.03

Rule D.04

Enumeration item

Rule D.05

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 Table 2.

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

Specify datatype declaration axiom for UML datatype as follows:

  • UML primitive datatypes are declared as the mapped XSD datatype in Table 2.

  • XSD and RDF(S) datatypes are declared as such.

  • Model specific datatypes are declared as such.

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

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

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.

Rule 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, whose values correspond to one of user-defined literals. They should be transformed into SKOS [skos-spec] concept schemes comprising the concepts corresponding to enumerated items.

17
Figure 2. Visual representation of a UML Enumeration
18
Figure 3. Visual representation of a SKOS concept scheme with concepts
Normally, the controlled list represented by UML Enumerations will be defined externally. In order to be ale to validate some data against the generate SHACL shapes, these controlled lists need to be imported into the SHACL shapes. Moreover, the restriction module should be also imported into the SHACL module, alongside the OWL core module.
Rule 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.
Listing 7. Concept scheme instantiation in Turtle syntax
:EnumerationName a skos:ConceptScheme .
Listing 8. Concept scheme instantiation in RDF/XML syntax
<skos:ConceptScheme rdf:about = "http://base.onto.uri/EnumerationName">
</skos:ConceptScheme>
Rule 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.

Listing 9. 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;
.
Listing 10. 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>
Rule 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.
Listing 11. Concept scheme items instantiation in Turtle syntax
:itemA a skos:Concept ;
  skos:inScheme :EnumerationName ;
.

:itemB a skos:Concept ;
  skos:inScheme :EnumerationName ;
.
Listing 12. 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>