Follow your nose

From OpenOrg
Jump to: navigation, search

RDF Documents

Ideally all the main information required for a service should be available from the same RDF document. Most notably trivial things like rdfs:label and rdf:type.

The normal semantic web approach to finding more information is to:

  1. Resolve the URI to see if it gets more triples
  2. Follow any seeAlso relationships from the URI to see if it gets more triples.

However if you want to explicitly indicate the URL of a source of additional data, that can be useful and save worthless lookups (eg. resolving a seeAlso link, only to end up with a 50Mb PDF document)

To indicate that more triples are available about URI-X use the following pattern. It is assumed that RDF-URL will resolve to a document containing triples in one of following formats: RDF+XML, Turtle, N3, N-Triples. <syntaxhighlight lang="xml">

 <rdf:Description rdf:about="...URI-X...">
   <rdfs:label>the name of the thing for which more data is available</rdfs:label>
   <rdfs:seeAlso rdf:resource="...RDF-URL..." />
 </rdf:Description>

 <rdf:Description rdf:about="...RDF-URL...">
   <rdf:type rdf:resource="http://purl.org/xtypes/Document-RDFSerialisation" />
 </rdf:Description>

</syntaxhighlight>

  • If many URIs all are seeAlso to the same URL then the rdf:type bit is only required once.
  • This pattern is particularly recommended if many URIs from a document all redirect to the same final RDF document.
  • This pattern also allows you to avoid minting your own URIs for things which already have them (eg. UK railway stations), but still provide additional information about them.
  • The class http://purl.org/xtypes/Document-RDFSerialisation indicates that the URL contains some triples in one of the standard formats.

SPARQL

If your RDF is getting complicated, it's probably time to import it into a SPARQL endpoint. If you provide a link to the SPARQL at the top of an RDF document, then you may omit this pattern and should (if possible) not import these into SPARQL, where they will have no value.

The following predicate should be used to link a document to the relevant endpoint (and also in voID descriptions too)

<syntaxhighlight lang="xml">

   <void:sparqlEndpoint rdf:resource="...URL-of-SPARQL-Endpoint..." />

</syntaxhighlight>

A SPARQL endpoint should contain a list of its primary datasets and this should be discoverable using the following query:

SELECT ?dataset ?label ?homepage {
  ?dataset <http://rdfs.org/ns/void#sparqlEndpoint> <URL-OF-SPARQL-ENDPOINT> 
  OPTIONAL { ?dataset <http://www.w3.org/2000/01/rdf-schema#label> ?label }
  OPTIONAL { ?dataset <http://xmlns.com/foaf/0.1/homepage> ?homepage }
}

(replacing URL-OF-SPARQL-ENDPOINT with the actual URL of the endpoint)

Example