When using rdflib.js to create xsd:boolean literals and serialise them to Turtle, boolean literals with lexical form "true" are incorrectly serialised as "false". This appears to be a bug in the boolean normalisation logic used by the Turtle serializer.
According to the XSD and RDF specs for xsd:boolean, the lexical space is:
"true" → value true
"false" → value false
"1" → value true
"0" → value false
In the current rdflib.js behaviour, "true" is being normalised to the lexical form "false" on serialisation, which is not spec‑compliant.
Reproducible example
const $rdf = require('rdflib')
const XSD = $rdf.Namespace('http://www.w3.org/2001/XMLSchema#')
const store = $rdf.graph()
const subject = $rdf.sym('http://example.org/s')
const predicate = $rdf.sym('http://example.org/p')
// Four literals with xsd:boolean datatype and different lexical forms
const litTrue = $rdf.literal('true', null, XSD('boolean'))
const litFalse = $rdf.literal('false', null, XSD('boolean'))
const litOne = $rdf.literal('1', null, XSD('boolean'))
const litZero = $rdf.literal('0', null, XSD('boolean'))
store.add(subject, predicate, litTrue)
store.add(subject, predicate, litFalse)
store.add(subject, predicate, litOne)
store.add(subject, predicate, litZero)
$rdf.serialize(
undefined, // base
store,
'http://example.org/',
'text/turtle',
(err, ttl) => {
if (err) {
console.error(err)
return
}
console.log(ttl)
}
)
On my system, the relevant part of the Turtle output looks like:
<http://example.org/s> <http://example.org/p> false, false, true, false .
When using rdflib.js to create xsd:boolean literals and serialise them to Turtle, boolean literals with lexical form "true" are incorrectly serialised as "false". This appears to be a bug in the boolean normalisation logic used by the Turtle serializer.
According to the XSD and RDF specs for xsd:boolean, the lexical space is:
"true" → value true
"false" → value false
"1" → value true
"0" → value false
In the current rdflib.js behaviour, "true" is being normalised to the lexical form "false" on serialisation, which is not spec‑compliant.
Reproducible example
On my system, the relevant part of the Turtle output looks like: