Re: Assigning values to variables

On Wed, Aug 23, 2006 at 08:46:29 +1000, Luke Steller wrote:
> 
> Hi All,
> 
> Is it possible to assign a value to a variable, apart from using
> pattern matching? More specifically, for instance is it possible to
> assign a literal - say a double returned by a function (custom
> function) to a variable, which in turn is returned by the query. For
> me it would be useful to have a query like:
> 
> PREFIX myfn: <java:com.luke.distance.>
> PREFIX ps: <http://luke#>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> SELECT ?printer ?distance
> WHERE
> {
>    ?printer rdf:type ps:InkJetPrinterOperational.
>    ?distance = myfn:LatLongDistance("-38.15291", "145.135775",
> "-38.152197", "154.135783", "K")
> }
> 
> which returns the printer individual URI and the distance (a double).
> 
> 
> Is anything like this possible?

An alternative would be SELECT expressions, but those aren't in the spec
either:

PREFIX myfn: <java:com.luke.distance.>
PREFIX ps: <http://luke#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?printer, myfn:LatLongDistance("-38.15291", "145.135775",
"-38.152197", "154.135783", "K")
WHERE
{
   ?printer rdf:type ps:InkJetPrinterOperational.
}

Some engines (including Jena I think) support predicate functions, ala:

PREFIX myfn: <java:com.luke.distance.>
PREFIX ps: <http://luke#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?printer ?distance
WHERE
{
   ?printer rdf:type ps:InkJetPrinterOperational.
   ?distance myfn:LatLongDistance [
	myfn:lat1 -38.15291;
        myfn:long1 145.135775;
        myfn:lat2 -38.152197;
	myfn:long2 154.135783;
	myfn:thing "K";
    ]
}

Or something similar.

- Steve

Received on Wednesday, 23 August 2006 11:00:25 UTC