Search code examples
pythonsyntaxrdfrdflib

what is the equivalent of rdf:ID in RDFlib?


I tried g.add(foo,RDF.ID,boo) but it didn't work. In the other hand RDF.type and RDF.about seems to work. how can i use rdf:ID in rdflib ?


Solution

  • You can't. rdf:ID is not an RDF property (neither is rdf:about, by the way), it's merely a syntactical device of the RDF/XML syntax. Just like angle brackets < and > are syntactical devices.

    In RDF/XML, rdf:ID is used to identify the subject of one or more RDF statements. For example:

    <rdf:Description rdf:ID="p1">
          <rdf:type rdf:resource="#Person">
          <rdfs:label>John</rdfs:label>
    </rdf:Description>
    

    is a bit of RDF/XML that contains two RDF statements. The subject for both of these statements is p1. The first statement says that p1 is of type Person. The second statement says that the label of p1 is "John".

    The trick, when working with RDFLib or any other RDF tool, is to think in terms of the RDF graph (that is, the collection of statements). Forget you ever saw what RDF/XML looked like.