Kim Vella
Kim Vella

Reputation: 21

Querying named graphs and different SPARQL endpoints

I am quite new to SPARQL so bear with me, please. I am using Apache Jena to store my RDFs in different named graphs, I have these RDF named graphs:

Endpoint Name:http://localhost:3030/2012-2013/query

Named Graphs:

<http://localhost:3030/2012-2013/data/2012-2013_62DAYBYCANCER>
<http://localhost:3030/2012-2013/data/2012-2013_62_DAY_CANCER_PLAN_ALL_CANCER>
<http://localhost:3030/2012-2013/data/2012-2013_62_DAY_CRS_SCEENING>

In another endpoint I have these named graphs:

Endpoint Name : http://localhost:3030/2013-2014/query

Named Graphs:

<http://localhost:3030/2013-2014/data/2013-2014_62DAYBYCANCER>
<http://localhost:3030/2013-2014/data/2013-2014_62_DAY_CANCER_PLAN_ALL_CANCER>
<http://localhost:3030/2013-2014/data/2013-2014_62_DAY_CRS_SCEENING>

I would like to access the triples in the graph 2012-2013_62DAYBYCANCER and joining them to triples from 2013-2014_62DAYBYCANCER. Is it possible to use named graphs and service together?

The structure of the graphs is given below. I would like to join them with the provider and the period-type to get the total.

For the graph 2012-2013_62DAYBYCANCER the structure is:

<rdf:Description rdf:about="http://mastersrdf.org/dataset/2012_2013_62DAYBYCANCER/1"> 
    <qb:dataSet rdf:resource="http://mastersrdf.org/dataset/2012_2013_62DAYBYCANCER"/>
    <provider xmlns="http://mastersrdf.org/def/statistical-dimension/" rdf:resource="http://mastersrdf.org/hull-and-east-yorkshire-hospitals-nhs-trust"/>
    <total xmlns="http://mastersrdf.org/def/statistical-dimension/">4</total>
    <period-type xmlns="http://mastersrdf.org/def/statistical-dimension/" rdf:resource="http://mastersrdf.org/q1"/>
</rdf:Description>

For the graph 2013-2014_62DAYBYCANCER the structure is:

<rdf:Description rdf:about="http://mastersrdf.org/dataset/2013_2014_62DAYBYCANCER/1"> 
    <qb:dataSet rdf:resource="http://mastersrdf.org/dataset/2013_2014_62DAYBYCANCER"/>
    <provider xmlns="http://mastersrdf.org/def/statistical-dimension/" rdf:resource="http://mastersrdf.org/hull-and-east-yorkshire-hospitals-nhs-trust"/>
    <total xmlns="http://mastersrdf.org/def/statistical-dimension/">50</total>
    <period-type xmlns="http://mastersrdf.org/def/statistical-dimension/" rdf:resource="http://mastersrdf.org/q1"/>
</rdf:Description>

Upvotes: 0

Views: 169

Answers (1)

AndyS
AndyS

Reputation: 16700

Is it possible to use named graphs and service together?

Yes. The pattern in the SERVICE clause will need to include a GRAPH clause. (The desired result will not be obtained by the SERVICE clause being inside a GRAPH clause.)

Upvotes: 2

Related Questions