Is there any Library for .NET that returns SPARQL results in some structured List instead of standard XML format? I am using SemWeb. I could not find any such method.
views:
31answers:
1
+1
Q:
Library for .NET that returns SPARQL results in some structured List instead of standard XML format?
+1
A:
SemWeb does appear to provide the building blocks for what you want. Looking at the documentation it seems QueryResultSink
is what you want. You could build a list of results using that, or work directly with the results as they arrive.
Alternatively try dotnetrdf. This introduction shows that queries result in a SparqlResultSet that you can iterate through.
From the examples:
TripleStore store = new TripleStore();
// ...data...
Object results = store.ExecuteQuery("SELECT * WHERE {?s ?p ?o}");
if (results is SparqlResultSet) {
SparqlResultSet rset = (SparqlResultSet)results;
foreach (SparqlResult result in rset) {
Console.WriteLine(result.ToString());
}
}
Yes with SemWeb you can write your own QueryResultSink implementation to get the results back in some other form if you want a list of results. If you use my dotNetRDF library as comment_bot suggests you get a SparqlResultSet which you can iterate through and you can index into each SparqlResult object using variable names or integer index
RobV
2010-04-08 16:11:00
@RobV is there a way to remove language tags like @en and type tags like ^^http://www.w3.org/2001/XMLSchema#int. from results?Offcource I can manipulate strings but is there any way availabel in library?
Taz
2010-04-29 07:31:21
If you know that a value for one variable is a LiteralNode (try using the `NodeType` property or doing `x is LiteralNode`) you can cast it to a LiteralNode and then use the `Value` property to just get the string value excluding the datatype/language tag
RobV
2010-04-29 12:50:15