0

Lets assume Model contains this data in triplet form.

@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ns1: <http://example.org/vocab#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/library> a ns1:Library ;
    ns1:contains <http://example.org/library/the-republic> .

<http://example.org/library/the-republic> a ns1:Book ;
    ns1:contains <http://example.org/library/the-republic#introduction> ;
    dc:creator "Plato" ;
    dc:title "The Republic" .

<http://example.org/library/the-republic#introduction> a ns1:Chapter ;
    dc:description "An introductory chapter on The Republic." ;
    dc:title "The Introduction" .

So I want create a new Model from this Model.
This type of query :

<http://example.org/library> ns1:contains ?data.

Above query will give me

?data = <http://example.org/library/the-republic>

But I want every triplets in new Model who are children of (originated from) this resultant URL ?data = <http://example.org/library/the-republic> including this result triplet also in Model

<http://example.org/library> ns1:contains <http://example.org/library/the-republic> .


So new Model will be :

@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ns1: <http://example.org/vocab#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/library> ns1:contains <http://example.org/library/the-republic> .

<http://example.org/library/the-republic> a ns1:Book ;
    ns1:contains <http://example.org/library/the-republic#introduction> ;
    dc:creator "Plato" ;
    dc:title "The Republic" .

<http://example.org/library/the-republic#introduction> a ns1:Chapter ;
    dc:description "An introductory chapter on The Republic." ;
    dc:title "The Introduction" .

To add more clarity let take another example.
Query is :

<http://example.org/library/the-republic> dc:creator ?data.

Here the result is ?data = "Plato" . And "Plato" is not a IRI or blank Node.
So new Model will be:

@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ns1: <http://example.org/vocab#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


<http://example.org/library/the-republic> dc:creator "Plato" .

Is there is any efficient way to do this other than recursively? I am creating new Model to avoid cycle because it is not necessary the data is acyclic.

Badman
  • 407
  • 5
  • 17
  • I don't get it for the first example. It's the same model as the initial one. Are you sure that the first triple should also be contained in the the second model then? – UninformedUser Jan 23 '17 at 08:18
  • From what I understand, you want to have all outgoing triples for the resource? If so, this is sometimes also referred to as Concise Bounded Description: https://www.w3.org/Submission/CBD/ . There are also extension that cover the incoming triples, sometimes called Symmetric Concise Bounded Description – UninformedUser Jan 23 '17 at 08:19
  • 1
    It is very unclear what you're asking. Please [edit] your question to clarify. In particular: clarify what the difference between the first and second model is, or what these query patterns you mention have to do with the problem. Try constructing an [mcve] that demonstrates the problem. – Jeen Broekstra Jan 24 '17 at 02:20

0 Answers0