[solved] RDF/XML element name misinterpreted as rdf:type (and not rdfs:type)

Hello folks,

I'm currently evaluating Stardog 5.0.4 Community as a possible substitute for Fuseki.

My use case is the publication of RDF/XML data that I created from XML using XSLT. Source code is here.

Problem: the shorthand technique offered by RDF/XML to implicitly declare the rdfs:type of a resource is misinterpreted by Stardog upon upload as rdf:type (which doesn't exist).

Here is a sample document, in extenso:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:b="https://data.maudry.com/voc/boamp#"
         xmlns:dct="http://purl.org/dc/terms/"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
         xmlns:attributions="https://boamp.maudry.com/attributions/"
         xmlns:appeloffres="https://boamp.maudry.com/appeloffres/"
         xmlns:annonces="https://boamp.maudry.com/annonces/"
         xmlns:acheteurs="https://boamp.maudry.com/acheteurs/"
         xmlns:titulaires="https://boamp.maudry.com/titulaires/"
         xmlns:descripteurs="https://boamp.maudry.com/descripteurs/"
         xmlns:lots="https://boamp.maudry.com/lots/"
         xmlns:cpv="https://boamp.maudry.com/cpv/"> 
   <b:Annonce rdf:about="https://boamp.maudry.com/annonces/16-652">
      <rdfs:type rdf:resource="https://data.maudry.com/voc/boamp#Annonce"/>
      <b:idweb>16-652</b:idweb>
      <b:nomHtml>16-652.html</b:nomHtml>
      <b:datePublication rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2016-01-05</b:datePublication>
      <b:dateFinDiffusion rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2016-01-25</b:dateFinDiffusion>
      <b:descripteur rdf:resource="https://boamp.maudry.com/descripteurs/274"/>
      <b:departementPublication>42</b:departementPublication>
      <b:resumeObjet>prestation d'interim médical en anesthesie-réanimation, CHU, à Saint-Etienne</b:resumeObjet>
      <b:appelOffres>
         <b:AppelOffres rdf:about="https://boamp.maudry.com/appeloffres/16-652">
            <b:acheteur>
               <rdf:Description rdf:about="https://boamp.maudry.com/acheteurs/CHU-St-Etienne">
                  <rdfs:type rdf:resource="https://data.maudry.com/voc/boamp#Autre"/>
                  <rdfs:label>CHU St Etienne</rdfs:label>
                  <b:codePostal>42055</b:codePostal>
                  <b:ville>St etienne</b:ville>
                  <b:profilAcheteur rdf:resource="http://www.achats-hopitaux.com"/>
               </rdf:Description>
            </b:acheteur>
            <rdfs:type rdf:resource="https://data.maudry.com/voc/boamp#Autre"/>
            <b:typeMarche>Service</b:typeMarche>
            <b:objetComplet>DAMR 2016/01 PRESTATION D'INTERIM MEDICAL EN ANESTHESIE-REANIMATION</b:objetComplet>
            <b:cpvPrincipal rdf:resource="https://boamp.maudry.com/cpv/79625000"/>
            <b:codePostal>42055</b:codePostal>
            <b:ville>Saint etienne cédex 2</b:ville>
            <b:typeProcedure>Procedure adapte</b:typeProcedure>
         </b:AppelOffres>
      </b:appelOffres>
   </b:Annonce>
</rdf:RDF>

Three resources have their (or one of their) rdfs:type declared:

  • a b:Annonce with URI <https://boamp.maudry.com/annonces/16-652> (the class is declared two times, by the way)
  • a b:AppelOffres (with also class b:Autre) with URI <https://boamp.maudry.com/appeloffres/16-652>
  • a b:Autre with URI <https://boamp.maudry.com/acheteurs/CHU-St-Etienne>

I upload this document using the Stardog command line tool, with this script.

I test the uploaded data with these queries. The repository only contains the above document.

Query to list the distinct classes (typed in Stardog query editor, copied from the actual HTTP payload to also have the prefixes)

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix boamp: <https://data.maudry.com/voc/boamp#>

select distinct ?class where {

?resource a ?class .
} limit 50 offset 0

Expected :

  • boamp:Annonce
  • boamp:AppelOffres
  • boamp:Autre

Results:

  • boamp:AppelOffres

Same query, with specific namespace and property for class binding

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix boamp: <https://data.maudry.com/voc/boamp#>

select distinct ?class where {

?resource rdfs:type ?class .
} limit 50 offset 0

Expected :

  • boamp:Annonce
  • boamp:AppelOffres
  • boamp:Autre

Results:

  • boamp:Annonce
  • boamp:Autre

With rdf:type (a property that doesn't exist, normally)

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix boamp: <https://data.maudry.com/voc/boamp#>

select distinct ?class where {

?resource rdf:type ?class .
} limit 50 offset 0

Expected :

  • no result

Results:

  • boamp:AppelOffres

I can't really draw conclusion on where the problem resides, but there is definitely something fishy going on...

Edit: the SPARQL a keyword seems to yield the same result as rdf:type.

Edit 2: the explicit class declaration (rdfs:type) for b:Annonce seems to have overriden the implicit one (element name)

Edit 3: strict parsing is on, reasoning is off

Hi,

From the http://www.w3.org/1999/02/22-rdf-syntax-ns# document itself, rdf:type is the correct predicate to signify that an entity is a member of a class:

rdf:type a rdf:Property ;
	rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
	rdfs:label "type" ;
	rdfs:comment "The subject is an instance of a class." ;
	rdfs:range rdfs:Class ;
	rdfs:domain rdfs:Resource .

In fact, if you look at the rdfs RDF document (https://www.w3.org/2000/01/rdf-schema) there is no official definition for rdfs:type. This value is allowed in your database, of course, but it will only match when explicitly queried.

As for the SPARQL a keyword, the SPARQL specification is explicit that it is shorthand for rdf:type

Hope this helps!

Wow… I was so sure it was rdfs:type. My bad :slight_smile: