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#";
    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

Reply via email to