basilapi / basil

Building Apis SImpLy from sparql endpoints
http://basil.kmi.open.ac.uk
24 stars 5 forks source link

RDF output for SELECT/ASK queries #39

Open enridaga opened 9 years ago

enridaga commented 9 years ago

The reason is to have a uniform support for all APIs, independently from the nature of the query.

enridaga commented 9 years ago

While this is not usually supported by endpoint, it is useful to hide this property from the user and offer an RDF representation of the result set (select) or boolean (ask) responses.

enridaga commented 9 years ago

Jena has all we need to perform this operation. Here is the formalism:

However I am not 100% sure that this would be the more intuitive way for doing so. Another option would be to serve it as RDF using the CSV vocabulary.

enridaga commented 9 years ago

Here is an example of the output that the Jena library produces for a ResultSet of 5 rows in RDF:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rs="http://www.w3.org/2001/sw/DataAccess/tests/result-set#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > 
  <rdf:Description rdf:nodeID="A0">
    <rs:value rdf:resource="http://bnb.data.bl.uk/id/person/BorrowGeorgeHenry1803-1881"/>
    <rs:variable>person</rs:variable>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A1">
    <rs:binding rdf:nodeID="A2"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A2">
    <rs:value rdf:resource="http://bnb.data.bl.uk/id/person/BashkirtseffMarie1860-1884"/>
    <rs:variable>person</rs:variable>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A3">
    <rs:value rdf:resource="http://bnb.data.bl.uk/id/person/BlundenEdmund1896-1974"/>
    <rs:variable>person</rs:variable>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A4">
    <rs:binding rdf:nodeID="A0"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A5">
    <rs:size rdf:datatype="http://www.w3.org/2001/XMLSchema#int">5</rs:size>
    <rs:solution rdf:nodeID="A4"/>
    <rs:solution rdf:nodeID="A6"/>
    <rs:solution rdf:nodeID="A7"/>
    <rs:solution rdf:nodeID="A8"/>
    <rs:solution rdf:nodeID="A1"/>
    <rs:resultVariable>person</rs:resultVariable>
    <rdf:type rdf:resource="http://www.w3.org/2001/sw/DataAccess/tests/result-set#ResultSet"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A8">
    <rs:binding rdf:nodeID="A9"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A9">
    <rs:value rdf:resource="http://bnb.data.bl.uk/id/person/BernsteinLeonard"/>
    <rs:variable>person</rs:variable>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A10">
    <rs:value rdf:resource="http://bnb.data.bl.uk/id/person/BirdJohn1954-"/>
    <rs:variable>person</rs:variable>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A6">
    <rs:binding rdf:nodeID="A3"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A7">
    <rs:binding rdf:nodeID="A10"/>
  </rdf:Description>
</rdf:RDF>

One part I don't like in this representation is that the order of the rows is lost.

enridaga commented 9 years ago

Another candidate is a recent W3C candidate recommendation:

enridaga commented 9 years ago

About how to implement it, I opened a question to SO as things are not very clear... http://stackoverflow.com/questions/33136916/streaming-a-resultset-as-rdf-using-a-custom-vocabulary