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.

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

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. 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 Figure 2 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.
Rule 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).

Listing 19. Tag for a plain literal in RDF/XML syntax
:ClassName
  tagName "tag value" .
Listing 20. Tag for a plain literal in RDF/XML syntax
<rdf:Description rdf:about =
"http://base.onto.uri/ClassName">
    <tagName>tag value</tagName>
</rdf:Description>
Listing 21. Tag for a literal with a language tag in RDF/XML syntax
:ClassName
  tagProperty "tag value"@langTag .
Listing 22. 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>
Listing 23. Tag for a typed value in RDF/XML syntax
:ClassName
  tagProperty "false"^^xsd:boolean .
Listing 24. 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>
Listing 25. Tag for a URI value in RDF/XML syntax
:ClassName
  tagProperty <https://www.example.org> .
Listing 26. 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>

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 27. Source in Turtle syntax
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:ResourceName
  rdfs:isDefinedBy <http://base.onto.uri#core> .
Listing 28. 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 29. 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 30. 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 31. 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 32. 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>