2017-06-02 4 views
2

Ich speichere einige Daten in meinem Ontologie-Modell in Protege mit Hilfe einer SPARQL UPDATE 'Einfügen' -Operation. Unten ist die Aktualisierungsabfrage.Lösche leere Knoten aus der Ontologie durch SPARQL UPDATE

PREFIX test: <http://www.semanticweb.org/muhammad/ontologies/2017/2/untitled-ontology-14#> 
insert { 
    [] test:Kpi_Variable ?s ; 
    test:hasValue_ROB4 ?p ; 
    test:hasTime ?now . 
} 
where { 

    values (?s ?p) { 
     (test:Actual_Production_Time 33) 
    } 
    bind (now() as ?now) 
} 

Es speichert im rdf Graph in folgender Weise:

[ test:Kpi_Variable test:Actual_Production_Time ; 
    test:hasTime  "2017-06-02T14:40:33.187+03:00"^^xsd:dateTime ; 
    test:hasValue_ROB4 33 
] . 

Jetzt möchte ich mit dem 'Löschen' Betrieb dieses Feld leer Knoten löschen. Ich habe viele Möglichkeiten ausprobiert, aber das hat nicht funktioniert. Irgendwelche Vorschläge?

Antwort

1

Mit DELETE:

PREFIX test: <http://www.semanticweb.org/muhammad/ontologies/2017/2/untitled-ontology-14#> 

DELETE 
    { 
    ?b test:Kpi_Variable ?s ; 
     test:hasValue_ROB4 ?p ; 
     test:hasTime ?t . 
    } 
WHERE 
    { 
    ?b test:Kpi_Variable ?s ; 
     test:hasValue_ROB4 ?p ; 
     test:hasTime ?t . 
    FILTER (?t < now()) 
    FILTER (isBlank(?b)) 
    # ... 
    VALUES (?s ?p) { (test:Actual_Production_Time 33) } 
    } 

Mit DELETE WHERE:

PREFIX test: <http://www.semanticweb.org/muhammad/ontologies/2017/2/untitled-ontology-14#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
DELETE 
WHERE 
    { 
    ?s test:Kpi_Variable test:Actual_Production_Time ; 
     test:hasValue_ROB4 33 ; 
     test:hasTime "2017-06-00T00:00:00.000+00:00"^^xsd:dateTime . 
    } 

Blank Knoten und Knoten leere Etiketten (sowie FILTER etc.) can not in DELETE WHERE verwendet werden.