On 14/02/12 21:31, Milorad Tosic wrote:
Hi,
This is probably a trivial question, but I couldn't find a practical
solution. I'm sending SPARQL queries to a TDB Jena store and it works
fine to some extend (though, I've noticed that
results.getResourceModel().write(out, "TURTLE"); works while
ResultSetFormatter.output(out, results,
ResultSetFormat.syntaxRDF_TURTLE); gives empty result without a
theory that would explain that?!?).
Is "results" is a ResultSet?
You can't write results as Turtle. You can encode the results as RDF
(see outputAsRDF).
ResultSetFormatter.output will print a warning and do nothing (maybe
that ought to be an exception) for a result set and Turtle.
The result.getResourceModel is probably the base data and unrelated to
the query results.
Anyway, I would like to get
SPARQL query results that would use prefixes instead of full URL. Is
that possible? Any advices?
Prefixes are just about surface syntax. The data and results are
absolute URIs, that's the way RDF is defined.
It is a matter of how you print them. The text formatter
(out(ResultSet) etc) uses the prefixes from the original data if
available. The other formats don't have the ability to include prefixes.
A Model in Jena has some prefixes associated with it and you can use
those if you want (in fact a Model has the PrefixMapping interface).
See FmtUtils which are the ARQ internal methods for serializing things.
Andy
Thanks Milorad