I'm saving the Jena RDF model, which contains some SPARQL queries inside using the model.write() in .ttl. In the output .ttl file, the query will look like this:
sml:selectQuery [ a sp:Select ;
sp:text "\r\nSELECT ?blah \r\nWHERE {\r\n blah\r\n}\r\n"
] .
So, it writes the whole query in one line, which is hard to read, especially for more complex queries. And not possible to easily compare queries in GIT.
But it is completely possible to write more readable queries by hand in input .ttl file:
sml:selectQuery [
a sp:Select ;
sp:text """
SELECT blah
WHERE {
blah
}
""" ;
] ;
I've tried looking into the source code to find out if it is possible to change the way serialisation works for writing, but haven't found it. So I want to ask if there's some way to do that or if there's some workaround which may help me.
Try setting the context setting for Turtle: multiline_literals
:
Command line:
riot --pretty TTL --set ttl:multiline_literals=true theDataFile.ttl
Source code:
RDFWriter
.source(model)
.lang(Lang.TTL)
.set(RIOT.symTurtleMultilineLiterals, true)
.output(System.out);
or set it JVM-wide:
RIOT.getContext().set(RIOT.symTurtleMultilineLiterals, true);