Skip to content

Commit a481c07

Browse files
authoredMar 17, 2021
Merge pull request #483 from bourgeoa/solid-namespace
use of solid prefixes
2 parents 5506be5 + b2ca73a commit a481c07

File tree

6 files changed

+46
-32
lines changed

6 files changed

+46
-32
lines changed
 

‎package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"cross-fetch": "^3.0.6",
5050
"jsonld": "^3.3.0",
5151
"n3": "^1.8.0",
52+
"solid-namespace": "^0.5.0",
5253
"xmldom": "^0.4.0"
5354
},
5455
"devDependencies": {

‎src/serializer.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@ import * as Uri from './uri'
1111
import * as Util from './utils-js'
1212
import CanonicalDataFactory from './factories/canonical-data-factory'
1313
import { createXSD } from './xsd'
14+
import solidNs from 'solid-namespace'
1415

1516
export default (function () {
1617
var __Serializer = function (store) {
1718
this.flags = ''
1819
this.base = null
1920

2021
this.prefixes = [] // suggested prefixes
21-
this.namespaces = [] // complementary indexes
22+
this.namespaces = [] // complementary
23+
const nsKeys = Object.keys(solidNs())
24+
for (const i in nsKeys) {
25+
const uri = solidNs()[nsKeys[i]]('')
26+
const prefix = nsKeys[i]
27+
this.prefixes[uri] = prefix
28+
this.namespaces[prefix] = uri
29+
}
2230

2331
this.suggestPrefix('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') // XML code assumes this!
2432
this.suggestPrefix('xml', 'reserved:reservedForFutureUse') // XML reserves xml: in the spec.

‎tests/serialize/t10-ref.ttl

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
@prefix : </details.ttl#>.
2+
@prefix cal: <http://www.w3.org/2002/12/cal/ical#>.
23
@prefix dc: <http://purl.org/dc/elements/1.1/>.
4+
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
5+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
36
@prefix sched: <http://www.w3.org/ns/pim/schedule#>.
7+
@prefix space: <http://www.w3.org/ns/pim/space#>.
48
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
59
@prefix c: <https://www.w3.org/People/Berners-Lee/card#>.
6-
@prefix sp: <http://www.w3.org/ns/pim/space#>.
710
@prefix det: <http://linkeddata.github.io/app-schedule/details.ttl#>.
8-
@prefix ic: <http://www.w3.org/2002/12/cal/ical#>.
9-
@prefix n0: <http://xmlns.com/foaf/0.1/>.
10-
@prefix rd: <http://www.w3.org/2000/01/rdf-schema#>.
1111

1212
:event
1313
a sched:SchedulableEvent;
1414
dc:author c:i;
1515
dc:created "2015-09-15T11:20:05Z"^^xsd:dateTime;
16-
sp:inspiration det:event1.
16+
space:inspiration det:event1.
1717
:event1
1818
dc:author :id1442316021316;
1919
dc:title "TAG 2016 Q1 Meeting ";
20-
rd:comment "Three day meeting, starting date:";
21-
ic:location "Melbourne Australia";
20+
rdfs:comment "Three day meeting, starting date:";
21+
cal:location "Melbourne Australia";
2222
sched:availabilityOptions sched:YesNoMaybe;
2323
sched:invitee
2424
:id1442316021320, :id1442316359855, :id1442316381050, :id1442316382860,
@@ -27,27 +27,27 @@
2727
sched:option :id1442316021318, :id1442316021319;
2828
sched:ready "2015-09-15T11:20:21Z"^^xsd:dateTime;
2929
sched:results </results.ttl>.
30-
:id1442316021316 n0:mbox "timbl@w3.org"; n0:name "Tim BL".
30+
:id1442316021316 foaf:mbox "timbl@w3.org"; foaf:name "Tim BL".
3131

32-
:id1442316021318 ic:dtstart "2016-01-13".
32+
:id1442316021318 cal:dtstart "2016-01-13".
3333

34-
:id1442316021319 ic:dtstart "2016-01-20".
34+
:id1442316021319 cal:dtstart "2016-01-20".
3535

36-
:id1442316021320 n0:mbox "peter.linss@hp.com".
36+
:id1442316021320 foaf:mbox "peter.linss@hp.com".
3737

38-
:id1442316359855 n0:mbox "appelquist@gmail.com".
38+
:id1442316359855 foaf:mbox "appelquist@gmail.com".
3939

40-
:id1442316381050 n0:mbox "mnot@mnot.net".
40+
:id1442316381050 foaf:mbox "mnot@mnot.net".
4141

42-
:id1442316382860 n0:mbox "hadley@linkedgov.org".
42+
:id1442316382860 foaf:mbox "hadley@linkedgov.org".
4343

44-
:id1442316551915 n0:mbox "yzhu@yahoo-inc.com".
44+
:id1442316551915 foaf:mbox "yzhu@yahoo-inc.com".
4545

46-
:id1442316616585 n0:mbox "ylafon@w3.org".
46+
:id1442316616585 foaf:mbox "ylafon@w3.org".
4747

48-
:id1442316618393 n0:mbox "slightlyoff@google.com".
48+
:id1442316618393 foaf:mbox "slightlyoff@google.com".
4949

50-
:id1442316627647 n0:mbox "travis.leithead@microsoft.com".
50+
:id1442316627647 foaf:mbox "travis.leithead@microsoft.com".
5151

52-
:id1442316628781 n0:mbox "timbl@w3.org".
52+
:id1442316628781 foaf:mbox "timbl@w3.org".
5353

‎tests/serialize/t12-ref.ttl

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@prefix : </structures.n3#>.
2-
@prefix XML: <http://www.w3.org/2001/XMLSchema#>.
2+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
33

44
:DSK :name "Dexter Scott King".
55

66
:MLK
7-
:born "1929-01-17"^^XML:date;
8-
:died "1968-01-15"^^XML:date;
7+
:born "1929-01-17"^^xsd:date;
8+
:died "1968-01-15"^^xsd:date;
99
:friend [];
1010
:name "Martin Luther King, Jr";
1111
:spouse _:_g_L4C88;
@@ -17,7 +17,7 @@
1717
:ZooReading1
1818
:boolDisabled false;
1919
:boolEnabled true;
20-
:date "2015-02-28"^^XML:date;
20+
:date "2015-02-28"^^xsd:date;
2121
:decBig 1234567890.99;
2222
:decBigNegative -1234567890.99;
2323
:decWithPoint 10.0;
@@ -29,10 +29,10 @@
2929
:intBig 1234567890;
3030
:intCount 16;
3131
:intNegative -123;
32-
:time "2015-03-16T17:53Z"^^XML:dateTime.
32+
:time "2015-03-16T17:53Z"^^xsd:dateTime.
3333
_:_g_L4C88 :name "Coretta Scott King".
3434

35-
[ a :Speech; :author :MLK; :date "1963-08-23"^^XML:date; :title "I have a dream" ].
35+
[ a :Speech; :author :MLK; :date "1963-08-23"^^xsd:date; :title "I have a dream" ].
3636

3737
[ :friend :MLK ].
3838

‎tests/serialize/t13-ref.ttl

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
@prefix : </,structures.nt#>.
22
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
3+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
34
@prefix str: </structures.n3#>.
4-
@prefix XML: <http://www.w3.org/2001/XMLSchema#>.
55

66
str:DSK str:name "Dexter Scott King".
77

88
str:MLK
9-
str:born "1929-01-17"^^XML:date;
10-
str:died "1968-01-15"^^XML:date;
9+
str:born "1929-01-17"^^xsd:date;
10+
str:died "1968-01-15"^^xsd:date;
1111
str:friend [];
1212
str:name "Martin Luther King, Jr";
1313
str:spouse _:_g_L4C88;
@@ -19,7 +19,7 @@ str:YK str:name "Yolanda King".
1919
str:ZooReading1
2020
str:boolDisabled false;
2121
str:boolEnabled true;
22-
str:date "2015-02-28"^^XML:date;
22+
str:date "2015-02-28"^^xsd:date;
2323
str:decBig 1234567890.99;
2424
str:decBigNegative -1234567890.99;
2525
str:decWithPoint 10.0;
@@ -31,13 +31,13 @@ str:ZooReading1
3131
str:intBig 1234567890;
3232
str:intCount 16;
3333
str:intNegative -123;
34-
str:time "2015-03-16T17:53Z"^^XML:dateTime.
34+
str:time "2015-03-16T17:53Z"^^xsd:dateTime.
3535
_:_g_L4C88 str:name "Coretta Scott King".
3636

3737
[
3838
a str:Speech;
3939
str:author str:MLK;
40-
str:date "1963-08-23"^^XML:date;
40+
str:date "1963-08-23"^^xsd:date;
4141
str:title "I have a dream"
4242
].
4343
[ str:friend str:MLK ].

0 commit comments

Comments
 (0)
Please sign in to comment.