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 Rules in JSON-LD context layer

Primitive datatype

Rule D.01

Rule D.02

Structured datatype

Rule D.03

Enumeration

Rule D.04

Rule D.05

Rule D.08

Enumeration item

Rule D.06

Rule D.07

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>
Rule D.02. Datatype — in JSON-LD context layer

Specify a term for each UML datatype by assigning an absolute URI of the datatype to its name. Create the term mapping as a top-level entry of the context object.

Listing 7. Datatype term mapping in JSON-LD syntax
"rdf:PlainLiteral": "http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral"

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.03. 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.
Rule D.04. 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 8. Concept scheme instantiation in Turtle syntax
:EnumerationName a skos:ConceptScheme .
Listing 9. Concept scheme instantiation in RDF/XML syntax
<skos:ConceptScheme rdf:about = "http://base.onto.uri/EnumerationName">
</skos:ConceptScheme>
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.
Rule D.05. 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 10. 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 11. 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.06. 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 12. Concept scheme items instantiation in Turtle syntax
:itemA a skos:Concept ;
  skos:inScheme :EnumerationName ;
.

:itemB a skos:Concept ;
  skos:inScheme :EnumerationName ;
.
Listing 13. 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>
Rule D.07. 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.

Listing 14. 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 ;
    ] .
Listing 15. 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>
Rule D.08. Enumeration — in JSON-LD context layer

Specify a term for each UML enumeration by assigning an absolute URI of the enumeration to its name. Create the term mapping as a top-level entry of the context object.

Listing 16. Enumeration term mapping in JSON-LD syntax
"at-voc:applicability": "http://publications.europa.eu/resource/authority/applicability"