Created
November 15, 2013 14:43
-
-
Save lawlesst/7485358 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rdflib | |
raw = """ | |
<rdf:RDF | |
xmlns:vitro-public="http://vitro.mannlib.cornell.edu/ns/vitro/public#" | |
xmlns:c4o="http://purl.org/spar/c4o/" | |
xmlns:ero="http://purl.obolibrary.org/obo/" | |
xmlns:pvs="http://vivoweb.org/ontology/provenance-support#" | |
xmlns:owl2="http://www.w3.org/2006/12/owl2-xml#" | |
xmlns:scirr="http://vivoweb.org/ontology/scientific-research-resource#" | |
xmlns:vivo="http://vivoweb.org/ontology/core#" | |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
xmlns:bibo="http://purl.org/ontology/bibo/" | |
xmlns:afn="http://jena.hpl.hp.com/ARQ/function#" | |
xmlns:foaf="http://xmlns.com/foaf/0.1/" | |
xmlns:scires="http://vivoweb.org/ontology/scientific-research#" | |
xmlns:dcterms="http://purl.org/dc/terms/" | |
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" | |
xmlns:geo="http://aims.fao.org/aos/geopolitical.owl#" | |
xmlns:skco="http://www.w3.org/2004/02/skos/core#" | |
xmlns:event="http://purl.org/NET/c4dm/event.owl#" | |
xmlns:dcelem="http://purl.org/dc/elements/1.1/" | |
xmlns:vitro="http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" | |
xmlns:vann="http://purl.org/vocab/vann/" | |
xmlns:skos="http://www.w3.org/2008/05/skos#" | |
xmlns:swvs="http://www.w3.org/2003/06/sw-vocab-status/ns#" | |
xmlns:owl="http://www.w3.org/2002/07/owl#" | |
xmlns:fabio="http://purl.org/spar/fabio/" | |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> | |
<rdf:Description rdf:about="http://vivo.iu.edu/individual/n4898"> | |
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> | |
<rdf:type rdf:resource="http://vivoweb.org/ontology/core#InformationResource"/> | |
<rdf:type rdf:resource="http://purl.org/ontology/bibo/Document"/> | |
<rdf:type rdf:resource="http://vivoweb.org/ontology/core#Review"/> | |
<rdf:type rdf:resource="http://purl.org/ontology/bibo/Article"/> | |
<bibo:cites rdf:resource="http://vivo.iu.edu/individual/n9999"/> | |
<vivo:title>Review of Licensing Digital Content: A Practical Guide for Librarians</vivo:title> | |
<vitro:mostSpecificType rdf:resource="http://vivoweb.org/ontology/core#Review"/> | |
</rdf:Description> | |
</rdf:RDF> | |
""" | |
model = rdflib.Graph() | |
model.parse(data=raw) | |
query = """ | |
PREFIX vivo: <http://vivoweb.org/ontology/core#> | |
PREFIX bibo: <http://purl.org/ontology/bibo/> | |
SELECT ?title | |
WHERE { | |
?resource a bibo:Document . | |
?resource vivo:title ?title . | |
} | |
""" | |
results = model.query(query) | |
for row in results: | |
print row |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment