You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Elli Schwarz <el...@yahoo.com> on 2012/07/19 17:28:49 UTC

Named graph URI problem

Hello,


I'm using the Jena API to connect to Fuseki via a DatasetAccessor, and I've noticed that when I attempt to create a named graph with a URI that contains the # sign that the URI is cut off from the # sign and on.

In other words, I have this code:
         Model m = ModelFactory.createDefaultModel();
         m.add(ResourceFactory.createResource("http://example.com/foo#test"),
         ResourceFactory.createProperty("http://example.com/prop"), "foo");

         DatasetAccessor ds = DatasetAccessorFactory.createHTTP("http://localhost:3030/ds/data");
         ds.add("http://mygraph.com/foo#test", m);     //the characters #test are cut off in the named graph URI

         Model otherModel = ds.getModel("http://mygraph.com/foo#test");  //this doesn't work since the graph is actually namedhttp://mygraph.com/foo

When I look at the named graphs created in Fuseki with a SPARQL query, I also see that the graph is named <http://mygraph.com/foo> without the trailing #test. Is that on purpose? While I understand that the # is used as an anchor tag to represent the position within a document, and therefore perhaps I shouldn't use # in a named graph URI since it represents an entire "document", it is still a valid URI so I find it weird that it gets cut off.


Thank you,
 Elli 

Re: Named graph URI problem

Posted by Andy Seaborne <an...@apache.org>.
On 19/07/12 16:28, Elli Schwarz wrote:
> Hello,
>
>
> I'm using the Jena API to connect to Fuseki via a DatasetAccessor, and I've noticed that when I attempt to create a named graph with a URI that contains the # sign that the URI is cut off from the # sign and on.
>
> In other words, I have this code:
>           Model m = ModelFactory.createDefaultModel();
>           m.add(ResourceFactory.createResource("http://example.com/foo#test"),
>           ResourceFactory.createProperty("http://example.com/prop"), "foo");
>
>           DatasetAccessor ds = DatasetAccessorFactory.createHTTP("http://localhost:3030/ds/data");
>           ds.add("http://mygraph.com/foo#test", m);     //the characters #test are cut off in the named graph URI
>
>           Model otherModel = ds.getModel("http://mygraph.com/foo#test");  //this doesn't work since the graph is actually namedhttp://mygraph.com/foo
>
> When I look at the named graphs created in Fuseki with a SPARQL query, I also see that the graph is named <http://mygraph.com/foo> without the trailing #test. Is that on purpose? While I understand that the # is used as an anchor tag to represent the position within a document, and therefore perhaps I shouldn't use # in a named graph URI since it represents an entire "document", it is still a valid URI so I find it weird that it gets cut off.
>
>
> Thank you,
>   Elli
>

(note to self - move the DatasetAccessor code into ARQ)

The client code is failing to %-encode the graph name (the SOH scripts 
do the right thing).

JENA-282 - and fixed, since it turned out only one point needed fixing.

(And, yes, using a # fragment is a bit odd)

By the way, have you seen Stephen's jena-client project?  It's an 
experimental new client interface to working with RDF data in a 
repository-like fashion.

http://s.apache.org/vzm

https://svn.apache.org/repos/asf/jena/Experimental/jena-client/


	Andy