On 18/01/12 08:22, Stephan Zednik wrote:
Hi,

I would like to execute a describe query on a variable that is determined by 
its id, which I would like to pass to the query programmatically using ARQ.

Lets say the query would look something like this:

PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX dc:<http://purl.org/dc/elements/1.1/>
PREFIX dcterms:<http://purl.org/dc/terms/>
PREFIX ex:<http://example.com/example>

DESCRIBE ?foo
WHERE { ?foo a ex:Foo .
        ?foo dcterms:identifier ?id .
}

and I would like to load the query from a file and pass a value in for ?id.

What is the best way to do this?

I looked at setInitialBinding( ...) on the QueryExecution but I am not sure it 
will do what I want.
from the javadoc:
void setInitialBinding(QuerySolution binding)
Set the initial association of variables and values. May not be supported by 
all QueryExecution implementations.
I am not sure setInitialBinding( ... ) is supported by execDescribe( ... ) 
because I don't think it makes sense for the ?id to be a variable in a describe 
query that resolves to a datatype.  That, and also because execDescribe( ... ) 
does not return a ResultSet.

The QueryExecution that does not suppor tit is the remote one (because the app probably should be using BINDINDS).


Will using a QuerySolution with an mapping of "id" to the application 
determined value work?

Have you tried?  It should work.



Thanks,
--Stephan

The other approach is to store a query template:  example:

DESCRIBE ?foo
WHERE { ?foo a ex:Foo .
        ?foo dcterms:identifier ?{id} .
}

and do a string replacement on on "?{id}"

        Andy

Reply via email to