-
Notifications
You must be signed in to change notification settings - Fork 785
/
Copy pathUnqualified Dublin Core RDF.js
153 lines (126 loc) · 4.11 KB
/
Unqualified Dublin Core RDF.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
{
"translatorID": "6e372642-ed9d-4934-b5d1-c11ac758ebb7",
"translatorType": 2,
"label": "Unqualified Dublin Core RDF",
"creator": "Simon Kornblith",
"target": "rdf",
"minVersion": "1.0.0b3.r1",
"maxVersion": "",
"priority": 100,
"configOptions": {
"dataMode": "rdf/xml"
},
"inRepository": true,
"lastUpdated": "2019-06-11 13:33:25"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2008 Simon Kornblith
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
function doExport() {
var dc = "http://purl.org/dc/elements/1.1/";
Zotero.RDF.addNamespace("dc", dc);
var item;
while (item = Zotero.nextItem()) { // eslint-disable-line no-cond-assign
if (item.itemType == "note" || item.itemType == "attachment") {
continue;
}
var resource;
if (item.ISBN) {
resource = "urn:isbn:" + item.ISBN;
}
else if (item.url) {
resource = item.url;
}
else {
// just specify a node ID
resource = Zotero.RDF.newResource();
}
/** CORE FIELDS **/
// title
if (item.title) {
Zotero.RDF.addStatement(resource, dc + "title", item.title, true);
}
// type
Zotero.RDF.addStatement(resource, dc + "type", item.itemType, true);
// creators
for (var j in item.creators) {
// put creators in lastName, firstName format (although DC doesn't specify)
var creator = item.creators[j].lastName;
if (item.creators[j].firstName) {
creator += ", " + item.creators[j].firstName;
}
if (item.creators[j].creatorType == "author") {
Zotero.RDF.addStatement(resource, dc + "creator", creator, true);
}
else {
Zotero.RDF.addStatement(resource, dc + "contributor", creator, true);
}
}
/** FIELDS ON NEARLY EVERYTHING BUT NOT A PART OF THE CORE **/
// source
if (item.source) {
Zotero.RDF.addStatement(resource, dc + "source", item.source, true);
}
// accessionNumber as generic ID
if (item.accessionNumber) {
Zotero.RDF.addStatement(resource, dc + "identifier", item.accessionNumber, true);
}
// rights
if (item.rights) {
Zotero.RDF.addStatement(resource, dc + "rights", item.rights, true);
}
/** SUPPLEMENTAL FIELDS **/
// TODO - create text citation and OpenURL citation to handle volume, number, pages, issue, place
// publisher/distributor
if (item.publisher) {
Zotero.RDF.addStatement(resource, dc + "publisher", item.publisher, true);
}
else if (item.distributor) {
Zotero.RDF.addStatement(resource, dc + "publisher", item.distributor, true);
}
else if (item.institution) {
Zotero.RDF.addStatement(resource, dc + "publisher", item.institution, true);
}
// date/year
if (item.date) {
Zotero.RDF.addStatement(resource, dc + "date", item.date, true);
}
// ISBN/ISSN/DOI
if (item.ISBN) {
Zotero.RDF.addStatement(resource, dc + "identifier", "ISBN " + item.ISBN, true);
}
if (item.ISSN) {
Zotero.RDF.addStatement(resource, dc + "identifier", "ISSN " + item.ISSN, true);
}
if (item.DOI) {
Zotero.RDF.addStatement(resource, dc + "identifier", "DOI " + item.DOI, true);
}
// callNumber
if (item.callNumber) {
Zotero.RDF.addStatement(resource, dc + "identifier", item.callNumber, true);
}
// archiveLocation
if (item.archiveLocation) {
Zotero.RDF.addStatement(resource, dc + "coverage", item.archiveLocation, true);
}
// medium
if (item.medium) {
// The "medium" property is only part of the qualified DC terms,
// therefore we use here the "format" property.
Zotero.RDF.addStatement(resource, dc + "format", item.medium, true);
}
}
}