From: Olaf H. <ha...@in...> - 2010-06-19 07:24:38
|
Hey, On Friday 18 June 2010 17:03:54 Blom, J.J.C. (Jaap) wrote: > Hi, > > I'm working on NG4J 0.9.3 and have the following code: > Node graph1 = Node.createURI("http://graph1"); > Node graph2 = Node.createURI("http://graph2"); > Node start = Node.createURI("http://start"); > Node predicate1 = Node.createURI("http://predicate1"); > Node predicate2 = Node.createURI("http://predicate2"); > Node result1 = Node.createLiteral("expected result"); > Node result2 = Node.createLiteral("not expected result"); > NamedGraphSet ngs = new NamedGraphSetImpl(); > ngs.addQuad(new Quad(graph1, start, predicate1, > Node.createAnon(new AnonId("blank")))); ngs.addQuad(new Quad(graph1, > Node.createAnon(new AnonId("blank")), predicate2, result1)); > ngs.addQuad(new Quad(graph2, Node.createAnon(new AnonId("blank")), > predicate2, result2));//*/ String query = > "Select ?target Where\n" + > "{\n" + > " <" + start.getURI() + "> <" + > predicate1.getURI() + "> ?b .\n" + " ?b <" + predicate2.getURI() + > "> ?target\n" + "}"; > System.out.println(query); > Query sparqlQuery = QueryFactory.create(query); > QueryExecution qe = > QueryExecutionFactory.create(sparqlQuery, new NamedGraphDataset(ngs)); > ResultSet results = qe.execSelect(); > while(results.hasNext()) > { > System.out.println(results.next()); > } > System.out.println("done"); > > This gives the following result: > Select $target Where > { > <http://start> <http://predicate1> ?b . > ?b <http://predicate2> $target > } > ( ?target = "expected result" ) > ( ?target = "not expected result" ) > done > > I didn't expect the "not expected result", since it is linked to a blank > node in another graph. Granted the blank nodes have the same label, but > RDF states that blank nodes in different graphs are not linked by their > label. Am I correct in this one and if so is this a NG4J error or a > Jena/ARQ error? I agree that you would expect only the "expected result" and that would be the correct behavior. The issue is that none ever expected to have two blank nodes with the same label in different graphs. Usually, this would never happen because Jena creates new blank node with unique labels whenever it reads an RDF document. Programmatically, you would typically create a Node object that represents your blank node and use this Node object instead of creating new Node objects with the same label. Hence, to me it seems that your example code uses the Jena API in a way it was not intended to be used. Why do you want to do it the way your example code outlines? Greetings, Olaf PS: I cannot answer the other questions you sent to the list because I'm not familiar with that part of NG4J. |