0
votes

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!

1
Without seeing the CONSTRUCT query, how can we say what's wrong?UninformedUser
@AKSW this is my query: CONSTRUCT { ?property ?value } where {{ <dbpedia.org/resource/Microsoft> ?property ?value } UNION {?property ?value <dbpedia.org/resource/Microsoft>}}learner
So you it looks like you did not really understand SPARQL and RDF. In the first part you define the triples that will be contained in the result, so in your case obviously the subject (<dbpedia.org/resource/Microsoft>) is missing. This brings me to the second problem, you have to use property URIs otherwise the are relative. I.e. in the example the protocol is missing, i.e. it should be <http://dbpedia.org/resource/Microsoft>. Moreover, the syntax is wrong as you have two semicolons that must not be there.UninformedUser
Last but not least, in the second part of the UNION you mixed up subject and predicate.UninformedUser
So to sum up, it looks like you copy and pasted parts of some other query without understand what it does. I really suggest some SPARQL tutorials that will help in understanding,UninformedUser

1 Answers

0
votes

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.