Skip to content

Instantly share code, notes, and snippets.

@njh
Created July 15, 2010 21:59
Show Gist options
  • Save njh/477594 to your computer and use it in GitHub Desktop.
Save njh/477594 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'rdf'
require 'rdf/ntriples'
require 'rdf/rdfxml'
graph = RDF::Graph.new
RDF::Reader::for(:ntriples).new(DATA.read) do |reader|
reader.each_statement do |statement|
graph << statement
end
end
puts RDF::Writer.for(:rdfxml).dump(graph)
__END__
<http://dbpedialite.org/things/3354#thing> <http://www.w3.org/2000/01/rdf-schema#comment> "Berlin (English pronunciation:\u00A0/b\u025Cr\u02C8l\u026An/; German pronunciation:\u00A0[b\u025B\u0250\u032F\u02C8li\u02D0n]\u00A0 (listen)) is the capital city and one of 16 states of Germany. With a population of 3.4 million people, Berlin is Germany's largest city. It is the second most populous city proper and the eighth most populous urban area in the European Union. Located in northeastern Germany, it is the center of the Berlin-Brandenburg Metropolitan Area, comprising 5 million people from over 190 nations. Geographically embedded in the European Plains, Berlin is influenced by a temperate seasonal climate. Around one third of the city's territory is composed of forests, parks, gardens, rivers and lakes.\n" .
<http://dbpedialite.org/things/3354#thing> <http://www.w3.org/2003/01/geo/wgs84_pos#long> "13.39889"^^<http://www.w3.org/2001/XMLSchema#double> .
<http://dbpedialite.org/things/3354#thing> <http://www.w3.org/2000/01/rdf-schema#label> "Berlin" .
<http://dbpedialite.org/things/3354#thing> <http://www.w3.org/2003/01/geo/wgs84_pos#lat> "52.50056"^^<http://www.w3.org/2001/XMLSchema#double> .
<http://dbpedialite.org/things/3354#thing> <http://www.w3.org/2002/07/owl#sameAs> <http://rdf.freebase.com/ns/m.0156q> .
<http://dbpedialite.org/things/3354#thing> <http://www.w3.org/2002/07/owl#sameAs> <http://dbpedia.org/resource/Berlin> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/page> <http://www.berlin.de/international/index.en.php/> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/page> <http://www.businesslocationcenter.de/en/Start/index.html> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/page> <http://www.hauptstadtregion-berlin-brandenburg.de/> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/page> <http://www.berlin-regional.de/> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/page> <http://www.berlin-tourist-information.de/index.en.php> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/page> <http://www.museumsportal-berlin.de/en.html> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/page> <http://www.exberliner.com> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/page> <http://berlin.unlike.net/> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/page> <http://www.flickr.com/photos/41182695@N08/sets/72157622725699696/> .
<http://dbpedialite.org/things/3354#thing> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .
<http://dbpedialite.org/things/3354#thing> <http://xmlns.com/foaf/0.1/isPrimaryTopicOf> <http://en.wikipedia.org/wiki/Berlin> .
@njh
Copy link
Author

njh commented Jul 15, 2010

@gkellogg
Copy link

Fixed in http://github.com/gkellogg/rdf-rdfxml/commit/bd5d124fcfb8fe3548fac06674e99ed430a07d23, I'll push an update to the Gem soon, just sorting a couple of other things out.

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