Skip to content

Commit

Permalink
Fix node#toJS by exposing a basic namespace map
Browse files Browse the repository at this point in the history
It was using `ns` assuming it's available globally
  • Loading branch information
Fletcher91 committed Jul 11, 2018
1 parent c0f921e commit 7b4a799
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var $rdf = {
N3Parser: require('./n3parser'),
NamedNode: require('./named-node'),
Namespace: require('./namespace'),
ns: require('./ns'),
Node: require('./node'),
parse: require('./parse'),
Query: require('./query').Query,
Expand Down
1 change: 1 addition & 0 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Node.fromValue = function fromValue (value) {
}

Node.toJS = function fromJS (term) {
const ns = require('./ns')
if (term.elements) {
return term.elements.map(Node.toJS) // Array node (not standard RDFJS)
}
Expand Down
60 changes: 60 additions & 0 deletions src/ns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const Namespace = require('./namespace')

const ns = {
adms: Namespace("http://www.w3.org/ns/adms#"),
as: Namespace("https://www.w3.org/ns/activitystreams#"),
bibo: Namespace("http://purl.org/ontology/bibo/"),
cc: Namespace("http://creativecommons.org/ns#"),
dbo: Namespace("http://dbpedia.org/ontology/"),
dbp: Namespace("http://dbpedia.org/property/"),
dbpedia: Namespace("http://dbpedia.org/resource/"),
dcat: Namespace("http://www.w3.org/ns/dcat#"),
dcterms: Namespace("http://purl.org/dc/terms/"),
dctype: Namespace("http://purl.org/dc/dcmitype/"),
dce: Namespace("http://purl.org/dc/elements/1.1/"),
doap: Namespace("http://usefulinc.com/ns/doap#"),
event: Namespace("http://purl.org/NET/c4dm/event.owl#"),
ex: Namespace("http://example.com/"),
exNS: Namespace("http://example.com/ns#"),
fhir: Namespace("http://hl7.org/fhir/"),
fhir3: Namespace("http://hl7.org/fhir/STU3"),
foaf: Namespace("http://xmlns.com/foaf/0.1/"),
geo: Namespace("http://www.w3.org/2003/01/geo/wgs84_pos#"),
gsp: Namespace("http://www.opengis.net/ont/geosparql#"),
gr: Namespace("http://purl.org/goodrelations/v1#"),
http: Namespace("http://www.w3.org/2011/http#"),
http07: Namespace("http://www.w3.org/2007/ont/http#"),
httph: Namespace("http://www.w3.org/2007/ont/httph#"),
hydra: Namespace("http://www.w3.org/ns/hydra/core#"),
ianalr: Namespace("http://www.w3.org/ns/iana/link-relations/relation#"),
ianamt: Namespace("http://www.w3.org/ns/iana/media-types/"),
link: Namespace("http://www.w3.org/2007/ont/link#"),
org: Namespace("http://www.w3.org/ns/org#"),
owl: Namespace("http://www.w3.org/2002/07/owl#"),
p: Namespace("http://www.wikidata.org/prop/"),
prov: Namespace("http://www.w3.org/ns/prov#"),
qb: Namespace("http://purl.org/linked-data/cube#"),
rdf: Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),
rdfs: Namespace("http://www.w3.org/2000/01/rdf-schema#"),
schema: Namespace("http://schema.org/"),
sh: Namespace("http://www.w3.org/ns/shacl#"),
sioc: Namespace("http://rdfs.org/sioc/ns#"),
skos: Namespace("http://www.w3.org/2004/02/skos/core#"),
ssn: Namespace("http://www.w3.org/ns/ssn/"),
sosa: Namespace("http://www.w3.org/ns/sosa/"),
time: Namespace("http://www.w3.org/2006/time#"),
vann: Namespace("http://purl.org/vocab/vann/"),
vcard: Namespace("http://www.w3.org/2006/vcard/ns#"),
void: Namespace("http://rdfs.org/ns/void#"),
vs: Namespace("http://www.w3.org/2003/06/sw-vocab-status/ns#"),
wd: Namespace("http://www.wikidata.org/entity/"),
wdata: Namespace("https://www.wikidata.org/wiki/Special:EntityData/"),
wdref: Namespace("http://www.wikidata.org/reference/"),
wds: Namespace("http://www.wikidata.org/entity/statement/"),
wdt: Namespace("http://www.wikidata.org/prop/direct/"),
wdv: Namespace("http://www.wikidata.org/value/"),
xmlns: Namespace("http://www.w3.org/2000/xmlns/"),
xsd: Namespace("http://www.w3.org/2001/XMLSchema#"),
}

module.exports = ns

0 comments on commit 7b4a799

Please sign in to comment.