2

I have a problem when reading RDF-XML into a Jena model. I use

FileManager fileManager = FileManager.get();
Model model = fileManager.loadModel(url);

Resource URIs like

http://kulturarvsdata.se/resurser/aukt/geo/county#01

turn out like

http://kulturarvsdata.se/resurser/aukt/geo/01

in the resources in the Jena model, i.e. the URI fragment part is stripped away.

I have tried to provide the base URI ecplicitly to Jena:

Model model = fileManager.loadModel(url, "http://kulturarvsdata.se/resurser/aukt/geo/county#", "RDF/XML");

but that makes no difference.

Have I misunderstiod something or is there a way to convince Jena to preserve the URI fragments?

Nils Weinander
  • 2,081
  • 2
  • 15
  • 20

1 Answers1

3

I think your problem is that base URI doesn't work like prefixes in turtle and SPARQL.

http://kulturarvsdata.se/resurser/aukt/geo/county begins:

<rdf:RDF xml:base="http://kulturarvsdata.se/resurser/aukt/geo/county#">
    ...

You then have a resource:

   <County rdf:about="01">...

That rdf:about URI is resolved relative to the provided base http://kulturarvsdata.se/resurser/aukt/geo/county#. And note I said 'resolved' rather than 'concatenated' which is what prefixes do. Resolving 01 relative to the base gives http://kulturarvsdata.se/resurser/aukt/geo/01.

The fragment (#) at the end of base does nothing in practice. What you need to do is replace your abouts with:

<County rdf:about="#01">...

(Essentially you can't use document base to make all links internal. Internal links must use fragments)

user205512
  • 8,798
  • 29
  • 28
  • Thanks! That makes perfect sense. I'll pass this on to the people who manage the dataset. – Nils Weinander Feb 25 '13 at 16:34
  • Minor update, I downloaded the resources and played around, the suggestion worked for resources using rdf:about. Interestingly enough, those using rdf:ID needed the original setup, with the fragment mark in xml:base. I assume there is something buried in the specs that explains why... – Nils Weinander Feb 27 '13 at 08:45
  • 1
    Oh yes, rdf:ID will work (see http://stackoverflow.com/questions/7118326/differences-between-rdfresource-rdfabout-and-rdfid/7119042#7119042). You don't need the fragment in base, however. – user205512 Feb 27 '13 at 08:55
  • Oh well, there I learned something new! I had got an altogether incorrect impression of the semantics of rdf:ID in the first place. – Nils Weinander Feb 27 '13 at 20:48