innoq/iq_rdf

Malformed collections in NTriples serialization

Closed this issue · 1 comments

Using rapper to parse the following iq_rdf generated nt-serialization results in

$ rapper -i ntriples -o turtle http://umthes.innoq.com/AntizipiertesGutachten-de.nt
rapper: Parsing URI http://umthes.innoq.com/AntizipiertesGutachten-de.nt with parser ntriples
rapper: Serializing with serializer turtle
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<http://umthes.innoq.com/AntizipiertesGutachten-de>
    <http://try.iqvoc.net/schema#compoundForm> (<http://umthes.innoq.com/antizipiere-de>
rapper: Error -  - Malformed collection - second predicate is not rdf:rest
        <http://umthes.innoq.com/Gutachten-de>
    ) .

rapper: Parsing returned 14 triples

I'm passing an array of URIs to iq_rdf to build the collection object:

def build_rdf(document, subject)
  subject.send(rdf_namespace).send(rdf_predicate, compound_form_contents.map {|cfc| IqRdf::build_uri(cfc.label.origin) })
end

I suppose the cause of this is sitting here:

https://github.com/innoq/iq_rdf/blob/master/lib/iq_rdf/collection.rb#L40

Maybe we need to append rdf:rest rdf:nil as the last element in a collection if there aren't any elements left.

EDIT:
Uh, seems this already happens:
https://github.com/innoq/iq_rdf/blob/master/lib/iq_rdf/collection.rb#L47