Skip to content

Instantly share code, notes, and snippets.

@njh
Created June 3, 2010 11:30
Show Gist options
  • Save njh/423774 to your computer and use it in GitHub Desktop.
Save njh/423774 to your computer and use it in GitHub Desktop.
Example of parsing RDFa into a graph
#!/usr/bin/env ruby
require 'rubygems'
require 'rdf/rdfa'
graph = RDF::Graph.load('http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0001.xhtml', :base_uri => 'http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0001.xhtml')
graph.each_statement do |statement|
statement.inspect!
end
@artob
Copy link

artob commented Jun 3, 2010

I need to take care of getting rid of :base_uri, but note that the rest of it can (in Ruby 1.8.7+) be simplified to:

graph.each_statement(&:inspect!)

...which is why the RDF::Value#inspect! method exists in the first place :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment