On datashapes as a complement to vocab


#1

There have been some discussions about vocabularies in the Gitter channels the past few hours. So I thought I would jot some of my thoughts down in the forum.

For interoperability we need to re-use data shapes or at the very least resolve them through some sort of equivalence process. To illustrate, I will use one of my bookmarks that was created with the Markbook application. Here it is:

@prefix : <#>.
@prefix terms: <http://purl.org/dc/terms/>.
@prefix bookm: <http://www.w3.org/2002/01/bookmark#>.
@prefix XML: <http://www.w3.org/2001/XMLSchema#>.
@prefix n0: <http://xmlns.com/foaf/0.1/>.
@prefix c: </profile/card#>.

<#0.08765609738909719>
    a bookm:Bookmark;
    terms:created "2019-02-12T07:32:50.643Z"^^XML:dateTime;
    terms:title "Style sheets in code";
    bookm:recalls n1:constructable-stylesheets;
    n0:maker c:me.

I first noticed that it suggested that it was a bookm:Bookmark, yet the example Bookmark used different properties other than bookm:recalls. So I decided to describe it from scratch in SHACL.

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sol: <http://solid.org/shapes/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix terms: <http://purl.org/dc/terms/>.
@prefix XML: <http://www.w3.org/2001/XMLSchema#>.
@prefix bookm: <http://www.w3.org/2002/01/bookmark#>.

sol:BookmarkShape
    rdf:type rdfs:Class;
    rdf:type sh:NodeShape;
    rdfs:comment "A bookmark refering to a website."^^rdf:HTML;
    rdfs:label "Bookmark";
    sh:targetClass sol:Bookmark;
    owl:equivalentClass <http://www.w3.org/2002/01/bookmark#Bookmark>;
    sh:property [
        sh:path foaf:maker;
        sh:description "Person creating the bookmark";
        sh:name "Created By";
        sh:nodeKind sh:IRI;
    ];
    sh:property [
        sh:path terms:created;
        sh:name "Date Created";
        sh:description "The date the bookmark was created";
        sh:datatype XML:dateTime;
    ];
    sh:property [
        sh:path terms:title;
        sh:name "Title";
        sh:description "The title of the bookmark";
        sh:datatype xsd:string;
    ];
sh:property [
        sh:path bookm:recalls;
        sh:name "Web Site";
        sh:description "The URL of the web site";
        sh:nodeKind sh:IRI;
    ].

The example bookmark would not validate against this shape and needed to have the type set to a sol:Bookmark where the prefix sol is @prefix sol: <http://solid.org/shapes/> .

I feel this is more accurate than a bookm:Bookmark as it contains the wider range of properties.

But it also highlights that just knowing the vocab is not sufficient for inter-operability. Rather we should also publish the data shape so that we can have apps decide how to cater for differences between the shapes in different apps.

Further, to facilitate a ‘follow your nose’ approach, I think we need to decide on a standard way of discovering the data shape. In this case, for example, we could include it in the typeIndex. So you could go from settings–>prefs–>public typeIndex–>Bookmark where you find a triple to lets you know which data shape has been used.

I also feel, we should curate common data shapes in the same way that schema.org curates them for json-ld.

I am interested in any feedback you care to give.


#2

No feedback on the content, but want to say that even having not looked into shapes/shacl yet, it was clear and helpful. Thanks.


#3

I think an alternative is share RDF manipulating code to npm, so apps dealing with similar business can use same Typescript schema (inside that package)