From: Blom, J.J.C. (Jaap) <jb...@cr...> - 2010-06-20 06:56:53
|
Hi, Wel for a number of reasons: A) It reads a little easier to track a blank node with a readable label in respect to a UID. B) Data received from sources not using NG4J/Jena (and thus not supporting this "rule" of uniquely naming blank nodes) C) Because I should be able to do it. The RDF defenitions specify that two blank nodes with the same label in different graphs should not be considered the same node on that fact alone. (Sorry if I seem to be ranting here) Like I said I doubt this is a bug from NG4J (I think it is Jena in this case), but since there are some elements from NG4J involved I need to be sure of this. Thanks, Jaap Blom -----Original Message----- From: Olaf Hartig [mailto:ha...@in...] Sent: zaterdag 19 juni 2010 9:24 To: Blom, J.J.C. (Jaap) Cc: ng4...@li... Subject: Re: [namedgraphs] SPARQL over named graphs with blank nodes 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. http://www.croon.nl/disclaimer http://www.croon.nl/inkoopvoorwaarden Kamer van Koophandel Rotterdam nr. / Chamber of Commerce Rotterdam no.: 24002312 |