W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > August 2011

Re: How do I get RDF.rb to produce RDF collections in RDF/XML with a rdf:parseType="Collection" serialisation

From: Marcel Otto <marcelotto@gmx.de>
Date: Wed, 24 Aug 2011 15:53:42 +0200
Cc: public-rdf-ruby@w3.org
Message-ID: <20110824135342.147420@gmx.net>
To: "Gregg Kellogg" <gregg@kellogg-assoc.com>

 you're right, if I use only resources in my collection everything works fine. That is, the limitation of collections containing literals, doesn't affect the normal use cases of collections in OWL.

 Sorry for bothering you, I should have been using the same examples for both of my usage scenarios.

 Regarding RDF::List: It's probably a bad name, since the name suggests direct support of RDF collections, which are defined in the RDF vocabulary with the class rdf:List.


----- Urspr√ľngliche Nachricht -----
Von: Gregg Kellogg
Gesendet: 22.08.11 22:44 Uhr
An: Marcel Otto
Betreff: Re: How do I get RDF.rb to produce RDF collections in RDF/XML with a rdf:parseType="Collection" serialisation

 On Aug 22, 2011, at 2:31 AM, Marcel Otto wrote:


 I've loaded a RDF/XML file with a collection (by
 rdf:parseType="Collection") into a RDF.rb graph and looked at the
 containing statement, consisting of equivalent rdf:first and rdf:rest
 triples. If I write this graph back to a RDF/XML file, I get the proper
 serialisation with rdf:parseType="Collection" back. But if I build it
 manually, I only get a serialisation of the rdf:first and rdf:rest
 triples back (not rdf:parseType="Collection" serialisation; note, that
 writing the same graph to a N3 file, produces a nice serialisation with
 Do you have an example? RDF/XML only serializes with parseType="Collection" unless any member is a literal. FYI, you can try this using http://rdf.greggkellogg.net/distiller/  by using the form input view, input type to "n3" or "ttl" and output type to "rdfxml".

 Is there a way to get the RDF/XML writer to produce a rdf:parseType
 serialisation with a manually built graph?
 Certainly, try it with the following:

 <> <#list> (<a> <b>) .

 I am aware of the fact, that both serialisations are equivalent,
 according to the RDF specification, but it looks so ugly, and given the
 importance of collections for OWL, an OWL ontology becomes almost

 By the way: I've also tried RDF::List, but this seems to be unusable
 with RDF/XML, since if I try to write it, I get a "RDF::WriterError:
 Attempt to serialize #<RDF::List...>, not supported in RDF/XML".

 You can use RDF::List to create a set of statements that can generate statements, but this is not directly supported by the various writers. As a convenience, when programming, you might try the following:

 g = RDF::Graph.new

 l = RDF::List[RDF::FOAF.Document, RDF::FOAF.Person]

 g << [RDF::URI("http://example.com/class "), RDF::OWL.unionOf, l.subject]

 l.each_statement {|st| g << st}

 As is, you cannot simply add a triple containing a List and expect it to expand automatically. It's not a bad idea, but it would complicate the processing. You might file a feature request at http://github.com/bendiken/rdf , although Arto hasn't been taking a very active interest in the gem for a while.

 Thanks in advance
Received on Wednesday, 24 August 2011 13:54:22 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:02:15 UTC