W3C home > Mailing lists > Public > public-sparql-dev@w3.org > April to June 2006

Re: sparql for vocab management: theory vs practice

From: Dan Brickley <danbri@danbri.org>
Date: Wed, 10 May 2006 08:58:55 -0400
To: "Seaborne, Andy" <andy.seaborne@hp.com>
Cc: Dan Brickley <danbri@danbri.org>, Steve Harris <S.W.Harris@ecs.soton.ac.uk>, public-sparql-dev@w3.org, public-swbp-wg@w3.org
Message-ID: <20060510125855.GB8195@postdiluvian.org>

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:10 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:17:05 GMT