Andy, Yes, results are ResultSet. What you described about ResultSetFormatter.output is exactly what I noticed, but couldn't find it in any documentation, so I concluded that I did something wrong. Thanks for the explanation.
Prefixes only matter the presentation style and are not related to resource identity IRI/URI etc. However, it would be more convenient for a human user to watch query results presented without full URI names. In fact, my personal choice would be turtle format with prefixes instead of full URI names. Are you suggesting that if I set prefixes explicitly in the Model containing results before I try to do results.getResourceModel().write(out, "TURTLE") it would print turtle format with prefixes instead of full URL names? Thanks, Milorad ----- Original Message ----- > From: Andy Seaborne <[email protected]> > To: [email protected] > Cc: > Sent: Wednesday, February 15, 2012 10:02 AM > Subject: Re: namespaces in sparql results > > 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 >
