rdfjs / N3.js

Lightning fast, spec-compatible, streaming RDF for JavaScript
http://rdf.js.org/N3.js/
Other
714 stars 130 forks source link

Serializing literal subjects returns invalid results #329

Open joachimvh opened 1 year ago

joachimvh commented 1 year ago

Copy/pasting from https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1582#issuecomment-1451503232

  const n3 = `"1"^^<http://www.w3.org/2001/XMLSchema#boolean> <http://example.com/p> <https://example.com/s> .`;
  const parser = new Parser({ format: 'text/n3' });
  const store = new Store(parser.parse(n3));
  const writer = new Writer({ format: 'text/turtle' });
  writer.addQuads(store.getQuads(null, null, null, null));
  writer.end((error, result): void => console.log(result));

Outputs

"1"^^http://www.w3.org/2001/XMLSchema#boolean <http://example.com/p> <https://example.com/s>.

Which could perhaps be excused in that it is invalid turtle so behaviour is undefined. But the same result occurs when using text/n3 format for the writer, while this is valid N3.