Re: Adding a list-valued property

>
> That would work, but of course, you’d also want to add the list to the
> graph for it to be included in the dump. I think Ian’s use case should
> probably work, and it indicates that there’s something missing both in the
> List implementation and the tests. It’s a natural thing to want to do.


Or you could create the RDF::List using your starting Repository as it's
graph... but yes.

Working with RDF::List recently, it has a couple of natural but surprising
behaviors that arise from it being an interface on a rdf:List as well as
manipulating a graph.

>From my recollection of a couple of weeks ago, adding an empty list to a
graph and then manipulating it has surprising results because the root
subject changes.

I also seem to remember an issue I had (but maybe only in my own fork...?)
that had to do with where the rdf:List type was applied in terms of
serializing to JSON-LD or RDFa... I think it had to do with type properties
on the rdf:rest objects, but I'm not sure at the moment.

Judson




On Mon, Nov 25, 2013 at 1:42 PM, Gregg Kellogg <gregg@greggkellogg.net>wrote:

>
> On Nov 25, 2013, at 1:24 PM, Judson Lester <nyarly@gmail.com> wrote:
>
> I think what you want is:
>
> r << [s, p, l.subject]
>
> That's just off the top of my head though.
>
>
> That would work, but of course, you’d also want to add the list to the
> graph for it to be included in the dump. I think Ian’s use case should
> probably work, and it indicates that there’s something missing both in the
> List implementation and the tests. It’s a natural thing to want to do.
>
> Note that in the 1.0.x versions, RDF::List extends RDF::Resource, which
> would make you believe that a list is a first-class item (Graph does to).
> This behavior is removed in the 1.1 versions they extend RDF::Value
> instead. I’m trying to push out all new versions of the RDF gems, but am
> stuck in some odd Sinatra/Rake behavior at the moment; I’ll make sure this
> is addressed then.
>
> Similarly, you might think that doing g = RDF::Graph.load(“foo”), r << [s,
> p, g] would add the graph as an anonymous named graph to the repository;
> this would be worth implementing/validating too.
>
> Ian, perhaps you’d raise an issue against RDF.rb.
>
> Gregg
>
> On Mon, Nov 25, 2013 at 1:19 PM, Ian Dickinson <i.j.dickinson@gmail.com>wrote:
>
>> Hi Gregg,
>> I'm doing something wrong trying to add a triple whose object is a
>> list. Basically what I'm trying to create is:
>>
>>     :s :p (1 2 3).
>>
>> Here's what I tried:
>>
>> 2.0.0-p247 :003 > r = RDF::Repository.new
>>  => #<RDF::Repository:0x15b1ac0()>
>> 2.0.0-p247 :004 > l = RDF::List[1,2,3]
>>  => #<RDF::List:0x16b6cf4(RDF::List[1, 2, 3])>
>> 2.0.0-p247 :005 > s = RDF::Resource.new("http://example.org/s")
>>  => #<RDF::URI:0x18d91f8(http://example.org/s)>
>> 2.0.0-p247 :006 > p = RDF::Resource.new("http://example.org/p")
>>  => #<RDF::URI:0x1abcd1c(http://example.org/p)>
>> 2.0.0-p247 :007 > r << [s,p,l]
>>  => #<RDF::Repository:0x15b1ac0()>
>> 2.0.0-p247 :008 > r.dump(:turtle)
>>  => "\n<http://example.org/s> <http://example.org/p> _:g24109960 .\n"
>> 2.0.0-p247 :009 > r << l
>>  => #<RDF::Repository:0x15b1ac0()>
>> 2.0.0-p247 :010 > r.dump(:turtle)
>>  => "\n<http://example.org/s> <http://example.org/p> _:g24109960
>> .\n\n(1 2 3) a <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .\n"
>>
>> I'm sure I'm doing something dumb, but I'm not sure what to change.
>> Suggestions?
>>
>> Thanks,
>> Ian
>>
>>
>
>

Received on Monday, 25 November 2013 22:27:12 UTC