Skip to content

Commit 0a4b7bc

Browse files
committed
Parse blank nodes from JSON-LD sources.
1 parent 0676710 commit 0a4b7bc

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/datasources/JsonLdDatasource.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,19 @@ function extractTriples(json, addTriple, done) {
4646

4747
// Converts a jsonld.js entity to an N3.js IRI or literal
4848
function convertEntity(entity) {
49-
// Return IRIs as-is
50-
if (entity.type === 'IRI')
49+
// Return IRIs and blank nodes as-is
50+
if (entity.type !== 'literal')
5151
return entity.value;
52-
// Add a language tag to the literal if present
53-
if ('language' in entity)
54-
return '"' + entity.value + '"@' + entity.language;
55-
// Add a datatype to the literal if present
56-
if (entity.datatype !== 'http://www.w3.org/2001/XMLSchema#string')
57-
return '"' + entity.value + '"^^<' + entity.datatype + '>';
58-
// Otherwise, return the regular literal
59-
return '"' + entity.value + '"';
52+
else {
53+
// Add a language tag to the literal if present
54+
if ('language' in entity)
55+
return '"' + entity.value + '"@' + entity.language;
56+
// Add a datatype to the literal if present
57+
if (entity.datatype !== 'http://www.w3.org/2001/XMLSchema#string')
58+
return '"' + entity.value + '"^^<' + entity.datatype + '>';
59+
// Otherwise, return the regular literal
60+
return '"' + entity.value + '"';
61+
}
6062
}
6163

6264
module.exports = JsonLdDatasource;

0 commit comments

Comments
 (0)