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 ) ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With