rdf4j
rdf4j copied to clipboard
SPARQLResultsTSVWriter writes naked/unquoted xsd:strings
Current Behavior
Literals of type xsd:string often get written out in SPARQL TSV results without quotes.
This is because of this section of code:
https://github.com/eclipse-rdf4j/rdf4j/blob/cd6509ba05c4d07eb9472158cb06b996b437b9e8/core/queryresultio/text/src/main/java/org/eclipse/rdf4j/query/resultio/text/tsv/SPARQLResultsTSVWriter.java#L204
Expected Behavior
The spec for SPARQL Results TSV says:
4.2 Serializing RDF Terms
The SPARQL Results TSV Results Format serializes RDF terms in the results table by using the syntax that SPARQL [SPARQL11-QUERY] and Turtle [TURTLE] use.
IRIs enclosed in <...>, literals are enclosed with double quotes "..." or single quotes ' ...' with optional @lang or ^^ for datatype. The quotes around the lexical form is required.
So, according to this last sentence — plus the reference to Turtle just previous — in TSV SPARQL results, one would expect all xsd:string literals to be quoted, in all circumstances — and not just when they don't pass the conditions in line 204
Steps To Reproduce
From the workbench, execute a SPARQL insert like this:
INSERT DATA
{
GRAPH <http://example/g> {
<http://example/s1> <http://example/p1> "o3" .
}
}
Then execute a query like this:
select ?o { ?s ?p ?o }
Then download the results as SPARQL/TSV, and view in a text editor, to see:
?o
o3
...the o3 there should be "o3".
Version
5.1.0
Are you interested in contributing a solution yourself?
None
Anything else?
No response