adding triples in 4store

1.3k views Asked by At

here url_add is a link that contains the rdf triples that i want to store in 4store.but if i pass url_add as an argument it generates Relative URIerror .

so what is the way in which i can pass url_add as an argument only.

response = store.add_from_uri('url_add')

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/lib/python2.7/dist-packages/django_gstudio-0.3.dev-py2.7.egg/gstudio/testing1.py", line 152, in

response = store.add_from_uri('url_add')

File "/usr/local/lib/python2.7/dist-packages/django_gstudio-0.3.dev-py2.7.egg/gstudio/HTTP4Store/HTTP4Store.py", line 74, in add_from_uri

r_obj = self.rh.GET(uri, headers=headers)

File "/usr/local/lib/python2.7/dist-packages/django_gstudio-0.3.dev-py2.7.egg/gstudio/HTTP4Store/utils.py", line 53, in GET

return self._request("%s" % (path), method="GET", headers=headers)

File "/usr/local/lib/python2.7/dist-packages/django_gstudio-0.3.dev-py2.7.egg/gstudio/HTTP4Store/utils.py", line 92, in _request

resp, content = self.h.request(path, method, headers=headers, body=data)

File "/usr/lib/python2.7/dist-packages/httplib2/init.py", line 1297, in request (scheme, authority, request_uri, defrag_uri) = urlnorm(uri)

File "/usr/lib/python2.7/dist-packages/httplib2/init.py", line 204, in urlnorm raise RelativeURIError("Only absolute URIs are allowed. uri = %s" % uri)

RelativeURIError: Only absolute URIs are allowed. uri = url_add

1

There are 1 answers

1
William Greenly On

What is the value of your URL

It is throwing an exception because you are passing a relative url instead of an absolute (you probably have something like "../../directory/filename.rdf"

If your url is an HTTP url e.g (http://host/filename.rdf) and dereferenceable then you can also use the LOAD directive as part of SPARQL update. So that simply means exectuting a SPARQL query (in the same way you execute a SPARQL query using 4store) using the following expression:

LOAD <http://host/filename.rdf>
INTO GRAPH <http://optional-name-of-graph>