Transformation of UML descriptors and tags

In this section are specified transformation rules for UML descriptive elements. Overview of transformation rules for UML descriptors and tags provides an overview of the section coverage.

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

Name

Example T.01

Example T.02

Note

Example T.03

Example T.04

Comment

Example T.05

Example T.06

Tag

Example T.07

Source

Example T.08

Example T.09

Name

Most of the UML elements are named. The UML conventions dedicate an extensive section to the naming conventions and how to deterministically generate a URI and a label from the UML element name. By default, we recommend the use of the SKOS lexicalization (skos:prefLabel) in the core ontology layer. In the future, this could be controlled by a flag in the configuration of the transformation tool. With such a flag one could enable RDFS lexicalization (rdfs:label) instead of, or in addition to, the SKOS lexicalization.

Example T.01. Label — in core ontology layer

Specify a label for the OWL entity based on the name of the UML element.

Labels in Turtle syntax
:ResourceName
  skos:prefLabel "Resource name"@en ;
.
Turtle
Labels in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/ResourceName">
    <skos:prefLabel xml:lang="en">Resource name</skos:prefLabel>
</rdf:Description>
XML
Example T.02. Label — in data shape layer

Specify a label for the SHACL shape, based on the name of the UML element.

Label declaration for NodeShape in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

shape:ClassName
  rdfs:label "Class name" ;
.
Turtle
Label declaration for NodeShape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName">
    <rdfs:label>Class name</rdfs:label>
</rdf:Description>
XML
Label declaration for PropertyShape in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName-PropertyName
  sh:name "Property name" ;
.
Turtle
Label declaration for PropertyShape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-PropertyName">
    <sh:name>Property name</sh:name>
</rdf:Description>
XML

Note

Most of the UML element foresee provisions of descriptions and notes. They should be transformed into rdfs:comment and skos:definition. By default, we recommend the use of the SKOS lexicalization (skos:definition) in the core ontology layer. In the future this could be controlled by a flag in the configuration of the transformation tool. With such a flag one could enable RDFS lexicalization (rdfs:comment) instead of, or in addition to, the SKOS lexicalization.

Example T.03. Description — in core ontology layer

Specify a description for the OWL entity based on the note on the UML element.

Description in Turtle syntax
:ResourceName
  skos:definition "Description of the resource meaning"@en ;
.
Turtle
Description in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/ResourceName">
    <skos:definition xml:lang="en">Description of the resource meaning</skos:definition>
</rdf:Description>
XML
Example T.04. Description — in data shape layer

Specify an annotation (comment or description) for the SHACL shape based on the note on the UML element.

Note declaration for NodeShape in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

shape:ClassName
  rdfs:comment "Description of the meaning of the class" ;
.
Turtle
Note declaration for NodeShape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName">
    <rdfs:comment>Description of the meaning of the class</rdfs:comment>
</rdf:Description>
XML
Note declaration for PropertyShape in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName-PropertyName
  sh:description "Description of the meaning of the property" ;
.
Turtle
Note declaration for PropertyShape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-PropertyName">
    <sh:description>Description of the meaning of the property</sh:description>
</rdf:Description>
XML

Comment

In accordance with [uml2.5], every kind of UML Element may own Comments (see Visual representation of a UML comment (on the left) and an OWL comment (on the right)). They add no semantics but may represent information useful to the reader. In OWL it is possible to define the annotation axiom for OWL Class, Datatype, ObjectProperty, DataProperty, AnnotationProperty and NamedIndividual. The textual explanation added to UML Class is identified as useful for conceptual modelling , therefore the Comments that are connected to UML Classes are taken into consideration in the transformation.

19
Figure 1. Visual representation of a UML comment (on the left) and an OWL comment (on the right)

As UML Comments add no semantics, they are not used in any method of semantic validation. In OWL the AnnotationAssertion axiom [owl2] does not add any semantics either, and it only improves readability.

Note: In practice, comments on UML attributes and generalizations are unsupported, as explained in the rule:comments-uml-elems UML convention.

Example T.05. Comment — in core ontology layer

Specify an annotation axiom (comment or editorial note) on the OWL entity for the UML Comment associated to a UML element.

Comment in Turtle syntax
:ClassName
  skos:editorialNote "This is an additional comment on ClassName"@en ;
.
Turtle
Comment in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/ClassName">
    <skos:editorialNote xml:lang="en">This is an additional comment on ClassName</skos:editorialNote>
</rdf:Description>
XML
Example T.06. Comment — in data shape layer

Specify an annotation axiom (comment or description) on the SHACL shape for the UML Comment associated to a UML element.

Note declaration for NodeShape in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

shape:ClassName
  rdfs:comment "This is an additional comment on ClassName" ;
