鉴于此 RDF:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rdf:RDF [<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
<!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>]>
<rdf:RDF xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dnr="http://www.dotnetrdf.org/configuration#"
xml:base="http://www.example.org/"
xmlns:ns1="http://www.example.org/startTime"
xmlns:ns2="http://www.example.org/endTime">
<rdf:Description rdf:about="Fadi">
<ns0:eat xmlns:ns0="http://example.org/">Apple</ns0:eat>
<ns1:startTime>00:01:38</ns1:startTime>
<ns2:endTime>00:01:39</ns2:endTime>
</rdf:Description>
</rdf:RDF>
我正在尝试进行 sparql 查询,但是当我进行此查询时:
SELECT * WHERE { { ?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } }
我得到答案。但是当我尝试这个时:
SELECT * WHERE { ?s ?p ?o . FILTER (regex(?o, 'Apple','i')) }
我不明白。
我需要通过查询获取 startTime 和 endTime,我该怎么写?!
包括来自 OP 注释的代码
Graph myGraph = new Graph();
FileLoader.Load(myGraph, "C:\\Users\\hasoOn\\Desktop\\tt.RDF");
TripleStore store = new TripleStore();
store.Add(myGraph);
SparqlQueryParser parser = new SparqlQueryParser();
SparqlQuery q = parser.ParseFromString("PREFIX ex: <example.org/>; SELECT * WHERE { ex:Fadi ?p ?o }");
SparqlResultSet results = (SparqlResultSet)store.ExecuteQuery(q);