activity-pub-poc/doc/Translate_ttl_to_spec.md
2023-08-02 12:18:12 +02:00

130 lines
No EOL
2.9 KiB
Markdown

- [receipts to transform ttl to spec](#receipts-to-transform-ttl-to-spec)
- [**a**](#a)
- [**rdfs:range**](#rdfsrange)
- [**rdfs:domain**](#rdfsdomain)
- [owner is **a** type](#owner-is-a-type)
- [owner is a **owl:unionOf** types](#owner-is-a-owlunionof-types)
- [**rdfs:subClassOf**](#rdfssubclassof)
- [Further infos](#further-infos)
- [RDF/S](#rdfs)
- [range (https://www.w3.org/TR/rdf12-schema/#ch\_range)](#range-httpswwww3orgtrrdf12-schemach_range)
- [type (https://www.w3.org/TR/rdf12-schema/#ch\_type)](#type-httpswwww3orgtrrdf12-schemach_type)
# receipts to transform ttl to spec
## **a**
*it* is **a** *something*
Example:
```ttl
as:id a owl:DatatypeProperty ,
owl:FunctionalProperty,
```
Maps to
```clojure
(s/def ::id
(s/and
::owl/DeprecatedProperty
::owl/FunctionalProperty))
```
Der token `a` in einer ttl Definition entspricht dem RDF-Prädikat `rdf:type`. Siehe:
* https://www.w3.org/TR/turtle/#sec-iri
* https://www.w3.org/TR/rdf12-schema/#ch_type
Das bedeutet für das Tripel: `(R, rdf:type, C) => C instanceof rdfs:Class & R instanceof C`
## **rdfs:range**
*its* value is defined in a **rdfs:range** *the range*
If range links to an other definition we map range same as **a**.
Example:
```ttl
as:id rdfs:range xsd:anyURI ;
```
Maps to
```clojure
(s/def ::id
(s/and
...
(sh/seq-spec ::xsd/anyURI)))
```
## **rdfs:domain**
*it* belong to a **rdfs:domain** *owner*
### owner is **a** type
We ignore this.
Example in namespace activitypub2
```ttl
as:id rdfs:domain [a owl:Class;]
```
Maps to
```clojure
```
### owner is a **owl:unionOf** types
It is added to the owner. That's the way to model properties. If the owner is membe of an other namespace, we create a subclass with same name in the namespce in scope and enhance the subclass.
Example in namespace activitypub2
```ttl
as:id rdfs:domain [owl:unionOf (as:Link as:Object)]
```
Maps to
```clojure
(s/def ::Object (sh/map-spec (s/keys :opt [::id ...])))
(s/def ::Link (sh/map-spec (s/keys :opt [::id])))
```
## **rdfs:subClassOf**
*its* value a **rdfs:subClassOf** *the class*
If subClassOf links to an other definition we map range same as **a**.
Example:
```ttl
as:Activity rdfs:subClassOf as:Object ;
```
Maps to
```clojure
(s/def ::Object ...)
(s/def ::Activity
(s/and
...
::Object
...))
```
# Further infos
## RDF/S
### range (https://www.w3.org/TR/rdf12-schema/#ch_range)
"P rdfs:range C" indicates that:
1. P is an instance of the class rdf:Property
2. C is an instance of the class rdfs:Class
3. all the resources denoted by the objects of triples whose predicate is P are instances of the class C.
=>Bedeutet(?): Es gilt: Tupel = (Subjekt, Prädikat, Objekt):
=> Wenn (P, rdfs:range, C) & (S, P, C2) => C2 is instance of C
### type (https://www.w3.org/TR/rdf12-schema/#ch_type)