Invalid XML in ResultSet

RDF literals may contain characters that are not allowed in XML, in particular XML1.0 []. When these literals are returned in a SPARQL Result Set, the returned XML is rendered invalid and can not be correctly parsed by an XML parser as used e.g. in Jena.

Example triple:

<urn:s> <urn:p> "BEL character is \u0007" .

Sparql Query:

SELECT ?o WHERE { <urn:s> <urn:p> ?o . }

Result Set:

<?xml version='1.0' encoding='UTF-8'?>
<sparql xmlns=''><head><variable name='o'/></head>
<results><result><binding name='o'><literal>BEL character is a</literal></binding></result></results>

In the Result Set the character <0x07> is contained (represented here as an "a") which is not allowed. The character should be escaped, e.g. "/u0007" or XML1.1 should be declared in the xml header.