how to insert a list in rdf

1.7k Views Asked by At

I have a graph, and in this graph I have a list like this:

:Michelangelo       :representativeFor :Italy;
                rdfs:label "Michelangelo di Ludovico Buonarroti Simoni";
                :birthInfo [:date "1475-03-10"^^xsd:date; :place  :Florence];
                :sculptorOf [a rdf:List; rdf:first :Pieta; rdf:rest [a rdf:List; rdf:first :David; rdf:rest [a rdf:List; rdf:first :TheLastJudgement; rdf:rest rdf:nil]]];
:sculptorOf rdfs:domain :Sculptor; rdfs:range :Sculpture.

When I put this query

select * 
where {:David a ?z}

I expect to get resourse and Sculpture. I don't understand why is not working , what should I do ?

1

There are 1 best solutions below

1
Joshua Taylor On

Your title is how to insert a list in rdf, but it looks like you're trying to query where your values in the query are in the list in the data.

If I understand you correctly, you want to find David's types based on:

:Michelangelo :sculptorOf [a rdf:List;
                           rdf:first :Pieta; 
                           rdf:rest [a rdf:List;
                                     rdf:first :David;
                                     rdf:rest [a rdf:List;
                                               rdf:first :TheLastJudgement;
                                               rdf:rest rdf:nil]]];

and the domain and range axioms:

:sculptorOf rdfs:domain :Sculptor; rdfs:range :Sculpture.

This isn't how RDF and OWL work. Michaelangelo didn't sculpt a list of things, he sculpted different things. In RDF, you'd represent this as:

:Michelangelo :sculptorOf  :Pieta, :David, :TheLastJudgement .

That's shorthand for three triples:

:Michelangelo :sculptorOf  :Pieta .
:Michelangelo :sculptorOf  :David .
:Michelangelo :sculptorOf  :TheLastJudgement .

Now, if you have OWL inference enabled, you'll be able to infer that since David is the object of a sculptorOf assertion, David must have the type Sculpture. If RDF(S) inference is available, you'll also be able to infer that David is an rdfs:Resource.