Tools for investigating schemas

Hi team,

After some discussion with Andy this morning I have been playing with some
scripts for analysing schemas and instance data. I'm sure these things are
obvious to RDF experts here, but for people who are not these simple
examples demonstrate how we can use RDQL and Unix command line tools to
query RDF instance data and schemas.

1. Determine all the properties defined in an RDF schema written in N3
format:

java jena.rdfquery --n3 -data "$1" 
"SELECT ?r WHERE (?r, 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#Property>)"  
| sort | uniq

2. Determine all the classes defined in an RDF schema written in N3 format:

java jena.rdfquery --n3 -data "$1" 
"SELECT ?r WHERE (?r, 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, 
<http://www.w3.org/2000/01/rdf-schema#Class>)"  
| sort | uniq

3. Determine all the properties used in an RDF file written in N3 format
matching the namespace
http://web.mit.edu/simile/2003/10/vraCore3

java jena.rdfquery --n3 -data "$1" 
"SELECT ?p WHERE (?r, ?p, ?v) AND 
?p =~ m!http://web.mit.edu/simile/2003/10/vraCore3!"  
| sort | uniq

4. Determine all the classes used in an RDF file written in N3 format
matching the namespace
http://web.mit.edu/simile/2003/10/vraCore3

java jena.rdfquery --n3 -data "$1" 
"SELECT ?v WHERE (?r, 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, 
?v) AND ?v =~ m!http://web.mit.edu/simile/2003/10/vraCore3!"  
| sort | uniq

5. Determine all the property values used in an RDF file written in N3
format matching the namespace
http://web.mit.edu/simile/metadata/artstor/$2

java jena.rdfquery --n3 -data "$1" 
"SELECT ?v WHERE (?r, ?p, ?v) AND 
?v =~ m!http://web.mit.edu/simile/metadata/artstor/$2!"  
| sort | uniq 

We can use these tools together - for example we might want to check that
the properties and classes used in some instance data match those defined in
a given schema, or compare two different schemas that describe the same
model (e.g. VRA). 

Dr Mark H. Butler
Research Scientist                HP Labs Bristol
mark-h_butler@hp.com
Internet: http://www-uk.hpl.hp.com/people/marbut/

Received on Wednesday, 22 October 2003 11:21:17 UTC