[redland-dev] Problems traversing arcs with the same URI
Simon Cross
simon at sanbi.ac.za
Mon Jan 17 05:52:09 PST 2005
Hi,
> I am not sure if this is a limitation of the API, a
> bug, or just a newbie mistake on my part. I am trying
> to traverse the model I have built, which contains
> nodes that have multiple arcs leaving them with the
> same uri. Here are the steps I currently do:
>
> 1. librdf_model_get_arcs_out(model, subject): Create
> a librdf_iterator that will give me all the arcs
> leaving this resource/node identified by 'subject.'
>
> 2. arc = librdf_iterator_get_object(itereator):
> Returns each indiviual arc from the iterator. If the
> node has 4 arcs leaving, all with the same uri, then
> this function seems to return all 4 of them uniquely
> (using calls to librdf_iterator_next() in between).
>
> 3. target = librdf_model_get_target(model, subject,
> arc): I use the arc returned above to try to get the
> individual targets of the 4 arcs. *This is where I
> have the problem* For some reason, this function
> returns THE SAME TARGET node all 4 times I call it.
My guess is that arc is a simple URI. Thus librdf_model_get_target has
no way of identifying which of the four arcs you are referring to (since
it sees only the subject and arc URIs).
librdf_model_get_targets would presumably list all of the target URIs
(in an iterator) but then you'd have to worry about duplicating targets
if you ran through all the results from librdf_model_get_arcs_out.
Maybe you can use librdf_model_find_statements_with_options to select
all the statements which have a particular subject? Or perhaps an RDQL
or SPARQL query would suit your needs better?
Schiavo
Simon
More information about the redland-dev
mailing list