[redland-dev] search condition

Jagdev Bhogal Jagdev.Bhogal at uce.ac.uk
Thu Mar 29 10:09:23 UTC 2007


Dear All

I have not had a response from the help archive to my earlier messages,
so I guess from the sounds of things I can only use a literal value in
the search condition for a query to retrieve specific records

So it is ok to do:

 

const char  *query_string="select ?label, ?comment from
<file:/export/CISR-D/jagdev/okapi/progs/news.rdf> where (?x rdf:type
rdfs:Class) (?x,rdfs:label, ?label), (?x, rdfs:comment, ?comment) and
?label == 'Content:Agent'  using rdf for
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>, rdfs for
<http://www.w3.org/2000/01/rdf-schema#>";

 

but not ok for the condition to have a variable in the comparison eg

.... and ?label==Keyword[i] .....

 

 

 

To overcome this, the only other solution I can think of is to convert
value (which holds the binding value of the query results, see C coding
below ) to a string and use the strstr function to do a substring search

Eg Char * outcome = strstr(value,Keyword[i]); 

 

If the substring is not found then the function returns a null value.

This just seems a longwinded way of doing things especially if the data
file is large.
Am I thinking along the right lines or totally off track.


Thanking you in advance

Jagdev Bhogal

 

 

#include <stdio.h>

#include <rasqal.h>

#include <raptor.h>

 

main()

{

            int i;

             rasqal_query *rq;

            rasqal_query_results *results;

             rasqal_literal *value;

             raptor_iostream *qo;

             const char  *query_string="select ?label, ?comment from
<file:/export/CISR-D/

jagdev/okapi/progs/news.rdf> where (?x rdf:type rdfs:Class)
(?x,rdfs:label, ?la

bel), (?x, rdfs:comment, ?comment) using rdf for
<http://www.w3.org/1999/02/22-

rdf-syntax-ns#>, rdfs for <http://www.w3.org/2000/01/rdf-schema#>"; 

const char *qfilename="queryoutput";

rasqal_init();

rq=rasqal_new_query("rdql",NULL);

raptor_init();

qo=raptor_new_iostream_to_filename(qfilename);

rasqal_query_prepare(rq,query_string, NULL);

results=rasqal_query_execute(rq);

while(!rasqal_query_results_finished(results)) {

 
for(i=0;i<rasqal_query_results_get_bindings_count(results);i++) {

                         const char
*name=rasqal_query_results_get_binding_name(results,i);

                         rasqal_literal *value;

 
value=rasqal_query_results_get_binding_value(results,i);

 
rasqal_query_results_write(qo,results,NULL,NULL);

                        }

                        rasqal_query_results_next(results);

}

raptor_free_iostream(qo);

rasqal_free_query_results(results);

rasqal_free_query(rq);

            rasqal_finish();

raptor_finish();

}

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.usefulinc.com/pipermail/redland-dev/attachments/20070329/98bee2c0/attachment.htm


More information about the redland-dev mailing list