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: Gregg Kellogg <gregg@kellogg-assoc.com>
Date: Wed, 24 Aug 2011 11:19:20 -0400
To: Marcel Otto <marcelotto@gmx.de>
CC: "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org>
Message-ID: <5EB113D6-9DD9-43A3-8454-170663ADD217@kellogg-assoc.com>
On Aug 24, 2011, at 6:53 AM, "Marcel Otto" <marcelotto@gmx.de<mailto:marcelotto@gmx.de>> wrote:

Hi,

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.

RDF::List does support lists and can be used both when parsing and when serializing, it just can't be used directly as a resource. With some work, it probably could, but this would involve updates to every reader and writer. Also, the statement count of graph or repository would be inaccurate.

It really exists to allow simpler programatic access to list elements, which is otherwise painful.

The fix should be to through an error if an attempt is made to serialize an .

Thanks,
Marcel





----- 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:

Hi,

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
parantheses).

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/> 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
unreadable.

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>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> http://github.com/bendiken/rdf, although Arto hasn't been taking a very active interest in the gem for a while.

Thanks in advance
Marcel
Gregg



Received on Wednesday, 24 August 2011 15:20:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 24 August 2011 15:20:16 GMT