W3C home > Mailing lists > Public > public-rdb2rdf-comments@w3.org > September 2013

RE: add NULL cases to conformance test

From: Vladimir Alexiev <vladimir.alexiev@ontotext.com>
Date: Thu, 19 Sep 2013 16:28:05 +0300
To: <public-rdb2rdf-comments@w3.org>, <tobyink@cpan.org>
Cc: "'Gregg Garcia'" <GGarcia@getty.edu>
Message-ID: <01c701ceb53c$130cbc30$39263490$@alexiev@ontotext.com>
Richard, thanks for the clarifications!!

>> If a column value (or any of the columns in a rr:template) is null, an r2rml processor should skip the involved triple.
>> If the rr:subjectMap column is null, it should skip all triples in that rr:TriplesMap.
>> This behaviour is stated quite definitely at:
>> http://www.w3.org/2001/sw/rdb2rdf/wiki/RDBNullValues#R2RML
> http://www.w3.org/TR/r2rml/#generated-triples
> Here it says: If Subject, Predicate or Object is empty, then abort these steps. (As a result, no triple is generated.)
> http://www.w3.org/TR/r2rml/#generated-rdf-term
> Here it says: The result of that function can be: Empty – if any of the referenced columns of the term map has a NULL value

> There are several tests that require NULL values to be ignored, e.g., this one:
> http://www.w3.org/2001/sw/rdb2rdf/test-cases/#R2RMLTC0013a
> It does not appear that an implementation could pass the test suite if it doesn't handle at least *some* of the cases for NULLs correctly.

The test result is here: https://bitbucket.org/tobyink/p5-rdf-rdb2rdf/src/6df083243e556e5e8c3044536ab2a4099a3076dc/meta/earl/with-sqlite.ttl?at=RDF-RDB2RDF#cl-626
But I repeated the test, and it fails (returns a row for Alice, which it shouldn’t).

So I fixed this problem. 
You can get it (together with the rrx:languageColumn extension) from:

I also made a pull request to the main author (Toby):

I added 3 tests in directory examples/ 
(sorry I didn’t do it properly in t/ since I don't know Perl unit testing):

1. D013-test: repeats the conformance test above. The old version (0.07) returns Alice and Bob, the fixed version only Alice

2. nullTest
Given a table CODES (ObjectProperty, subPropertyOf , Concept, label) with 4 cols and 3 rows that are sparsely populated,
produces this output:

<http://example.com/ontology/broaderGeneric> a owl:ObjectProperty ;
        rdfs:label "Broader Generic" ;
        rdfs:subPropertyOf <http://www.w3.org/2004/02/skos/core#skos:broader> .
<http://example.com/ontology/historicFlag> a owl:ObjectProperty ;
        rdfs:label "Historic flag" .
<http://example.com/thes/historic/Current> a skos:Concept ;
        skos:prefLabel "Current" .

3. R2RML-language.pl
Outputs 3 books with dc:title in different languages:
- book/1: fr from rrx:languageColumn title_lang
- book/2: it from rrx:languageColumn title_lang
- book/3: en from rr:language (*default* constant lang)

perldoc lib/RDF/RDB2RDF/R2RML.pm :

    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
    @prefix owl:  <http://www.w3.org/2002/07/owl#>.
    @prefix rr:   <http://www.w3.org/ns/r2rml#>.
    @prefix rrx:  <http://purl.org/r2rml-ext/>.

    rrx:languageColumn a owl:DatatypeProperty;
      rdfs:domain rr:TermMap;
      rdfs:range rdf:Literal;
      rdfs:comment "Specifies the language of a literal, to be retrieved from a column. rr:language can be used as constant default".

This can be used in R2RML scripts like so:

    @prefix rr:   <http://www.w3.org/ns/r2rml#>.
    @prefix rrx:  <http://purl.org/r2rml-ext/>.
    @prefix bibo: <http://purl.org/ontology/bibo/>.
    @prefix dc:   <http://purl.org/dc/elements/1.1/>.

    [] rr:logicalTable [rr:tableName "books"];
      rr:subjectMap [rr:class bibo:Book; rr:template "book/{book_id}"];
      rr:predicateObjectMap [
        rr:predicate dc:title;
        rr:objectMap [
          rr:column "title";
          rrx:languageColumn "title_lang";
          rr:language "en"  # default
Received on Thursday, 19 September 2013 13:28:32 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 19:45:18 UTC