Skip to content

Commit

Permalink
Support generalized RDF N-Quads serialization.
Browse files Browse the repository at this point in the history
Add support for generalized RDF `BlankNode` predicate during N-Quads
serialization.
  • Loading branch information
davidlehn committed Sep 15, 2023
1 parent 71638d8 commit fb7d15c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
- Use a pre-computed map of replacement values.
- Performance difference depends on the number of replacements. The
[rdf-canon][] escaping test showed up to 15% improvement.
- Support generalized RDF `BlankNode` predicate during N-Quads serialization.

### Fixed
- Disable native lib tests in a browser.
Expand Down
8 changes: 6 additions & 2 deletions lib/NQuads.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,12 @@ module.exports = class NQuads {
nquad += `_:${s.value}`;
}

// predicate can only be NamedNode
nquad += ` <${_iriEscape(p.value)}> `;
// predicate normally a NamedNode, can be a BlankNode in generalized RDF
if(p.termType === TYPE_NAMED_NODE) {
nquad += ` <${_iriEscape(p.value)}> `;
} else {
nquad += ` _:${p.value} `;
}

// object is NamedNode, BlankNode, or Literal
if(o.termType === TYPE_NAMED_NODE) {
Expand Down

0 comments on commit fb7d15c

Please sign in to comment.