W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > April 2012

select.where clause

From: Basil Bimblebaum <basilbimblebaum@freenet.de>
Date: Thu, 12 Apr 2012 23:40:31 +0200
Message-ID: <4F874BCF.5010600@freenet.de>
To: "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org>
Hi there,

recently getting into ruby and rdf, I am now running queries with
sparql-client and its pretty sweet.

Up to now, I just lazyly pass the query as a string to the client, but I
what to define the select clause properly.

##Starting from here (this works fine),
client = SPARQL::Client.new(target)
result = client.select.where(
	"SELECT distinct ?herp ?derp WHERE {
	?herp <http://www.w3.org/2000/01/rdf-schema#comment> ?derp.
} LIMIT 5"
)
result.each do |asolution|
asolution.each {|key, value| puts "#{ key} has value #{value}" }
end
##

Starting from the documentation I tried some stuff like this but.. what
am I doing wrong here?

s1 = RDF::Query::Variable.new(:herp)
p1 = RDF::Query::Variable.new(:p1,
"<http://www.w3.org/2000/01/rdf-schema#comment>")
o1 = RDF::Query::Variable.new(:derp)
result = client.select.where([:herp, :p1, :derp]).limit(5)

Regards
Peter
Received on Friday, 13 April 2012 08:11:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 13 April 2012 08:11:15 GMT