Search code examples
sparqlrdfprotege

How to update triples in Protégé?


I'm trying a very simple SPARQL update in both Protégé 4.3 and 5b24:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
DELETE {?s ?p ?o}
WHERE { ?s rdfs:isDefinedBy ?o }

It throws the following error:

An error was thrown: org.openrdf.query.MalformedQueryException: Encountered " "delete" "DELETE "" at line 5, column 1. Was expecting one of: "base" ... "prefix" ... "select" ... "construct" ... "describe" ... "ask" ...

My questions are:

  1. Is any update allowed in Protégé? and if not

  2. What are the alternative file-based ways to achieve this? (including non-SPARQL means in Protégé)


Solution

  • There is an error in your DELETE graph pattern. ?p is not bound in the WHERE clause, so the DELETE graph pattern will fail to find a match. The following would delete triples with rdfs:isDefinedBy as the property:

    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    DELETE { ?s rdfs:isDefinedBy ?o }
    WHERE { ?s rdfs:isDefinedBy ?o }
    

    Guaranteed to work for TopBraid Composer, and could work for Protégé.