Top

1.5.38. How can I use SPARUL to add missing triples to a Named Graph?

What?

Use of SPARUL to add missing triples to a Named Graph. For example, an ontology/vocabulary extension.

Why?

A lot of ontologies and vocabularies started life prior to emergence of the Linked Data meme. As a result, many do not include rdfs:isDefinedBy relations (via triples) that associate Classes and Properties in an ontology with the ontology itself, using de-referencable URIs. The downside of this pattern is that Linked Data's follow-your-nose pattern isn't exploitable when viewing these ontologies e.g., when using contemporary Linked Data aware browsers.

How?

If SPARUL privileges are assigned to SPARQL or other accounts associated with SPARQL Endpoint. Or via WebID? protected SPARQL endpoint with SPARUL is granted to SPARQL or specific accounts or WebIDs in a group.

INSERT INTO <LocalNamedGraphIRI>
  { ?s rdfs:DefinedBy <LocalOntologyEntityURI>.
    ?o rdfs:isDefinedBy <http://www.w3.org/ns/auth/acl>. }
FROM <ExtSourceNamedGraphIRI>
WHERE
  {
    ?s a ?o
  }
Example
  1. Load Quad Named Graph via Sponger based query:

    DEFINE get:soft "replace"
    SELECT DISTINCT *
    FROM <http://www.w3.org/ns/auth/acl#>
    WHERE
      {
        ?s ?p ?o
      }
    
  2. Added Triples via SPARUL to Ontology Named Graph:

    INSERT INTO <http://www.w3.org/ns/auth/acl#>
      {  ?s rdfs:DefinedBy <http://www.w3.org/ns/auth/acl>.
         ?o rdfs:DefinedBy <http://www.w3.org/ns/auth/acl>. }
    FROM <http://www.w3.org/ns/auth/acl#>
    WHERE
      {
        ?s a ?o
      }
    
  3. Via Conductor or Command-line iSQL courtesy of SPASQL execute the following statements:

    1. Remove an existing graph:

      SPARQL
      CLEAR GRAPH <http://www.w3.org/ns/auth/acl/> ;
      
      SPARQL
      CLEAR GRAPH <http://www.w3.org/ns/auth/acl> ;
      
      SPARQL
      CLEAR GRAPH <http://www.w3.org/ns/auth/acl#> ;
      
    2. Load a new graph:

      SPARQL
      LOAD <http://www.w3.org/ns/auth/acl> ;
      
    3. Add missing rdfs:isDefinedBy triples via SPARUL:

      SPARQL
      INSERT INTO <http://www.w3.org/ns/auth/acl>
        {  ?s rdfs:DefinedBy <http://www.w3.org/ns/auth/acl>.
           ?o rdfs:DefinedBy <http://www.w3.org/ns/auth/acl>. }
      FROM <http://www.w3.org/ns/auth/acl>
      WHERE
        {
          ?s a ?o
        } ;
      
  4. Verification: Access the following url:

    http://<cname>/describe/?uri=http://www.w3.org/ns/auth/acl>