Skip to content

RDFJS compliance: the equals method #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pietercolpaert opened this issue Apr 23, 2018 · 1 comment
Open

RDFJS compliance: the equals method #243

pietercolpaert opened this issue Apr 23, 2018 · 1 comment

Comments

@pietercolpaert
Copy link

pietercolpaert commented Apr 23, 2018

When using the toRDF method, the jsonld.js library does not return RDFJS spec compliant quads as the quads to not contain an equals() function as required by the spec.

Hotfixed this using the DataFactory class from the N3.js library as follows:

  addEqualsMethodToQuad (quad) {
    quad.equals = DataFactory.internal.Quad.prototype.equals;
    if (quad.subject.termType === 'NamedNode')
      quad.subject.equals = DataFactory.internal.NamedNode.prototype.equals;
    if (quad.subject.termType === 'BlankNode')
      quad.subject.equals = DataFactory.internal.BlankNode.prototype.equals;
    if (quad.predicate.termType === 'NamedNode')
      quad.predicate.equals = DataFactory.internal.NamedNode.prototype.equals;
    if (quad.predicate.termType === 'BlankNode')
      quad.predicate.equals = DataFactory.internal.BlankNode.prototype.equals;
    if (quad.object.termType === 'NamedNode')
      quad.object.equals = DataFactory.internal.NamedNode.prototype.equals;
    if (quad.object.termType === 'BlankNode')
      quad.object.equals = DataFactory.internal.BlankNode.prototype.equals;
    if (quad.object.termType === 'Literal')
      quad.object.equals = DataFactory.internal.Literal.prototype.equals;
    if (quad.graph.termType === 'NamedNode')
      quad.graph.equals = DataFactory.internal.NamedNode.prototype.equals;
    if (quad.graph.termType === 'BlankNode')
      quad.graph.equals = DataFactory.internal.BlankNode.prototype.equals;
    return quad;
  }

Fixing this into this library may allow for the N3.js library compatibility and the compatibility to the entire RDF-Ext family.

@RubenVerborgh
Copy link

The idea would actually be that parsers accept a factory argument, such that they can instantiate RDF.js objects of a particular library (like here).

@pietercolpaert pietercolpaert changed the title RDFJS compliancy: the equals method RDFJS compliance: the equals method Apr 24, 2018
rubensworks referenced this issue in ddvlanck/rdf-parser-jsonld Aug 31, 2018
Function parse rewrite based on function term
rubensworks pushed a commit to ddvlanck/rdf-parser-jsonld that referenced this issue Aug 31, 2018
This contains fixes for the following open
non-RDFJS-compliance issues in jsonld:
* digitalbazaar/jsonld.js#243
* digitalbazaar/jsonld.js#244
koo5 added a commit to koo5/understand_humans that referenced this issue Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants