Hi,

I'm hoping someone can help with me with this question about rdflib. 
Apologies in advance as i'm new to rdflib
(and to rdf a bit too) and this might be a newbie question.

I have some code which I am using to construct an rdf sequence.  I call 
'addItemToSequence' several times
to build up the sequence, having set up the graph elsewhere.

ns_client_site1_url = "http://example.com/ns/client-site1#";
ns_client_site1 = Namespace(ns_client_site1_url)
site = ns_client_site1

def addItemToSequence(source_id, target_id)
    g.add( (site[source_uid], RDF.Seq, URIRef('children_of_%s' % 
source_uid) ) )
    s = Seq( g, URIRef('children_of_%s' % source_uid) )
    g.add( (URIRef('children_of_%s' % source_uid), RDF.li, 
site[target_uid]) )

I get the following rdf out of it:

<rdf:RDF
  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
  <rdf:Description rdf:about="http://example.com/ns/client-site1#124";>
    <rdf:Seq>
      <rdf:Description rdf:about="children_of_124">
        <rdf:li rdf:resource="http://example.com/ns/client-site1#157"/>
        <rdf:li rdf:resource="http://example.com/ns/client-site1#151"/>

      </rdf:Description>
    </rdf:Seq>
  </rdf:Description>
</rdf:RDF>

The intent is to produce the rdf required to describe a simple, 
hierarchical site map as used by a website,
which i can then query.  In the example, the resources and 
target_uid/source_uid represent the unique ids
of the pages that are related.

Now, my questions are:

- have i created a sequence correctly here?  i.e. am i _always_ going to 
get the items back in the same order, or
do i just get them back in this order because of a quirk of 
python/rdflib.  i'm not sure how i can test
that my sequence is preserving its order.  the main reason for doing 
this is to make sure i'm adding it properly.
i was expecting the items in the sequence to have tags of rdf:_1, rdf:_2 
etc.

- when i add the sequence, it seems i have to give it a name 
(children_of_whatever).  yet i think i ought to
be able to specify this as an empty/abstract node (sorry, not quite sure 
of the terminology here) so I don't need to
give it am rdf:description at all.  is this possible?  or am i 
misguided?!  if it's possible, how do i do it with
rdflib.

- finally, if i want to change the order of items in the sequence, how 
should this be done?  delete all the items
and add them again in the right order?  do sequences provide any help to 
'promote' items at all?  should they?

I hope the examples and questions are clear.  I've googled quite a lot 
and whilst rdf examples are easy to find,
rdflib examples are not.  To that end, I'm happy to contribute a test / 
example based on the outcome of this
(or even some code!)

I am using rdflib 2.2.3, as i required python 2.3.5 compatibility.  I am 
using the rdflib.Graph.Graph class and not
the sparql graph, if that is any help.

rdflib looks really good.  is there any chance of getting the rdf and 
code for the recipe examples in too?  happy
to hack about with it to get it into shape if it's useful.

thanks for your help,

miles




_______________________________________________
Dev mailing list
[email protected]
http://rdflib.net/mailman/listinfo/dev

Reply via email to