Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug inserting RDF-XML based graphs or reader into repositories #5

Open
cmarin opened this issue Jul 13, 2010 · 0 comments
Open

Bug inserting RDF-XML based graphs or reader into repositories #5

cmarin opened this issue Jul 13, 2010 · 0 comments

Comments

@cmarin
Copy link

cmarin commented Jul 13, 2010

Bug inserting RDF-XML based graphs into repositories.

I am able to insert NTriple based readers into a Sesame repository. However, RDFXML ones cannot be inserted. Here's what I've been trying:
require 'rdf'
require 'rdf/sesame'
require 'rdf/rdfxml'
repository = RDF::Sesame::Repository.new('http://localhost:8080/openrdf-sesame/repositories/test')

Successfully returns count of 47

reader = RDF::NTriples::Reader.new(File.read(RAILS_ROOT + '/public/doap.nt'))
repository.clear
repository.insert(reader)
repository.count

Only returns count of 3

reader = RDF::RDFXML::Reader.new(File.read(RAILS_ROOT + '/public/doap.xml'))
repository = RDF::Sesame::Repository.new('http://localhost:8080/openrdf-sesame/repositories/test')
repository.clear
repository.insert(reader)
repository.count

Graph count returns 47, but insertion into repository fails

stream = File.open(RAILS_ROOT + '/public/doap.xml')
graph = RDF::Graph.new
RDF::RDFXML::Reader.new(stream).each { |s| graph << s }
puts graph.count

Now that we have a graph, insert into repository

This inserts 3 entries, but not the entire 47

repository.clear
repository.insert(graph.to_a)
repository.count

Same thing, returns 3

repository.clear
repository.insert(*graph.to_a)
repository.count

Same thing, returns 3

repository.clear
repository<<graph.to_rdf
repository.count

The << method in writable.rb looks like it detects a graph and then

calls insert_graph, but none of these seem to work either

repository<<graph
repository.insert(graph)
repository.insert(graph.to_ntriples)
repository.insert(_graph.to_ntriples)
graph.each { |s| repository << s }
graph.each { |s| repository.insert(_s) }
graph.each { |s| repository.insert(s) }

stream = File.open(RAILS_ROOT + '/public/doap.xml')
graph = RDF::Graph.new
RDF::RDFXML::Reader.new(stream).each { |s| graph << s }
reader = RDF::NTriples::Reader.new(graph.to_ntriples)
repository.insert(reader)

I am able to get this to work with the RDF Context gem:
require 'rdf'
require 'rdf/sesame'
require 'rdf_context'
url = "http://localhost:8080/openrdf-sesame/repositories/test"
repository = RDF::Sesame::Repository.new(url)

The doap.xml file fails but rdf.xml does get parsed correctly

f = File.open(RAILS_ROOT + '/public/rdf.xml')
graph = RdfContext::Graph.new
graph.parse(f.read, nil, :type => :rdfxml)

statements = RDF::NTriples::Reader.new(graph.to_ntriples)
repository.insert(*statements)
repository.count
repository.clear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant