So to summarize:

1) URIs in  RDF inside jena are always absolute
2) the "base" argument in a read provides the base to make relative URIs
absolute.
3)  If  the "base" on a read is not provided some reasonable value will be
constructed (e.g. file name) so there is no way to create an internal
representation of a relative URI through the read() methods.
4) the "base" argument in a write provides a mechanism to convert absolute
URIs to relative URIs in that URIs that have a namespace matching the base
are written as relative URIs
5) if the "base" is not provided no conversion to relative URIs will be
performed.


Does that cover it?

Claude



On Mon, Sep 16, 2013 at 9:23 PM, Andy Seaborne <[email protected]> wrote:

> On 16/09/13 19:33, Claude Warren wrote:
>
>> So on read the base converts all relative URIs to the be grounded in the
>> base.
>> Is there any way to read a file with relative URIs and have the URIs
>> remain
>> relative?
>>
>
> Not and be legal RDF.
> RDF is based on absolute URIs in the abstract data model. Relative URIs
> only legally exist in concrete syntax.
>
> The API can create bad RDF as well.
>
> The NT parser will read the data, it issues ERRORs but the data is parsed
> and output.  Strictly, it's illegal NT because NT is defined to have
> absolute URIs. TTL resolves them; NT does not.
>
>
>  On write the base converts all relative URIs to be grounded in the base in
>> the output.
>> Is there any way to write a file with relative URIs?
>>
>
> My example has relative URIs in the output.
>
> rdf:about="/s"   No URI scheme - it's a relative URI (it's a rooted path
> but that is a different concept).
> rdf:resource="o"    Relative URI.
>
>
>
>  In the preceeding example if the base were left out of the write would it
>> make any difference in the output since all the URIs are absolute.
>>
>
> Try it!
>
> Yes it makes a different - the output is:
>
>
> <rdf:RDF
>     
> xmlns:rdf="http://www.w3.org/**1999/02/22-rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> "
>     xmlns:ex="http://example/";>
>   <rdf:Description rdf:about="http://example/s";>
>     <ex:p rdf:resource="http://example/**ns/o <http://example/ns/o>"/>
>   </rdf:Description>
> </rdf:RDF>
>
> Relative URIs risk changing data - if you move a file to a new location,
> then URIs in the data are different.  RDF works on the absolute, location
> invariant data as the abstract data.
>
>         Andy
>
>
>> Claude
>>
>>
>> On Sun, Sep 15, 2013 at 11:24 PM, Andy Seaborne <[email protected]> wrote:
>>
>>  On 15/09/13 17:34, Claude Warren wrote:
>>>
>>>  Can someone give me an example where the base is actually used in the
>>>> model.read and model.write calls?  I thought I understood what it does
>>>> but
>>>> I can't seem to construct a unit test that shows it works.
>>>>
>>>> Claude
>>>>
>>>>
>>>>  IIRC if a prefix is available, that is preferred over relative URIs.
>>>
>>> Relative URIs:
>>>
>>> public static void main(String ... argv) throws Exception
>>> {
>>>      Model model = ModelFactory.****createDefaultModel() ;
>>>
>>>      String x = "<s> <p> <http://example/ns/o> ." ;
>>>      StringReader sr = new StringReader(x) ;
>>>      model.read(sr, "http://example/";, "TTL") ;
>>>      model.write(System.out, "N-TRIPLES") ;
>>>      System.out.println("-----") ;
>>>      model.setNsPrefix("ex", "http://example/";) ;
>>>      model.write(System.out, "RDF/XML-ABBREV", "http://example/ns/";) ;
>>> }
>>>
>>>
>>>
>>> <http://example/s> <http://example/p> <http://example/ns/o> .
>>>
>>> so relative URIs were resolved against the base.
>>>
>>> <rdf:RDF
>>>      
>>> xmlns:rdf="http://www.w3.org/****1999/02/22-rdf-syntax-ns#<http://www.w3.org/**1999/02/22-rdf-syntax-ns#>
>>> <htt**p://www.w3.org/1999/02/22-rdf-**syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>> >
>>>
>>> "
>>>      xmlns:ex="http://example/";>
>>>    <rdf:Description rdf:about="/s">
>>>      <ex:p rdf:resource="o"/>
>>>    </rdf:Description>
>>> </rdf:RDF>
>>>
>>> rdf:resource="o" is relative to a base of "http://example/ns/";
>>>
>>>          Andy
>>>
>>>
>>
>>
>>
>


-- 
I like: Like Like - The likeliest place on the web<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Reply via email to