Closed mistergibson closed 13 years ago
It's a bug in RDF.rb, which should be updated shortly.
I noticed your pull request, thanks for the upstream effort. I'm using 0.3.1 of rdf.rb and am not sure when the gem will be updated. As I really need this working - could you post a comment here when the corrections are incorporated? I can then do a pull if the gem isn't updated in time.
Thanks in Advance, and thanks for the prompt reply. :)
Arto should get it out shortly, there are couple of other things to go in.
You could always clone my fork in the mean time.
Actually I got the same error with your forked version.
The specs pass for me using that version of the gem, and I did try that example specifically, and it seems to work as advertised.
Can you provide some detail: what version of Ruby are you running?
Can you provide a test case and the error results you're seeing?
I am running Ruby 1.8.7-249-i486-Linux.
And ... actually the above code is all I've tried with identical results, no specific test cases beyond that.
What is the value of $datafile. The error and line number generated is exactly the same?
The patch generated is in the reader-content_type branch, so you may have neglected to switch to that branch before installing.
From the gem directory, try the following:
RDF::RDFXML::Reader.open("etc/doap.xml") {|r| puts r}
Please send the result of this output.
RDF::RDFXML::Reader.open("/var/lib/gems/1.8/gems/rdf-rdfxml-0.3.0/etc/doap.xml") {|r| puts r}
yields: #RDF::RDFXML::Reader:0xb69cf368 ... so that's perfect. Which led me to the next logical question - what is different about my files? Well, for one thing the files I'm working with don't typically use the rdf:RDF tag, but simply an RDF tag. When I correct that to something closer to your sample file and try:
RDF::RDFXML::Reader.open("odp_rdfxml.sample") {|r| puts r}
I get:
/usr/lib/ruby/gems/1.8/gems/rdf-0.3.1/lib/rdf/reader.rb:125:in open':NameError: undefined local variable or method
content_type' for RDF::RDFXML::Reader:Class
I'm thinking at this point that it does not properly get the dtd info to define the resource types properly. Here is a dump of the odp_rdfxml.sample file:
<?xml version="1.0" encoding="UTF-8"?>
It really looks to me like you're not using the reader-content_type branch of my fork, that has this change. The good news is that Arto has finally released his dydra project (http://dydra.com) and said he'd get a release of RDF.rb incorporating this change out today or tomorrow.
ok ... sorry - finally got the branch you sited installed. It did solve the first error, but I got this one now :
/usr/lib/ruby/gems/1.8/gems/rdf-0.3.1/lib/rdf/reader.rb:125:in `open':RDF::FormatError: unknown RDF format: file_nameodp_rdfxml.sample.inspect}
code and sample file being the same. Do you see anything glaring about the afore posted sample file?
It looks like you might have a bad path in your variable. Try the following in irb:
require 'rdf/rdfxml'
RDF::RDFXML::Reader.open("http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf") {|r| puts r}
You should be able to do the following, as well:
require 'linkeddata'
RDF::Graph.load("http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf").dump(:ntriples)
OK, the error is because it was using the filename extension as its content type detector. I renamed the sample file to end in .xml and it finally gave me a spiffy Reader object. Thanks for all your help with this issue. :)
Hello.
I was attempting to follow your example and encountered an error while testing. Code and Error follows:
RDF::RDFXML::Reader.open($datafile_path) do |reader| reader.each_statement do |statement| puts statement.inspect end end
NameError: undefined local variable or method
content_type' for RDF::RDFXML::Reader:Class from /usr/lib/ruby/gems/1.8/gems/rdf-0.3.1/lib/rdf/reader.rb:125:in
open' from /usr/lib/ruby/1.8/open-uri.rb:32:inopen_uri_original_open' from /usr/lib/ruby/1.8/open-uri.rb:32:in
open' from /usr/lib/ruby/gems/1.8/gems/rdf-0.3.1/lib/rdf/util/file.rb:28:inopen_file' from /usr/lib/ruby/gems/1.8/gems/rdf-0.3.1/lib/rdf/reader.rb:117:in
open' from (irb):2Any idea why I would be getting this error? Thanks in advance.