.
Turtle
Note declaration for NodeShape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName">
    <rdfs:comment>This is an additional comment on ClassName</rdfs:comment>
</rdf:Description>
XML
Note declaration for PropertyShape in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

shape:ClassName-PropertyName
  sh:description "This is an additional comment on PropertyName" ;
.
Turtle
Note declaration for PropertyShape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-PropertyName">
    <sh:description>This is an additional comment on PropertyName</sh:description>
</rdf:Description>
XML

Tags

Any UML element can have additional information provided by means of tags, represented by UML Tag elements. Tags serve two purposes (as described in rule:tags-use-cases): to either provide additional description of an element or control the transformation process. Every descriptive tag should be transformed into annotation on the RDF resource representing the UML element (e.g. Class, Attribute, Connector).

For example, the language tags that are provided on the tag, can be used to generate multilingual ontologies/specifications. The elements highlighted in Example depicting the specification of UML tags below would be transformed in the following Turtle statement epo:Procedure skos:definition "this is the definition in French"@fr .

20
Figure 2. Example depicting the specification of UML tags
The generation of annotations from tags could be controlled by a flag in the configuration of the transformation tool.
Example T.07. Tag — in core ontology layer

Specify an annotation axiom on the OWL entity for a UML Tag associated to a UML element. Apply this transformation rule only for descriptive tags (as defined in as defined in rule:descriptive-tags). Detect the kind of tag by analyzing its key, and generate the proper RDF representation of the tag value as specified in rule:gen-tags.

The below snippets present generated RDF statements for the four supported forms of tags and their values: a plain literal, a literal with a language tag, a typed value and an URI. The snippets use suitable examples to demonstrate the idea.

The tagProperty indicates a part of a tag name with a compact URI (for example skos:related for a tag with the skos:related<> key).

Tag for a plain literal in RDF/XML syntax
:ClassName
  tagName "tag value" .
Turtle
Tag for a plain literal in RDF/XML syntax
<rdf:Description rdf:about =
"http://base.onto.uri/ClassName">
    <tagName>tag value</tagName>
</rdf:Description>
XML
Tag for a literal with a language tag in RDF/XML syntax
:ClassName
  tagProperty "tag value"@langTag .
Turtle
Tag for a literal with a language tag in RDF/XML syntax
<rdf:Description rdf:about =
"http://base.onto.uri/ClassName">
    <tagProperty xml:lang = "langTag" >tag value</tagProperty>
</rdf:Description>
XML
Tag for a typed value in RDF/XML syntax
:ClassName
  tagProperty "false"^^xsd:boolean .
Turtle
Tag for a typed value in RDF/XML syntax
<rdf:Description rdf:about =
"http://base.onto.uri/ClassName">
  <tagProperty rdf:datatype = "http://www.w3.org/2001/XMLSchema#boolean" >false</tagProperty>
</rdf:Description>
XML
Tag for a URI value in RDF/XML syntax
:ClassName
  tagProperty <https://www.example.org> .
Turtle
Tag for a URI value in RDF/XML syntax
<rdf:Description rdf:about =
"http://base.onto.uri/ClassName">
  <tagProperty rdf:resource =
  "https://www.example.org"/>
</rdf:Description>
XML

Source

It is a good practice to annotate all concepts in an ontology with the IRI of the ontology where these concepts are defined. RDFS provides a dedicated property for purpose, called rdfs:isDefinedBy, which we will use.

Example T.08. Source specification — in core ontology layer

Annotate all locally defined OWL concepts with the name of the (core) ontology that defines them.

Source in Turtle syntax
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:ResourceName
  rdfs:isDefinedBy <http://base.onto.uri#core> .
Turtle
Source in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/ResourceName">
    <rdfs:isDefinedBy rdf:resource="http://base.onto.uri#core" />
</rdf:Description>
XML
Example T.09. Source specification — in data shape layer

For all SHACL shapes specify the source ontology defining the shape.

Source declaration for NodeShape in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

shape:ClassName
  rdfs:isDefinedBy <http://base.shape.uri/#core-shapes> .
Turtle
Source declaration for NodeShape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName">
    <rdfs:isDefinedBy rdf:resource="http://base.shape.uri/#core-shapes" />
</rdf:Description>
XML
Source declaration for PropertyShape in Turtle syntax
@prefix shape: <http://base.shape.uri/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

shape:ClassName-PropertyName
  rdfs:isDefinedBy <http://base.shape.uri/#core-shapes> .
Turtle
Source declaration for PropertyShape in RDF/XML syntax
<rdf:Description rdf:about = "http://base.shape.uri/ClassName-PropertyName">
    <rdfs:isDefinedBy rdf:resource="http://base.shape.uri/#core-shapes" />
</rdf:Description>
XML