Transformation of UML descriptors and tags

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

Rule T.01

Rule T.02

Note

Rule T.03

Rule T.04

Comment

Rule T.05

Rule T.06

Tag

Rule T.07

Source

Rule T.08

Rule 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.

Rule T.01. Label — in core ontology layer

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

Listing 1. Labels in Turtle syntax
:ResourceName
  skos:prefLabel "Resource name"@en ;
.
Listing 2. 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>
Rule T.02. Label — in data shape layer

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

Listing 3. 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" ;
.
Listing 4. 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>
Listing 5. 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" ;
.
Listing 6. 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>

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.

Rule T.03. Description — in core ontology layer

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

Listing 7. Description in Turtle syntax
:ResourceName
  skos:definition "Description of the resource meaning"@en ;
.
Listing 8. 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>
Rule 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.

Listing 9. 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" ;
.
Listing 10. 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>
Listing 11. 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" ;
.
Listing 12. 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>

Comment

In accordance with [uml2.5], every kind of UML Element may own Comments (see Figure 1). 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.

By default, we recommend the use of the SKOS lexicalization (skos:editorialNote) 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.

Rule 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.

Listing 13. Comment in Turtle syntax
:ClassName
  skos:editorialNote "This is an additional comment on ClassName"@en ;
.
Listing 14. 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>
Rule 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.

Listing 15. 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" ;
.
Listing 16. 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>
Listing 17. 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" ;
.
Listing 18. 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>

Tags

Any UML element can have additional information provided by means of tags, represented by UML Tag elements. Such tags should be transformed into annotation on the RDF resource representing the UML element (e.g. Class, Attribute, Connector). The language tags that are provided on the tag, can be used to generate multilingual ontologies/specifications. For example, the highlighted elements in Figure 2 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.
Rule T.07. Tag — in core ontology layer

Specify an annotation axiom on the OWL entity for each UML Tag associated to a UML element. If a tag has an associated language tag, it should be attached to the value.

Listing 19. Tags in Turtle syntax
:ClassName
  tagName "tag value"@langTag ;
.
Listing 20. Tags in RDF/XML syntax
<rdf:Description rdf:about = "http://base.onto.uri/ClassName">
    <tagName xml:lang="langTag">tag value</tagName>
</rdf:Description>

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.

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

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

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

:ResourceName
  rdfs:isDefinedBy <http://base.onto.uri#core> .
Listing 22. 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>
Rule T.09. Source specification — in data shape layer

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

Listing 23. 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> .
Listing 24. 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>
Listing 25. 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> .
Listing 26. 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>