Skip to content

NQuads Parser is not working properly #9

@sumutcan

Description

@sumutcan

rdflib-js produces blank nodes with underscore after : character. When the jsonld.js library tries to parse it with rdf-canonize the QUAD regex does not match with such a blank node and throws an error.

following snippet in NQuads.js does not parse the blank node: _:_g_L15C515

      // parse quad

      const match = line.match(REGEX.quad);

      if(match === null) {
        throw new Error('N-Quads parse error on line ' + lineNumber + '.');
      }

Quoting from NQuads specification:

RDF blank nodes in N-Quads are expressed as _: followed by a blank node label which is a series of name characters. The characters in the label are built upon PN_CHARS_BASE, liberalized as follows:
The characters _ and digits may appear anywhere in a blank node label.
The character . may appear anywhere except the first or last character.
The characters -, U+00B7, U+0300 to U+036F and U+203F to U+2040 are permitted anywhere except the first character.

Changing the regex in NQuads.js to (_:(?:[A-Za-z0-9_]+)) should solve the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions