#!/bin/env python print "==== Example 1 - fetch a metadata record, print in RDF/XML" import joseki import sys from joseki import JosekiRequest from rdflib.URIRef import URIRef from rdflib.Namespace import Namespace # A better name for the "wildcard" in a triple match ANY = None # Declare constants: better to use namespaces DC = Namespace("http://purl.org/dc/elements/1.1/") dcTitle = DC['title'] # The target model URL # This is the Joseki online demo modelURL = "http://jena.hpl.hp.com:2020/books" if len(sys.argv) > 1: modelURL = sys.argv[1] print "Data source =", modelURL book1 = URIRef("http://example.org/book/book1") book2 = URIRef("http://example.org/book/book2") book3 = URIRef("http://example.org/book/book3") book4 = URIRef("http://example.org/book/book4") book5 = URIRef("http://example.org/book/book5") # ---------------------------------------- # Can pass a URIref or string ## store = joseki.fetch(modelURL, "http://example.org/book/book1") store = joseki.fetch(modelURL, book2) store.prefix_mapping("dc", "http://purl.org/dc/elements/1.1/") store.prefix_mapping("vcard", "http://www.w3.org/2001/vcard-rdf/3.0#") if store.__dict__.has_key('serialize'): # RDFlib v2 print store.serialize() else: # RDFlib v1 print >>sys.stderr, "Warning: running rdflib v1 - some things don't work" store.output(sys.stdout)