Re: SPARQL question: get distinct list of datatypes used for literals

Seaborne, Andy wrote:
> 
>> -----Original Message-----
>> From: public-rdf-dawg-comments-request@w3.org [mailto:public-rdf-dawg-
>> comments-request@w3.org] On Behalf Of Lee Feigenbaum
>> Sent: 21 August 2008 18:26
>> To: al@jku.at
>> Cc: Semantic Web; public-rdf-dawg-comments@w3.org
>> Subject: Re: SPARQL question: get distinct list of datatypes used for
>> literals
>>
>>
>> Andreas Langegger wrote:
>>
>>> Hi there,
>>>
>>> maybe sb can tell me if this is still possible: I'd like to fetch all
>>> datatype URIs used for object literals in a dataset. There is the
>>> dataset predicate which can be used in filter expressions to filter
>>> literals to a known datatype like xsd:string: FILTER(datatype(?val) =
>>> xsd:string).
>>>
>>> But can I bind the value to a variable somehow? With a filter it can't
>>> work (consider FILTER(datatype(?val) = ?dt) where ?val is bound to
>>> literal values and ?dt should give me the type). I could use property
>>> functions, but I'd like to stay with SPARQL specs. Maybe there is a way
>>> to do it I just can't see...
>>>
>>> thanks,
>>> AndyL
>> AndyL,
>>
>> There's no way to do this (select functions of values from a
>> graph/dataset) in the SPARQL specification.
>>
>> As you said, various implementations provide extensions that will do
>> this. Please see:
>>
>> http://esw.w3.org/topic/SPARQL/Extensions/Selecting_Expressions
>>
>> Lee
>>
> Yes - in strict SPARQL (simple entailment), a query can only return RDF terms found in the graph itself.
> 
> 
> I'm sure someone can correct me, but D-entailment comes close: sec 5.1 of RDF sSemantics has the text:
> 
> """
> Say that an RDF graph recognizes a datatype URI reference aaa when the graph rdfs-entails a datatyping triple of the form
> 
> aaa rdf:type rdfs:Datatype .
> """

In which case, the query that AndyL wants would be:

SELECT ?dt {
   :s :p ?val .
   ?dt a rdfs:Datatype .
   FILTER (datatype(?val) = ?dt) .
}

Offhand, I don't know of any SPARQL implementations that do this: at the 
same time, I don't know of any that don't, other than my own :-D

For my own edification, I'd be very interested in learning of engines 
that support this application of D-entailment.

Lee

Received on Thursday, 21 August 2008 22:13:39 UTC