Re: sparql for vocab management: theory vs practice

Thanks all. Here's what I have now:

[[

# List the undocumented FOAF properties used by some FOAF description

PREFIX  foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX  rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX danbri: <http://danbri.org/foaf.rdf>

SELECT DISTINCT  ?p

FROM <http://danbri.org/foaf.rdf>
FROM NAMED foaf: 
WHERE
  { ?s  ?p  ?o .
    OPTIONAL
      { GRAPH foaf:
          { ?p  rdf:type  rdf:Property ;
                rdf:type  ?type .
          }
      }
    FILTER ( ! bound(?type) )
    FILTER REGEX( str(?p), "^http://xmlns.com/foaf/0.1/" ) # ignore 3rd-party namespaces
  }

]]



Running it now, I get the following:

----------------------
| p                  |
======================
| foaf:wife          |
| foaf:pubkeyAddress |
| foaf:dateOfBirth   |
| foaf:archnemesis   |
----------------------

It doesn't feel 100% great having the namespace URI in a regex like
that, ...but it does at least work perfectly :)

So this little query lets me find out which properties I've used in
my FOAF file but which don't really exist in the schema. Kinda handy :)
Something quite similar should be able to check for fictional properties
such as dc:author (instead of dc:creator). I guess to check all
namespaces would need a bit of application code since we can't decide 
which graphs to load in mid-query (otherwise we could write a web
crawler in sparql maybe?)...

cheers,

Dan

Received on Wednesday, 10 May 2006 12:59:08 UTC