On 08/01/13 20:35, Jean-Marc Vanel wrote:
2013/1/8 Olivier Rossel <[email protected]>:
My current code is like this:
QueryExecution exec =
QueryExecutionFactory.create(QueryFactory.create(queryString,
Syntax.syntaxSPARQL_11), new
DatasetImpl(ModelFactory.createDefaultModel()));
exec.execConstruct().write(byteArrayOutputStream);
Here is the recipe :
Model r = exec.execConstruct();
r.write(byteArrayOutputStream, "N3");
And my queries are like that:
CONSTRUCT { ... } WHERE { SERVICE <http://bla.com/sparql/> {... } }
Is it possible to configure Jena so those CONSTRUCT are sent with an
"Accept: text/n3" header?
The web part would be Fuseki.
I didn't see a way to control this with Jena API :( .
BTW, is it even legal to demand "text/n3" as a result format?
yes.
The current accept negotiation in Fuseki is based on
application/rdf+xml, text/turtle, application/turtle,
application/x-turtle, application/n-triples, text/plain
that's the set checked, respecting q= against the Accept header.
It does not include text/n3. That could be added but it will be treated
as Turtle.
Turtle is not a strict subset of N3 currently. The prefix names are
broader that N3 defines, and there are differences in the treatment of
numbers - small things but they break data exchange.
Generally in Jena, N3 is treated as Turtle.
"Accept: text/turtle" is to be preferred.
r.write(byteArrayOutputStream, "TTL");
There is no strict, compliant N3 parser that covers the beyond-Turtle
and beyond RDF features of N3. The "beyond-Turtle but still RDF"
features are just a matter of writing the parser; the "beyond RDF"
features are fundamental change to Jena (formulae/graph literals). They
are not interoperable with other systems.
You can't create N3-beyond-RDF with CONSTRUCT.
Andy