#!/usr/local/bin/ruby
#
# A little test program for Ruby-RDF features
# see http://www.w3.org/2001/12/rubyrdf/intro or mailto:danbri@w3.org

require '../basicrdf'		   # use the Ruby-RDF library
                                   				   
# get some data into a Graph:
#
db = Loader.nt2graph()	   # loads ntriples from STDIN (default)

#file = 'all-packages.rdf'
#file='webwho.xrdf'  # todo: get from commandline
testquery=nil

# An XSLT-based RDF reader (needs Sablotron tools installed)
#db = Loader.rdf2graph(file)
		   
# Register RDF/XML namespaces with db:
#
FOAF = db.reg_xmlns 'http://xmlns.com/foaf/0.1/', 'foaf'
DC = db.reg_xmlns 'http://purl.org/dc/elements/1.1/', 'dc'

print db.toNtriples() +"\n\n\n" 


mb_uri = 'mailto:danbri@w3.org'    # a sample URI to query data about

# Using Graph.ask: "What resources have a foaf_mbox of mailto:danbri@w3.org?"
#
danbri=db.ask(Statement.new(nil, FOAF+'mbox', mb_uri )).subjects[0]
                                   # ask the data for all statements
				   # matching some template (with the 
				   # bit we want 'nil'd out. get the 
				   # subjects of these statements and
				   # take the first answer we find...
					 
# Using Node API: "What are the foaf_mbox properties of <node> ?"
#

if (testquery)
  print "Mailbox(es) for the resource with mailbox #{mb_uri}: \n"
  print " #{danbri.foaf_mbox.join(' ') } \n" if danbri
end












