Skip to content

Instantly share code, notes, and snippets.

@white-gecko
Last active November 13, 2019 19:01
Show Gist options
  • Save white-gecko/7a3a8f3bcac8832752905f9dd1d0f765 to your computer and use it in GitHub Desktop.
Save white-gecko/7a3a8f3bcac8832752905f9dd1d0f765 to your computer and use it in GitHub Desktop.
If you want to query a complete dataset with a single construct query.
PREFIX ex: <http://example.org/>
CONSTRUCT {
?s ?p ?o .
?g a ex:Graph ;
ex:hasData ?datalit .
} WHERE {
{
?s ?p ?o .
} UNION {
GRAPH ?g {
?gs ?gp ?go
BIND(CONCAT("<", STR(?gs), "> <", STR(?gp), "> <", STR(?go), "> .") as ?datalit)
}
}
}
PREFIX ex: <http://example.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
CONSTRUCT {
?s ?p ?o .
?g a ex:Graph ;
ex:hasData [ a rdf:Statement ;
rdf:subject ?gs ;
rdf:predicate ?gp ;
rdf:object ?go ] .
} WHERE {
{
?s ?p ?o .
} UNION {
GRAPH ?g {
?gs ?gp ?go
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment