| 46 | |
| 47 | // Converts a jsonld.js entity to the N3.js in-memory representation |
| 48 | function convertEntity(entity) { |
| 49 | // Return IRIs and blank nodes as-is |
| 50 | if (entity.type !== 'literal') |
| 51 | 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 | } |
| 62 | } |
| 63 | |
| 64 | module.exports = JsonLdDatasource; |