So I have this turtle file:
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.org/> .
@prefix ex-sample: <http://example.org/sample/> .
ex:a rdf:type skos:Concept .
ex:a rdf:prefLabel "a" .
ex:b rdf:type skos:Concept .
ex:b rdf:prefLabel "b" .
ex:c rdf:type skos:Concept .
ex:c rdf:prefLabel "c" .
ex:d rdf:type skos:Concept .
ex:d rdf:prefLabel "d" .
ex:e rdf:type ex-sample:sample .
ex:e dct:subject ex:d .
ex:e dct:subject ex:c .
I want to make a SPARQL query that returns a column that lists all the possible paths to reach the ex:a from ex:e. I expect the table to have two rows, that look like this:
row1: d,c,b,a
row2: c,b,a
I have tried this SPARQL query:
?target rdf:type ex:sample .
?target skos:prefLabel ?targetTitle .
?target dct:subject ?dctsubject .
?dctsubject skos:broader* ?furtherPath .
?furtherPath skos:prefLabel ?furtherPathLabel .
}
It can identify all the paths but they are printed in many rows, like this:
row 1: d
row 2: c
row 3: b
row 4: a
row 5: c
row 6: b
row 7: a
Thanks!