Closed jcoyne closed 11 years ago
Unfortunately, jRuby doesn't work particularly well, largely due to issues with Nokogiri. Work on a REXML/Builder version is underway, but is down on my list a bit.
Please provide a test cases, and I'll add it to examples that I track. Eventually, I do want to get this, and other gems, working on jRuby.
My input XML data is:
<?xml version='1.0' encoding='UTF-8'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
<head>
<variable name='s'/>
<variable name='p'/>
<variable name='o'/>
</head>
<results>
<result>
...
Whit this code I get only the first statement of the rdf xml. But I need the real data in the children nodes (result).
RDF::RDFXML::Reader.new(xml) do |reader|
reader.each_statement do |statement|
block.call(statement)
end
end
Output is only one statement:
<RDF::Statement:0x2e7dc48(_:g49076660 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2005/sparql-results#sparql> .)>
How can I navigate to the results?
Firstly, full support for RDF/XML in jRuby may be problematic, as Nokogiri does not run the same. Also, SPARQL results aren't actually RDF/XML; there's a separate format for SPARQL results. The sparql-client gem includes a parser for both XML and JSON variations. Look at SPARQL::Client#parse_response, and in particular SPARQL::Client.parse_xml_bindings.
Hi Gregg!
Thank you for the answer. I don't use jRuby. I use the normal Ruby. I have see the SPARQL-client gem. But how can I integrate it to my rdf-sesame gem?
Sorry, the jRuby bit was the original topic of the issue.
You should just be able to require "sparql/client".
In your Gemspec or Gemfile, add gem "sparql-client"
I'm pretty sure the original issue is due to this issue in nokogiri:
undefined method
xpath' for nil:NilClass /home/hyrdadm/.rvm/gems/jruby-1.6.7/gems/rdf-rdfxml-0.3.5/lib/rdf/rdfxml/reader.rb:170:in
each_statement'