Created on Feb. 23, 2013, 11:50 a.m. by Hevok & updated on Feb. 25, 2013, 7:35 p.m. by Hevok
SPARQL Construction of RDF Graphs - CONSTRUCT
itself defines a Template for the Construction of RDF Graphs
.
¶
¶
For example given a simple kKnowledge bBase with a pPrefix to a nNamespace and two pPersons that are connected to some Blank Node with a nName and id for each pPerson.
¶
¶
This nNamespace can be transformed into the foaf nNamespace where one has also something like names, but one has to substitute the username with the a foaf name to have a foaf output. In the Graph Pattern one is looking for all users that have the userid or username from the kKnoweldge bBase and one can construct/define a new pattern where one puts the Subject from the original Pattern and nName and one substitutes the pProperty to the pProperty of the new nNamespace, namely from the foaf namespace.
¶
¶
In the end the result of the Query will be if it was defined as serialized RDF/XML will be an XML file based on RDF with the Content of the Database in connection with for instance the foaf nNamespace which was in the predefined Template of the construct sStatement. This is a simple way to translate from one Vocabulary to another Vocabulary. Therefore, it is for Vocabulary transcription/transformation which is very handy.
¶
¶
CONSTRUCT
defines a template for the construction of new RDF Graphs.
¶
¶
Data:
¶
¶
@prefix org: <http://example.com/ns#>] .
¶
¶
:a org:username "Hevok" .
¶
:a org:userid 5 .
¶
¶
:b org:username "EVA" .
¶
:b org:userid 2 .
¶
¶
¶
Query:
¶
¶
PREFIX foaf: <http://xmlns.com/foaf/0.1/>]
¶
PREFIX org: <http://example.com/ns#>]
¶
¶
CONSTRUCT { ?x foaf:name ?name }
¶
WHERE { ?x org:name ?name }
¶
¶
¶
Result of a CONSTRUCT
Query as serialized RDF/XML
¶
¶
<rdf:RDF
¶
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-nx#"
¶
xmlns:foaf="http://xmlns.com/foaf/0.1/">]
¶
<rdf:Description>
¶
<foaf:name>Hevok</foaf:name>
¶
</rdf:Description>
¶
<rdf:Description>
¶
<foaf:name>EVA</foaf:name>
¶
</rdf:Description>
¶
</rdf:RDF>
Comment on This Data Unit