CONSTRUCT
Use the CONSTRUCT query form to create new data from your existing data.
Syntax
[ PREFIX Clause ] CONSTRUCT { graph_or_triple_template } WHERE Clause [ Solution Modifiers ]
For more information on specific clauses in the CONSTRUCT query syntax, see SPARQL Basics.
CONSTRUCT queries take each solution and substitute it for the variables in the graph or triple template. AnzoGraph combines the triples into a single RDF graph in N-Triple format. If you specify a pattern that produces a triple that contains an unbound variable or an illegal RDF construct such as a literal value in the subject or predicate position, these problematic triples are excluded from the output graph.
CONSTRUCT query results are always returned in RDF format. They cannot be returned in any other format and any options normally used to specify a result format, such as the Accept, Content-Type, or format parameters are simply ignored.
Examples
The following example query specifies a triple template that constructs a new age predicate and approximate age value for the person triples in the sample Tickit data set. The resulting age values are approximations because the calculation excludes days and months.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> CONSTRUCT { ?person <age> ?age . } WHERE { GRAPH <tickit> { SELECT ?person ((YEAR(?date))-(YEAR(xsd:dateTime(?birthdate))) AS ?age) WHERE { ?person <birthday> ?birthdate . BIND(xsd:dateTime(NOW()) AS ?date) } } } ORDER BY ?person LIMIT 50
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. <person1> <age> "79"^^<http://www.w3.org/2001/XMLSchema#int> . <person10> <age> "81"^^<http://www.w3.org/2001/XMLSchema#int> . <person100> <age> "51"^^<http://www.w3.org/2001/XMLSchema#int> . <person1000> <age> "75"^^<http://www.w3.org/2001/XMLSchema#int> . <person10000> <age> "24"^^<http://www.w3.org/2001/XMLSchema#int> . <person10001> <age> "36"^^<http://www.w3.org/2001/XMLSchema#int> . <person10002> <age> "53"^^<http://www.w3.org/2001/XMLSchema#int> . <person10003> <age> "28"^^<http://www.w3.org/2001/XMLSchema#int> . <person10004> <age> "75"^^<http://www.w3.org/2001/XMLSchema#int> . <person10005> <age> "47"^^<http://www.w3.org/2001/XMLSchema#int> . <person10006> <age> "61"^^<http://www.w3.org/2001/XMLSchema#int> . <person10007> <age> "29"^^<http://www.w3.org/2001/XMLSchema#int> . ...