Search code examples
rdfsemantic-webrdfs

rdfs:domain error when validating RDF with RDFS in RDFUnit


I tried to validate my RDF with RDFS in RDFUnit online demo (http://rdfunit.aksw.org/demo/). Result of validation is:

Fail ERROR http://example.org/cim#IdentifiedObject.mRID has rdfs:domain different from: http://example.org/cim#IdentifiedObject

RDF:

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:cim="http://example.org/cim#" >
  <rdf:Description  rdf:about="1">
    <rdf:type rdf:resource="cim:IdentifiedObject" />
    <cim:IdentifiedObject.mRID>1</cim:IdentifiedObject.mRID>
  </rdf:Description>
</rdf:RDF>

RDFS:

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base="http://example.org/cim#" >
  <rdfs:Class rdf:ID="IdentifiedObject" />
  <rdf:Property rdf:ID="IdentifiedObject.mRID">
    <rdfs:domain rdf:resource="#IdentifiedObject" />
  </rdf:Property>
</rdf:RDF>

What is a proper way of declaring domains in rdf:Propery?


Solution

  • The error is a little cryptic, but at a guess the problem is this line in your data:

    <rdf:type rdf:resource="cim:IdentifiedObject" />
    

    You are using a prefixed name as the value of rdf:resource here, but that is not allowed in RDF/XML*. This value needs to be the full URI: http://example.org/cim#IdentifiedObject. The result of the current situation is probably that RDFUnit doesn't recognize that the class used in your data and the class your schema uses in the domain statement are the same thing.

    Protip: don't use RDF/XML. Like, ever. It's a terrible syntax to have to manually write/debug. Switch to something like Turtle or N-Triples, much easier to read and edit.

    * The reason this doesn't work is that RDF/XML is, well, XML, and it uses the XML namespace mechanism for denoting prefixed names - which is only for element and attribute names, not for attribute values.