I'm using DotNetRDF (downloaded from BitBucket) to execute SPARQL queries, but I'm getting an exception when using a query with a property path:
The value of a variable in a Set cannot be changed
Here is a portion of the RDF, the SPARQL query, and the C# code that executes the query. I'd expect the query to return id/002
and id/003
.
<owl:Class rdf:about="http://ex.info/id/001">
<rdfs:label xml:lang="en">example data</rdfs:label>
<rdfs:subClassOf>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://ex.info/id/002"/>
<rdf:Description rdf:about="http://ex.info/id/003"/>
<owl:Restriction>
<owl:onProperty rdf:resource="http://ex.info/id/004"/>
<owl:someValuesFrom rdf:resource="http://ex.info/id/005"/>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</rdfs:subClassOf>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select ?superclass where {
<http://ex.info/id/001> (rdfs:subClassOf|(owl:intersectionOf/rdf:rest*/rdf:first))* ?superclass .
filter(!isBlank(?superclass))
}
public List<string> queryData2(string query)
{
IGraph g = new Graph();
FileLoader.Load(g, filePath);
SparqlResultSet results = (SparqlResultSet)g.ExecuteQuery(query);
List<string> output = new List<string>();
foreach (SparqlResult result in results)
{
output.Add(result.ToString());
}
return output;
}