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