I want to get all classes of my ontology. This is a part of my ontology file in RDF/XML format created by Protege:
<!-- http://www.w3.org/2002/07/owl#aqua -->
<Class rdf:about="&owl;aqua"/>
<!-- http://www.w3.org/2002/07/owl#varioPerfect -->
<Class rdf:about="&owl;varioPerfect"/>
I wrote this query, which works properly in Protege, but when I use it in dotNetRDF it returns the full URI of the class instead of just its name.
public string[] ontologysearch()
{
List<string> list = new List<string>();
TripleStore store = new TripleStore();
Graph mygraph = new Graph();
mygraph.LoadFromFile("D:/msc/search-engine/project/catalogXML.owl");
store.Add(mygraph);
string sparqlQuery1 = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
+ "PREFIX owl: <http://www.w3.org/2002/07/owl#>"
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>"
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"
+ "SELECT distinct ?cls1"
+ " WHERE{"
+ " ?cls1 a owl:Class .}";
SparqlQueryParser sparqlParser = new SparqlQueryParser();
SparqlQuery query = sparqlParser.ParseFromString(sparqlQuery1);
InMemoryDataset ds = new InMemoryDataset(mygraph);
//Get the Query processor
ISparqlQueryProcessor processor = new LeviathanQueryProcessor(ds);
Object results = processor.ProcessQuery(query);
if (results is SparqlResultSet)
{
SparqlResultSet r = results as SparqlResultSet;
foreach (SparqlResult res in r)
{
list.Add(res["cls1"].ToString());
}
}
return list.ToArray();
}
The result I expected was just "aqua" but in fact is "http://www.w3.org/2002/07/owl#aqua". Why does this happen, and how can I retrieve the name instead?