Hi,
Is there a way to extract a subgraph of a dataset with SPARQL ? I can see two possibilities :
- Using DESCRIBE, but it is not standardized and not easy to control
- Using CONSTRUCT, but we have to explicitly write all triples that will be created (redundant, difficult with inferred statements, etc.)
What I really want is get the whole subgraph identified by the WHERE clause as an output. Something like :
CONSTRUCT *
WHERE{...}
(I know, it doesn't make much sense... but you get the idea)
Thank you !
To clarify, a little example of how I would do it now (which is probably silly, but I have no idea how to do it better) :
CONSTRUCT{
?resource a ?type .
?resource :property1 ?value1 .
?resource :property2 ?anotherresource .
?anotherresource :property3 ?value2 .
}
WHERE{
?resource a ?type .
?resource :property1 ?value1 .
?resource :property2 ?anotherresource .
?anotherresource :property3 ?value2 .
}
The problem seems quite clear to me : everything is specified twice. Is there a way that I could get everything directly from the WHERE clause ?