2

The output of my application has to be an RDF file (some XML) in browser. How do I get it from a SPARQL endpoint? A SELECT query returns just tables of values. CONSTRUCT queries return just triples. So is there a way to have these queries return RDF files (using some RDF library) or there is some other option?

Ben Companjen
  • 1,417
  • 10
  • 24
hudi
  • 15,555
  • 47
  • 142
  • 246

1 Answers1

2

RDF/SPARQL databases can contains one or more RDF files. With SPARQL the only way to get back RDF triples is via COSTRUCT queries. CONSTRUCT queries return triples that can be serialized in various formats RDF/XML, RDF/Turtle, Ntriples, ... These responses can be considered RDF documents.

If what you need is all the triples from a SPARQL endpoint as a RDF file then you should try to find the RDF dumps for that particular case. Be aware, not all SPARQL services provide RDF dumps. This is something fundamentally aside of the SPARQL protocol.

Manuel Salvadores
  • 16,287
  • 5
  • 37
  • 56
  • 2
    I might add, you could stream the results of a construct query through a streaming RDF writer, such as OpenRdf's RIO or Jena's RIOT to save the results of the query to a file of RDF in the serialization of your choice. – Michael Mar 22 '12 at 18:05