[redland-dev] RDQL - Objective C/Cocoa/ OS X ?
Mr cool
mrcoolkrish at gmail.com
Wed Sep 14 19:17:02 BST 2005
Hi,
Has anyone tried SPARQL/RDQL RDF queries using Objective C / Cocoa / OS X ?
The name/value of bindings doesn't seem to get populated from the query.
(However I am able to populate my storage/model manually and display them)
I also tried querying a local rdf using the "SELECT ... FROM
<file.rdf> ..." , but that results in "Failed to make triples source."
error.
Gist of my code: (for Bindings case)
============
mynsurl = [NSURL
URLWithString:@"http://www.ilrt.bristol.ac.uk/people/cmdjb/webwho.xrdf"];
qry = [NSString stringWithString:@"SELECT ?name WHERE (?x foaf:name
?name) USING foaf FOR <http://xmlns.com/foaf/0.1/> "];
myredlandquery=[RedlandQuery
queryWithLanguageName:RedlandRDQLLanguageName queryString:qry
baseURI:myredlanduri];
myredlandstorage = [[RedlandStorage storage]
initWithFactoryName:@"hashes" identifier:@"test"
options:@"contexts='yes',hash-type='memory'"];
myredlandmodel=[[RedlandModel model] initWithStorage:myredlandstorage];
myredlandqueryresults = [myredlandquery executeOnModel:myredlandmodel];
if ([myredlandqueryresults isBindings] != 0) {
int count = [myredlandqueryresults countOfBindings];
NSLog(@"%d - Number of bindings", count);
for (j=0; j<count; j++) {
NSLog(@"Name at binding %d is %@",j,[myredlandqueryresults
nameOfBindingAtIndex:j]);
}
i=0;
while ([myredlandqueryresults finished] == 0) {
i++;
NSLog([NSString stringWithFormat:@"Count %d",i]);
for (j=0; j<count; j++) {
mynodes = [myredlandqueryresults valueOfBindingAtIndex:j];
NSLog(@"%@ - Literal Value",[mynodes literalValue]);
}
[myredlandqueryresults next];
} //loop results
} //ifbindings
Thanks,
MK
More information about the redland-dev
mailing list