[redland-dev] json serialization (again)

Eric Hanson elh at cs.pdx.edu
Thu Oct 5 23:40:04 UTC 2006


I had this working at one point [1] but now I reinstalled Linux and
can't get it working anymore:

1. install redland-1.0.4 from source
2. download & install latest ruby bindings from the svn repository which
contain patches that make json-serialization possible
3. do the following:

---
eric at vector:~$ cat redland.rb
require 'rdf/redland.rb'
queryStr = 'select ?s ?p ?o where {?s ?p ?o}'
store = Redland::HashStore.read_store('test', '/usr/local/redland-data',
false)
model = Redland::Model.new(store)
query = Redland::Query.new(queryStr, 'sparql')
results = query.execute(model)
# print
results.to_string(Redland::Uri.new("http://www.w3.org/TR/2004/WD-rdf-sparql-XMLres-20041221/"),
nil)
print
results.to_string(Redland::Uri.new("http://www.w3.org/2001/sw/DataAccess/json-sparql/"),
nil)

print 'store:',store,"\n"
print 'model:',model,"\n"
print 'query:',query,"\n"
print 'results:',results,"\n"
eric at vector:~$ ruby redland.rb
store:#<Redland::HashStore:0xb7c52db8>
model:#<Redland::Model:0xb7c52bd8>
query:#<Redland::Query:0xb7c52afc>
results:#<Redland::QueryResults:0xb7c52a20>
eric at vector:~$
---

It prints nothing.

Now if I uncomment the rdf-sparql-XMLres line, it prints XML results
just fine:

---
eric at vector:~$ cat redland.rb
require 'rdf/redland.rb'
queryStr = 'select ?s ?p ?o where {?s ?p ?o}'
store = Redland::HashStore.read_store('test', '/usr/local/redland-data',
false)
model = Redland::Model.new(store)
query = Redland::Query.new(queryStr, 'sparql')
results = query.execute(model)
print
results.to_string(Redland::Uri.new("http://www.w3.org/TR/2004/WD-rdf-sparql-XMLres-20041221/"),
nil)
# print
results.to_string(Redland::Uri.new("http://www.w3.org/2001/sw/DataAccess/json-sparql/"),
nil)

print 'store:',store,"\n"
print 'model:',model,"\n"
print 'query:',query,"\n"
print 'results:',results,"\n"
eric at vector:~$ ruby redland.rb
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2001/sw/DataAccess/rf1/result">
  <head>
    <variable name="s"/>
    <variable name="p"/>
    <variable name="o"/>
  </head>
  <results>
    <result>
      <s uri="a"/>
      <p uri="b"/>
      <o>c</o>
    </result>
    <result>
      <s uri="a"/>
      <p uri="b"/>
      <o>cd</o>
    </result>
    <result>
      <s uri="a"/>
      <p uri="b"/>
      <o>cde</o>
    </result>
    <result>
      <s uri="a"/>
      <p uri="b"/>
      <o>cdef</o>
    </result>
  </results>
</sparql>
store:#<Redland::HashStore:0xb7cf0db8>
model:#<Redland::Model:0xb7cf0bd8>
query:#<Redland::Query:0xb7cf0afc>
results:#<Redland::QueryResults:0xb7cf0a20>
eric at vector:~$
---

With the URL I'm using, it behaves the same as if I used a totally
random URL.  I had the JSON serialization working at one point, I'm
wondering what changed in my environment to make it break.  I thought it
was working with 1.0.4 without any patches, but an afternoon later and
I'm still spinning my wheels.  Any ideas would be greatly appreciated!

Thanks,
Eric

[1]http://lists.gnomehack.com/pipermail/redland-dev/2006-July/001373.html


More information about the redland-dev mailing list