Hi Dave, Thanks for the answer. Yes, as the plan B I was thinking about in that direction (I didn't know about ResourceUtils#renameResource utility method, thanks!).
However, looking at the source it seems a bit expensive operation, isn't it? So if I can defer reading the data into a model until I know the base URI, that would be the best and if not, the solution you proposed works for me. Best Regards, Nandana On Wed, Jul 9, 2014 at 6:06 PM, Dave Reynolds <[email protected]> wrote: > On 09/07/14 16:53, Nandana Mihindukulasooriya wrote: > >> Hi, >> >> I know I can set the base when building from a model with RDF data (and >> the >> serialization of RDF has relative URIs). >> >> Model#read(InputStream in, String base, String lang)::Model >> >> According to the Javadoc "If the base is the empty string, then relative >> URIs will be retained in the model. This is typically unwise and will >> usually generate errors when writing the model back out.". >> >> I was wondering whether it is possible to defer setting the base such that >> when the model is read they retain as relative URIs in the model but later >> on (but before writing the model) I can set the correct base so that when >> they are written they will be serialized correctly? >> > > Short ans: no. > > Longer ans: > > The URIs in the model are supposed to be absolute so as the javadoc says, > forcing relative URIs in there is a bad idea. > > However, it is possible rename resources in a model using > ResourceUtils#renameResource. So it is possible to take a model, list all > the unique subject and object resources in it, for each of those if they > are relative work out the correct absolute URI, then run a series of > renameResource calls to do the mapping. You will then have a model with > correct absolute URIs that you can write out. > > Just a small matter of programming. > > Dave > >
