rdfjs / N3.js

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

Incorrect parsing of empty Notation3 graph terms #356

Open phochste opened 1 year ago

phochste commented 1 year ago

The current N3 parser doesn't handle empty Notation3 graph terms well:

This Notation3 document:

@prefix : <urn:example:> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .

() log:onNegativeSurface { } .

is parsed as:

[
      Quad {
        id: '',
        _subject: NamedNode { id: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil' },
        _predicate: null,
        _object: null,
        _graph: BlankNode { id: '_:n3-72' }
      },
      Quad {
        id: '',
        _subject: NamedNode { id: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil' },
        _predicate: NamedNode {
          id: 'http://www.w3.org/2000/10/swap/log#onNegativeSurface'
        },
        _object: BlankNode { id: '_:n3-72' },
        _graph: DefaultGraph { id: '' }
      }
]

See also: https://github.com/jeswr/pretty-turtle/issues/45

jeswr commented 1 year ago

Also see https://github.com/rdfjs/types/issues/37 regarding the handling of empty graph terms.