Sven Voigt
Sven Voigt

Reputation: 147

How to allow for dereferencing literals with a datatype in RDF?

The resource description framework (RDF) allows specifying a distributed system of resources. For example, I could specify that I am friends with Bill using the triple <http:example.com/me> <http:example.com/friendsWith> <http:otherExample.com/Bill>. And "http:otherExample.com/Bill" could be dereferenced if it turns out that "http:otherExample.com/Bill" is an rdf resource (e.g., application/rdf+xml). However, what if I want to dereference "http:otherExample.com/Bill" as some literal with some dataType?

The problem is that it seems impossible to specify that the object should be a literal with a datatype at some remote location given the contradiction of specifying rdfs:range of some property to be a datatype and then providing a URI instead. For example, if I specify a property ex:hasProfilePic with rdfs:range xsd:base64Binary, but then I have a triple such that <http:otherExample.com/Bill> ex:hasProfilePic <http://otherExample.com/BillsProfilePic>, wouldn't this be invalid since the range of the specified ex:hasProfilePic is actually a URI resource?

A possible solution is to include a datatype in the dereferenced URL, "data:image/png;base64,iVBORw0KGgoAAAANS...", but this still wouldn't encode a literal in the RDF graph.

Ideally, I think there would be a datatype that is a union of URI and a datatype so that that the literal is interpreted as either based on the content. For example, ex:externalImage could be a union datatype of URI and image and allow specifying literals using datatype notation "http://otherExample.com/BillsProfilePic"^^ex:externalImage. Does such a datatype scheme already exist? Or are there other ways of dereferencing literals with datatypes in RDF?

Upvotes: 1

Views: 243

Answers (1)

IS4
IS4

Reputation: 13217

The world of RDF is not divided into "URI resources" and "literals". A resource is anything, any entity that is worthy of describing or identifying. A certain subset of resources are literal values (class rdfs:Literal); these are entities in the value space of datatypes (rdfs:Datatype), i.e. any entity that can be mapped to by a literal is an instance of rdfs:Literal. URI nodes and literal nodes are merely means of identifying the resources in the universe, either using an address/name, or the value (and datatype, language tag etc.).

This is fine:

<p> rdfs:range xsd:integer .

<a> <p> <http://example.org/some_integer> .

Under RDF Schema (RDFS), it can be entailed that <http://example.org/some_integer> a rdfs:Literal, and there is no contradiction in that ‒ you know that http://example.org/some_integer identifies some integer, and you give a name (the URI) to this integer, just without specifying its value. After all, something like http://dbpedia.org/resource/Graham's_number is perfectly valid to use and there is not much other choice anyway.

It's up to you what you host at the URI, but there are some options:

<> owl:sameAs 10 .

This is recognizable under OWL Full, and easily readable and understandable as well.

<> a rdf:CompoundLiteral ;
  a xsd:integer ;
  rdf:value "10" ;

This seems reasonable to me as well, but might not be as understandable.

{
  "@type": "xsd:integer",
  "@value": "10"
}

Offering this JSON-LD also seems like a viable alternative to me, but I am not sure whether there is something that could interpret this correctly.

Upvotes: 1

Related Questions