I want to create a slight generic query interface for my compiled RDF model.
I have to way of accessing my data :
1- using built in jena itertors / statemetns / resrources / etc ….
2-creating some SPARQL
but for creating SPARQL or RDQL I have to call a bind my SPARQL variables to java variables and since in my SPARQL I can have variety number of variables I don’t know how to make it generic.
so what is the best way of making a RDF query interface generic?
Use SPARQL, not RDQL. Most systems today implement SPARQL that is the W3C standard. With SPARQL, as in SQL, you can use
*to bind all the variable that occur in the triple patterns. Example:Most SPARQL client libraries allow you to get all variables. In Jena ARQ, for example, you’ll find that
QuerySolutionhas a methodIterator<String> varNames(), this method will give you back all the variable names. You can traverse these and use the methodgetin the same class to retrieve the row values.The great advantage of SPARQL is that, since it is a standard, you can use the different triple stores that follow the specification.