Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating URIs in Jena for RDF

I am generating an RDF file programmatically in Jena i.e. when I am inserting data in the rdf (instances) i need to have an unique URI (which will refer to the resource), somewhat like primary key in rdbms. I want to know is it posiible to do in Jena like when I will create Resource for an instance I can generate the URI ?

Example :

Resource resAnswer = ModelCreation.md.createResource(RDFResourcesURI.Answer_Resource_URI + answer.getAnswer_id());

-- here I am hardcoding (or user input) the answer_id and then appending to a predefined URI. Instead of hardcoding can I generate it (like auto increment in mysql ) ?

like image 405
pc_ Avatar asked Oct 11 '11 06:10

pc_


1 Answers

There's a URI scheme for UUIDs http://www.ietf.org/rfc/rfc4122.txt, so you can use that to turn UUIDs into URIs, e.g. e.g. urn:uuid:2238b240-f3eb-11e0-be50-0800200c9a66

Alternatively you can just append the UUID to some prefix, e.g. http://my.example/id/2238b240-f3eb-11e0-be50-0800200c9a66

HTTP based onetime URIs are good if you want to be able to make it resolvable.

like image 97
Steve Harris Avatar answered Oct 11 '22 23:10

Steve Harris