learner
learner

Reputation: 1

How to create RDF model from DBPedia data using SPARQL

I am a new one on semantic web. I would like to get all object/values for Microsoft from DBPedia using SPARQL query and save result in RDF format. I have made a query on http://dbpedia.org/sparql which works well and returns all pair/values regarding Microsoft.The code is as follows:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

 select * where 
 {{ <http://dbpedia.org/resource/Microsoft>  ?property ?value }
  UNION
 {?property ?value <http://dbpedia.org/resource/Microsoft>}}

What I want is to create RDF format for the results. I read tutorial on https://www.w3.org/TR/rdf-sparql-query/#construct and understood it can be done by using CONSTRUCT query. I changed SELECT to CONSTRUCT, but that did not work. If possible could you tell me what is my mistake and how can I apply CONSTRUCT to my query to get RDF model from the query please? Thanks in advance!

Upvotes: 0

Views: 576

Answers (1)

Ivo Velitchkov
Ivo Velitchkov

Reputation: 2431

In order to get more clear distinction of the actual triples you retrieve, I'd suggest changing the variables in the following way:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

 select * where 
 {{ <http://dbpedia.org/resource/Microsoft>  ?property ?value }
  UNION
 {?subject ?property <http://dbpedia.org/resource/Microsoft>}}

And regarding the result format, just choose "Turtle" or "RDF/XML", instead of "HTML" from the results menu of the SPARQL interface.

Upvotes: 0

Related Questions