W3C home > Mailing lists > Public > semantic-web@w3.org > November 2007

Re: RDF validation of vocabulary

From: Paul Tyson <phtyson@sbcglobal.net>
Date: Wed, 28 Nov 2007 05:39:11 -0600
Message-ID: <474D535F.4040206@sbcglobal.net>
To: Karl Dubost <karl@w3.org>
CC: Semantic web list <semantic-web@w3.org>

Here is a sparql query that will detect IRIs not in the named 
vocabularies.  It assumes that all subject IRIs in your graph will not 
be vocabulary terms, but it would be easy to list subject IRIs as well.

If you added another named graph that contained validation assertions 
about what is expected or allowed in your graph, you could use this 
technique to validate the graph.

PREFIX rdf: <_http://www.w3.org/1999/02/22-rdf-syntax-ns#_>
PREFIX rdfs: <_http://www.w3.org/2000/01/rdf-schema#_>
SELECT  distinct ?iri
FROM <_test.rdf_ <file:///users/en86757/test.rdf>>
FROM NAMED <_dc.rdf_ <file:///users/en86757/dc.rdf>>
FROM NAMED <_foaf.rdf_ <file:///users/en86757/foaf.rdf>>
FROM NAMED <_rdf-syntax-ns.rdf_ <file:///users/en86757/rdf-syntax-ns.rdf>>
FROM NAMED <_rdf-schema.rdf_ <file:///users/en86757/rdf-schema.rdf>>
{?s ?iri ?o .
        OPTIONAL {GRAPH ?g
         {?iri a rdf:Property }}}
 {?s ?p ?iri .
        FILTER (isIRI(?iri))
        OPTIONAL {GRAPH ?g
         {?iri a rdfs:Class }}}
 FILTER (!bound(?g))

Karl Dubost wrote:

> Hi,
> I was trying to validate an RDF document and I just realized that the  
> RDF validator, was just checking
> the document is well-formed and that is a graph, but not that the  
> vocabulary is used appropriately.
> <?xml version="1.0"?>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>   xmlns:dc="http://purl.org/dc/elements/1.1/"
>   xmlns:myvocab="http:example.org/">
>   <rdf:Description rdf:about="http://www.w3.org/">
>     <dc:title>World Wide Web Consortium</dc:title>
>     <dc:foobar>a foreign element to Dublin Core Vocabulary</dc:foobar>
>     <myvocab:foo>an unknown vocab</myvocab:foo>
>   </rdf:Description>
> </rdf:RDF>
> The vocabulary which is not part of Dublin Core for example will not  
> be detected.
> <dc:foobar>a foreign element to Dublin Core Vocabulary</dc:foobar>
> Is there a way to check that your vocabulary is consistent.  The  
> answer could be:
> Your document is RDF valid but contains
> * an unknown vocabulary: vocab,
> * an element which is not part of dc vocabulary: foobar
> -- 
> Karl Dubost - W3C
> http://www.w3.org/QA/
> Be Strict To Be Cool
Received on Wednesday, 28 November 2007 11:37:18 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 07:42:00 UTC