From: Penny, C. <Chr...@ds...> - 2014-01-13 06:04:07
|
UNCLASSIFIED Hi All, It appears as though the fragment part (# onwards) of the graphs BaseUri is not being saved to the Fuseki server. Below is a quick example to demonstrate what I mean. private void graphURIFragmentProblemExample(string fusekiTripleStore) { //Setup graph IGraph graph = new Graph(); graph.BaseUri = new Uri("http://test.com/test#graph1"); graph.NamespaceMap.AddNamespace("data", UriFactory.Create("http://test.com/test#")); //Create nodes and a tuple IUriNode subject1Node = graph.CreateUriNode("data:subject1"); IUriNode object1Node = graph.CreateUriNode("data:object1"); IUriNode subject2Node = graph.CreateUriNode("data:subject2"); IUriNode object2Node = graph.CreateUriNode("data:object2"); IUriNode predicateNode = graph.CreateUriNode("data:predicate"); graph.Assert(new Triple(subject1Node, object1Node, predicateNode)); graph.Assert(new Triple(subject2Node, object2Node, predicateNode)); //Print out local graph System.Console.WriteLine("Printing local graph"); CompressingTurtleWriter writer = new CompressingTurtleWriter(); var sw = new System.IO.StringWriter(); writer.Save(graph, sw); Console.WriteLine(sw.ToString()); //Save graph to triplestore FusekiConnector store = new FusekiConnector(new Uri(fusekiTripleStore)); store.SaveGraph(graph); //Query store for all data, including the graph it belongs to StringBuilder sb = new StringBuilder(); sb.Append("select ?graph ?subject ?predicate ?object"+Environment.NewLine); sb.Append("where" + Environment.NewLine); sb.Append("{" + Environment.NewLine); sb.Append("GRAPH ?graph" + Environment.NewLine); sb.Append("{" + Environment.NewLine); sb.Append("?subject ?predicate ?object" + Environment.NewLine); sb.Append("}" + Environment.NewLine); sb.Append("}" + Environment.NewLine); Object results = store.Query(sb.ToString()); SparqlResultSet rset = (SparqlResultSet)results; //Print results System.Console.WriteLine("Printing query results"); foreach (SparqlResult r in rset) { System.Console.WriteLine(r.ToString()); } } Output: Printing local graph @base <http://test.com/test#graph1>. @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. @prefix xsd: <http://www.w3.org/2001/XMLSchema#>. @prefix data: <http://test.com/test#>. <http://test.com/test#subject1> <http://test.com/test#object1> <http://test.com/test#predicate>. <http://test.com/test#subject2> <http://test.com/test#object2> <http://test.com/test#predicate>. Printing query results ?graph = http://test.com/test , ?subject = http://test.com/test#subject1 , ?predicate = http://test.com/test#object1 , ?object = http://test.com/test#predicate ?graph = http://test.com/test , ?subject = http://test.com/test#subject2 , ?predicate = http://test.com/test#object2 , ?object = http://test.com/test#predicate As can be seen, the #graph1 component of the graph's URI hasn't been bound to the ?graph variable of the query (although it is present in the local graph object). Additionally, I tried doing the above with Apache-Jena components. Using s-query to execute following query confirms the missing fragment from the graph URI: Command line: ${JENA_HOME}/s-query --service ${FUSEKI_SERVER}/query --query ${TURTLE_HOME}/query.arq Where query.arq contains the query: select ?g ?s ?p ?o where { GRAPH ?g { ?s ?p ?o . } } The results are as follows (note the missing #graph1): { "head": { "vars": [ "g" , "s" , "p" , "o" ] } , "results": { "bindings": [ { "g": { "type": "uri" , "value": "http://test.com/test" } , "s": { "type": "uri" , "value": "http://test.com/test#subject1" } , "p": { "type": "uri" , "value": "http://test.com/test#object1" } , "o": { "type": "uri" , "value": "http://test.com/test#predicate" } } , { "g": { "type": "uri" , "value": "http://test.com/test" } , "s": { "type": "uri" , "value": "http://test.com/test#subject2" } , "p": { "type": "uri" , "value": "http://test.com/test#object2" } , "o": { "type": "uri" , "value": "http://test.com/test#predicate" } } ] } } In an attempt to eliminate Fuseki as a souce of the problem I inserted the same triples into the same graph using Apache-Jena: Command line: ${JENA_HOME}/s-put ${FUSEKI_SERVER}/data http://test.com/test#graph1 named_graph_bug_example.ttl Where "named_graph_bug_example.ttl" contains the following content: PREFIX data: <http://test.com/test#> data:subject1 data:predicate data:object1 . data:subject2 data:predicate data:object2 . Rerunning the original command now shows the new tuples in a graph with the correct URI (alongside the old tuples): { "head": { "vars": [ "g" , "s" , "p" , "o" ] } , "results": { "bindings": [ { "g": { "type": "uri" , "value": "http://test.com/test" } , "s": { "type": "uri" , "value": "http://test.com/test#subject1" } , "p": { "type": "uri" , "value": "http://test.com/test#object1" } , "o": { "type": "uri" , "value": "http://test.com/test#predicate" } } , { "g": { "type": "uri" , "value": "http://test.com/test#graph1" } , "s": { "type": "uri" , "value": "http://test.com/test#subject1" } , "p": { "type": "uri" , "value": "http://test.com/test#predicate" } , "o": { "type": "uri" , "value": "http://test.com/test#object1" } } , { "g": { "type": "uri" , "value": "http://test.com/test#graph1" } , "s": { "type": "uri" , "value": "http://test.com/test#subject2" } , "p": { "type": "uri" , "value": "http://test.com/test#predicate" } , "o": { "type": "uri" , "value": "http://test.com/test#object2" } } , { "g": { "type": "uri" , "value": "http://test.com/test" } , "s": { "type": "uri" , "value": "http://test.com/test#subject2" } , "p": { "type": "uri" , "value": "http://test.com/test#object2" } , "o": { "type": "uri" , "value": "http://test.com/test#predicate" } } ] } } It's entirely possible that I've misunderstood how to set a graph's URI in dotnetRDF, but it looks like there may be another problem here. Let me know if you need any more information. Regards, Chris. IMPORTANT: This email remains the property of the Department of Defence and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email. |