-
Notifications
You must be signed in to change notification settings - Fork 1
/
Short Title Catalogue Netherlands (PICA-STCN).js
2014 lines (1958 loc) · 59.7 KB
/
Short Title Catalogue Netherlands (PICA-STCN).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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"translatorID": "bdf0aa2b-2209-44a2-ac1f-e079221a08b1",
"label": "Short Title Catalogue, Netherlands (PICA-STCN)",
"creator": "Sean Takats, Michael Berkowitz, Sylvain Machefert, Sebastian Karcher (with adaptations for STCN by Ben Pauley)",
"target": "^https?://picarta\\.oclc\\.org/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": false,
"translatorType": 4,
"browserSupport": "gcsb",
"lastUpdated": "2015-06-28 15:49:46"
}
function getSearchResults(doc) {
return doc.evaluate(
"//table[@summary='short title presentation']/tbody/tr//td[contains(@class, 'rec_title')]|//table[@summary='hitlist']/tbody/tr//td[contains(@class, 'hit') and a/@href]",
doc, null, XPathResult.ANY_TYPE, null);
}
function detectWeb(doc, url) {
var multxpath = "//span[@class='tab1']|//td[@class='tab1']";
if (elt = doc.evaluate(multxpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
var content = elt.textContent;
//Z.debug(content)
if ((content == "Liste des résultats") || (content == "shortlist") || (content == 'Kurzliste') || content == 'titellijst') {
if(!getSearchResults(doc).iterateNext()) return; //no results. Does not seem to be necessary, but just in case.
return "multiple";
} else if ((content == "Notice détaillée") || (content == "title data") || (content == 'Titeldaten') || (content == 'Vollanzeige') ||
(content == 'Besitznachweis(e)') || (content == 'full title') || (content == 'Titelanzeige' || (content == 'titelgegevens'))) {
var xpathimage = "//span[@class='rec_mat_long']/img|//table[contains(@summary, 'presentation')]/tbody/tr/td/img";
if (elt = doc.evaluate(xpathimage, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
var type = elt.getAttribute('src');
//Z.debug(type);
if (type.indexOf('article.') > 0) {
//book section and journal article have the same icon
//we can check if there is an ISBN
if(ZU.xpath(doc, '//tr/td[@class="rec_lable" and .//span[starts-with(text(), "ISBN")]]').length) {
return 'bookSection';
}
return "journalArticle";
} else if (type.indexOf('audiovisual.') > 0) {
return "film";
} else if (type.indexOf('book.') > 0) {
return "book";
} else if (type.indexOf('handwriting.') > 0) {
return "manuscript";
} else if (type.indexOf('sons.') > 0 || type.indexOf('sound.') > 0 || type.indexOf('score') > 0) {
return "audioRecording";
} else if (type.indexOf('thesis.') > 0) {
return "thesis";
} else if (type.indexOf('map.') > 0) {
return "map";
}
}
return "book";
}
}
}
function scrape(doc, url) {
var zXpath = '//span[@class="Z3988"]';
var eltCoins = doc.evaluate(zXpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext();
if (eltCoins) {
var coins = eltCoins.getAttribute('title');
var newItem = new Zotero.Item();
//newItem.repository = "SUDOC"; // do not save repository
//make sure we don't get stuck because of a COinS error
try {
Zotero.Utilities.parseContextObject(coins, newItem);
} catch(e) {
Z.debug("error parsing COinS");
}
/** we need to clean up the results a bit **/
//pages should not contain any extra characters like p. or brackets (what about supplementary pages?)
if(newItem.pages) newItem.pages = newItem.pages.replace(/[^\d-]+/g, '');
} else var newItem = new Zotero.Item();
newItem.itemType = detectWeb(doc, url);
newItem.libraryCatalog = "Library Catalog - " + doc.location.host;
// We need to correct some informations where COinS is wrong
var rowXpath = '//tr[td[@class="rec_lable"]]';
if (!ZU.xpathText(doc, rowXpath)){
rowXpath = '//tr[td[@class="preslabel"]]';
}
var tableRows = doc.evaluate(rowXpath, doc, null, XPathResult.ANY_TYPE, null);
var tableRow, role;
var authorpresent = false;
while (tableRow = tableRows.iterateNext()) {
var field = doc.evaluate('./td[@class="rec_lable"]|./td[@class="preslabel"]', tableRow, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
var value = doc.evaluate('./td[@class="rec_title"]|./td[@class="presvalue"]', tableRow, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
field = ZU.trimInternal(ZU.superCleanString(field.trim()))
.toLowerCase().replace(/\(s\)/g, '');
// With COins, we only get one author - so we start afresh. We do so in two places: Here if there is an author fied
//further down for other types of author fields. This is so we don't overwrite the author array when we have both an author and
//another persons field (cf. the Scheffer/Schachtschabel/Blume/Thiele test)
if (field == "author" || field == "auteur" || field == "verfasser"){
authorpresent = true;
newItem.creators = new Array();
}
//Z.debug(field + ": " + value)
//french, english, german, and dutch interface
switch (field) {
case 'auteur':
case 'author':
case 'medewerker':
case 'beteiligt':
case 'verfasser':
case 'other persons':
case 'sonst. personen':
case 'collaborator':
case 'beiträger': //turn into contributor
case 'contributor':
if (field == 'medewerker' || field == 'beteiligt'||field =='collaborator') role = "editor";
if (field == 'beiträger' || field == 'contributor') role = "contributor";
//we may have set this in the title field below
else if (!role) role = "author";
if (!authorpresent) newItem.creators = new Array();
if (authorpresent && (field=="sonst. personen" || field=="other persons")) role = "editor";
//sudoc has authors on separate lines and with different format - use this
if (url.search(/sudoc\.(abes\.)?fr/) != -1) {
var authors = ZU.xpath(tableRow, './td[2]/div');
for (var i in authors) {
var authorText = authors[i].textContent;
var authorFields = authorText.match(/^\s*(.+?)\s*(?:\((.+?)\)\s*)?\.\s*([^\.]+)\s*$/);
var authorFunction = '';
if (authorFields) {
authorFunction = authorFields[3];
authorText = authorFields[1];
var extra = authorFields[2];
}
if (authorFunction) {
authorFunction = Zotero.Utilities.superCleanString(authorFunction);
}
var zoteroFunction = '';
// TODO : Add other author types
if (authorFunction == 'Traduction') {
zoteroFunction = 'translator';
} else if ((authorFunction.substr(0, 7) == 'Éditeur') || authorFunction=="Directeur de la publication") {
//once Zotero suppports it, distinguish between editorial director and editor here;
zoteroFunction = 'editor';
} else if ((newItem.itemType == "thesis") && (authorFunction != 'Auteur')) {
zoteroFunction = "contributor";
} else {
zoteroFunction = 'author';
}
if (authorFunction == "Université de soutenance" || authorFunction == "Organisme de soutenance") {
// If the author function is "université de soutenance" it means that this author has to be in "university" field
newItem.university = authorText;
newItem.city = extra; //store for later
} else {
var author = authorText.replace(/[\*\(].+[\)\*]/, "");
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, zoteroFunction, true));
}
}
} else {
var authors = value.split(/\s*;\s*/);
for (var i in authors) {
if (role == "author") if (authors[i].search(/[\[\()]Hrsg\.?[\]\)]/)!=-1) role = "editor";
var author = authors[i].replace(/[\*\(\[].+[\)\*\]]/, "");
var comma = author.indexOf(",") != -1;
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, role, comma));
}
}
break;
case 'edition':
case 'ausgabe':
var edition;
if (edition = value.match(/(\d+)[.\s]+(Aufl|ed|éd)/)){
newItem.edition = edition[1];
}
else newItem.edition = value;
case 'dans':
case 'in':
//Looks like we can do better with titles than COinS
//journal/book titles are always first
//Several different formats for ending a title
// end with "/" http://gso.gbv.de/DB=2.1/PPNSET?PPN=732386977
// http://gso.gbv.de/DB=2.1/PPNSET?PPN=732443563
// end with ". -" followed by publisher information http://gso.gbv.de/DB=2.1/PPNSET?PPN=729937798
// end with ", ISSN" (maybe also ISBN?) http://www.sudoc.abes.fr/DB=2.1/SET=6/TTL=1/SHW?FRST=10
newItem.publicationTitle = ZU.superCleanString(
value.substring(0,value.search(/(?:\/|,\s*IS[SB]N\b|\.\s*-)/i)));
//ISSN/ISBN are easyto find
//http://gso.gbv.de/DB=2.1/PPNSET?PPN=732386977
//http://gso.gbv.de/DB=2.1/PPNSET?PPN=732443563
var issnRE = /\b(is[sb]n)\s+([-\d\sx]+)/i; //this also matches ISBN
var m = value.match(issnRE);
if(m) {
if(m[1].toUpperCase() == 'ISSN' && !newItem.ISSN) {
newItem.ISSN = m[2].replace(/\s+/g,'');
} else if(m[1].toUpperCase() == 'ISBN' && !newItem.ISBN) {
newItem.ISBN = m[2].replace(/\s+/g,'');
}
}
//publisher information can be preceeded by ISSN/ISBN
// typically / ed. by ****. - city, country : publisher
//http://gso.gbv.de/DB=2.1/PPNSET?PPN=732386977
var n = value;
if(m) {
n = value.split(m[0])[0];
//first editors
var ed = n.split('/'); //editors only appear after /
if(ed.length > 1) {
n = n.substr(ed[0].length+1); //trim off title
ed = ed[1].split('-',1)[0];
n = n.substr(ed.length+1); //trim off editors
if(ed.indexOf('ed. by') != -1) { //not http://gso.gbv.de/DB=2.1/PPNSET?PPN=732443563
ed = ed.replace(/^\s*ed\.\s*by\s*|[.\s]+$/g,'')
.split(/\s*(?:,|and)\s*/); //http://gso.gbv.de/DB=2.1/PPNSET?PPN=731519299
for(var i=0, m=ed.length; i<m; i++) {
newItem.creators.push(ZU.cleanAuthor(ed[i], 'editor', false));
}
}
}
var loc = n.split(':');
if(loc.length == 2) {
if(!newItem.publisher) newItem.publisher = loc[1].replace(/^\s+|[\s,]+$/,'');
if(!newItem.place) newItem.place = loc[0].replace(/\s*\[.+?\]\s*/, '').trim();
}
//we can now drop everything up through the last ISSN/ISBN
n = value.split(issnRE).pop();
}
//For the rest, we have trouble with some articles, like
//http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=013979922
//we'll only take the last set of year, volume, issue
//There are also some other problems, like
//"How to cook a russian goose / by Robert Cantwell" at http://opc4.kb.nl
//page ranges are last
//but they can be indicated by p. or page (or s?)
//http://www.sudoc.abes.fr/DB=2.1/SET=6/TTL=1/SHW?FRST=10
//http://opc4.kb.nl/DB=1/SET=2/TTL=1/SHW?FRST=7
//we'll just assume there are always pages at the end and ignore the indicator
n = n.split(',');
var pages = n.pop().match(/\d+(?:\s*-\s*\d+)/);
if(pages && !newItem.pages) {
newItem.pages = pages[0];
}
n = n.join(','); //there might be empty values that we're joining here
//could filter them out, but IE <9 does not support Array.filter, so we won't bother
//we're left possibly with some sort of formatted volume year issue string
//it's very unlikely that we will have 4 digit volumes starting with 19 or 20, so we'll just grab the year first
var dateRE = /\b(?:19|20)\d{2}\b/g;
var date, lastDate;
while(date = dateRE.exec(n)) {
lastDate = date[0];
n = n.replace(lastDate,''); //get rid of year
}
if(lastDate) {
if(!newItem.date) newItem.date = lastDate;
} else { //if there's no year, panic and stop trying
break;
}
//volume comes before issue
//but there can sometimes be other numeric stuff that we have
//not filtered out yet, so we just take the last two numbers
//e.g. http://gso.gbv.de/DB=2.1/PPNSET?PPN=732443563
var issvolRE = /[\d\/]+/g; //in French, issues can be 1/4 (e.g. http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=013979922)
var num, vol, issue;
while(num = issvolRE.exec(n)) {
if(issue != undefined) {
vol = issue;
issue = num[0];
} else if(vol != undefined) {
issue = num[0];
} else {
vol = num[0];
}
}
if(vol != undefined && !newItem.volume) {
newItem.volume = vol;
}
if(issue != undefined && !newItem.issue) {
newItem.issue = issue;
}
break;
case 'serie':
case 'collection':
case 'series':
case 'schriftenreihe':
case 'reeks':
// The series isn't in COinS
var series = value;
var m;
var volRE = /;[^;]*?(\d+)\s*$/;
if(m = series.match(volRE)) {
if(ZU.fieldIsValidForType('seriesNumber', newItem.itemType)) { //e.g. http://gso.gbv.de/DB=2.1/PPNSET?PPN=729937798
if(!newItem.seriesNumber) newItem.seriesNumber = m[1];
} else { //e.g. http://www.sudoc.fr/05625248X
if(!newItem.volume) newItem.volume = m[1];
}
series = series.replace(volRE, '').trim();
}
newItem.seriesTitle = newItem.series = series; //see http://forums.zotero.org/discussion/18322/series-vs-series-title/
break;
case 'titre':
case 'title':
case 'titel':
case 'title of article':
case 'aufsatztitel':
title = value.split(" / ");
if (title[1]) {
//Z.debug("Title1: "+title[1])
//store this to convert authors to editors.
//Run separate if in case we'll do this for more languages
//this assumes title precedes author - need to make sure that's the case
if (title[1].match(/^\s*(ed. by|edited by|hrsg\. von|édité par)/)) role = "editor";
}
if (!newItem.title) {
newItem.title = title[0];
}
newItem.title = newItem.title.replace(/\s+:/, ":").replace(/\s*\[[^\]]+\]/g, "");
break;
case 'periodical':
case 'zeitschrift':
//for whole journals
var journaltitle = value.split(" / ")[0];
break;
case 'year':
case 'jahr':
case 'jaar':
newItem.date = value; //we clean this up below
break;
case 'language':
case 'langue':
case 'sprache':
// Language not defined in COinS
newItem.language = value;
break;
//Hacking STCN Fingerprint to "Extra" field
case 'fingerprint':
case 'vingerafdruk':
newItem.extra = value;
break;
//Hacking "imprint" into "place" and "publisher"
case 'imprint':
case 'impressum':
var firstComma = value.indexOf(',');
var place = value.substring(0,firstComma);
var place = place.replace(/\[\]/,'');
var publisherRange = value.substring(firstComma+2);
var nextComma = publisherRange.indexOf(', ');
var publisher = publisherRange.substring(0,nextComma);
newItem.city = place;
newItem.publisher = publisher;
break;
//Hacking format and collation information into "numPages"
case 'size':
case 'formaat':
var format = value;
break;
case 'collation':
case 'collatie':
newItem.numPages = format + '; ' + value;
break;
//Hacking "Typographical information" into Notes
case 'typographical information':
case 'typografische informatie':
var notes = value.split(',');
for (var i in notes) {
noteContent = notes[i].slice(notes[i].indexOf('(')+1,notes[i].indexOf(')'));
newItem.notes.push({note: noteContent});
}
break;
/*
case 'editeur':
case 'published':
case 'publisher':
case 'ort/jahr':
case 'uitgever':
//ignore publisher for thesis, so that it does not overwrite university
if (newItem.itemType == 'thesis' && newItem.university) break;
var m = value.split(';')[0]; //hopefully publisher is always first (e.g. http://www.sudoc.fr/128661828)
var place = m.split(':', 1)[0];
var pub = m.substring(place.length+1); //publisher and maybe year
if(!newItem.city) {
place = place.replace(/[[\]]/g, '').trim();
if(place.toUpperCase() != 'S.L.') { //place is not unknown
newItem.city = place;
}
}
if(!newItem.publisher) {
if(!pub) break; //not sure what this would be or look like without publisher
pub = pub.replace(/\[.*?\]/g,'') //drop bracketted info, which looks to be publisher role
.split(',');
if(pub[pub.length-1].search(/\D\d{4}\b/) != -1) { //this is most likely year, we can drop it
pub.pop();
}
if(pub.length) newItem.publisher = pub.join(','); //in case publisher contains commas
}
if(!newItem.date) { //date is always (?) last on the line
m = value.match(/\D(\d{4})\b[^,;]*$/); //could be something like c1986
if(m) newItem.date = m[1];
}
break;
*/
case 'pays':
case 'country':
case 'land':
if (!newItem.country) {
newItem.country = value;
}
break;
/*
case 'description':
case 'extent':
case 'umfang':
case 'omvang':
case 'kollation':
case 'collation':
value = ZU.trimInternal(value); // Since we assume spaces
// We're going to extract the number of pages from this field
var m = value.match(/(\d+) vol\./);
// sudoc in particular includes "1 vol" for every book; We don't want that info
if (m && m[1] != 1) {
newItem.numberOfVolumes = m[1];
}
//make sure things like 2 partition don't match, but 2 p at the end of the field do
// f., p., and S. are "pages" in various languages
// For multi-volume works, we expect formats like:
// x-109 p., 510 p. and X, 106 S.; 123 S.
var numPagesRE = /\[?((?:[ivxlcdm\d]+[ ,\-]*)+)\]?\s+[fps]\b/ig,
numPages = [], m;
while(m = numPagesRE.exec(value)) {
numPages.push(m[1].replace(/ /g, '')
.replace(/[\-,]/g,'+')
.toLowerCase() // for Roman numerals
);
}
if(numPages.length) newItem.numPages = numPages.join('; ');
//running time for movies:
m = value.match(/\d+\s*min/);
if (m){
newItem.runningTime = m[0];
}
break;
*/
case 'résumé':
case 'abstract':
case 'inhalt':
case 'samenvatting':
newItem.abstractNote = value;
break;
case 'notes':
case 'note':
case 'anmerkung':
case 'snnotatie':
case 'annotatie':
newItem.notes.push({
note: doc.evaluate('./td[@class="rec_title"]|./td[@class="presvalue"]', tableRow, null, XPathResult.ANY_TYPE, null).iterateNext().innerHTML
});
break;
case 'sujets':
case 'subjects':
case 'subject heading':
case 'trefwoord':
case 'schlagwörter':
case 'gattung/fach':
case 'category/subject':
var subjects = doc.evaluate('./td[2]/div', tableRow, null, XPathResult.ANY_TYPE, null);
//subjects on separate div lines
if (ZU.xpath(tableRow, './td[2]/div').length > 1) {
var subject_out = "";
while (subject = subjects.iterateNext()) {
var subject_content = subject.textContent;
subject_content = subject_content.replace(/^\s*/, "");
subject_content = subject_content.replace(/\s*$/, "");
subject_content = subject_content.split(/\s*;\s*/)
for (var i in subject_content) {
if (subject_content != "") {
newItem.tags.push(Zotero.Utilities.trimInternal(subject_content[i]));
}
}
}
} else {
//subjects separated by newline or ; in same div.
var subjects = value.trim().split(/\s*[;\n]\s*/)
for (var i in subjects) {
subjects[i] = subjects[i].trim().replace(/\*/g, "").replace(/^\s*\/|\/\s*$/, "");
if (subjects[i].length!=0) newItem.tags.push(Zotero.Utilities.trimInternal(subjects[i]))
}
}
break;
case 'thèse':
case 'dissertation':
newItem.type = value.split(/ ?:/)[0];
break;
case "identifiant pérenne de la notice":
case 'persistent identifier of the record':
case 'persistent identifier des datensatzes':
var permalink = value; //we handle this at the end
break;
case 'doi':
newItem.DOI = value.trim();
case 'isbn':
var isbns = value.trim().split(/[\n,]/);
var isbn = [], s;
for (var i in isbns) {
var m = isbns[i].match(/[-x\d]{10,}/i); //this is necessary until 3.0.12
if(!m) continue;
if(m[0].replace(/-/g,'').search(/^(?:\d{9}|\d{12})[\dx]$/i) != -1) {
isbn.push(m[0]);
}
}
//we should eventually check for duplicates, but right now this seems fine;
newItem.ISBN = isbn.join(", ");
break;
case 'signatur':
newItem.callNumber = value;
break;
case 'worldcat':
//SUDOC only
var worldcatLink = doc.evaluate('./td[2]//a', tableRow, null, XPathResult.ANY_TYPE, null).iterateNext();
if (worldcatLink) {
newItem.attachments.push({
url: worldcatLink.href,
title: 'Worldcat Link',
mimeType: 'text/html',
snapshot: false
});
}
break;
}
}
//merge city & country where they're separate
var location = [];
if (newItem.city) location.push(newItem.city.trim());
newItem.city = undefined;
if (newItem.country) location.push(newItem.country.trim());
newItem.country = undefined;
//join and remove the "u.a." common in German libraries
if(location.length) newItem.place = location.join(', ').replace(/\[?u\.a\.\]?\s*$/, "");
//remove u.a. and [u.a.] from publisher
if (newItem.publisher){
newItem.publisher = newItem.publisher.replace(/\[?u\.a\.\]?\s*$/, "");
}
//clean up date, which may come from various places; We're conservative here and are just cleaning up c1996 and [1995] and combinations thereof
if (newItem.date){
newItem.date = newItem.date.replace(/[\[c]+\s*(\d{4})\]?/, "$1");
}
//if we didn't get a permalink, look for it in the entire page
if(!permalink) {
var permalink = ZU.xpathText(doc, '//a[./img[contains(@src,"/permalink") or contains(@src,"/zitierlink")]][1]/@href');
}
//switch institutional authors to single field;
for (var i=0; i<newItem.creators.length; i++){
if (!newItem.creators[i].firstName){
newItem.creators[i].fieldMode = true;
}
}
if(permalink) {
newItem.attachments.push({
title: 'Link to Library Catalog Entry',
url: permalink,
mimeType: 'text/html',
snapshot: false
});
//also add snapshot using permalink so that right-click -> View Online works
newItem.attachments.push({
title: 'Library Catalog Entry Snapshot',
url: permalink,
mimeType: 'text/html',
snapshot: true
});
} else {
//add snapshot
newItem.attachments.push({
title: 'Library Catalog Entry Snapshot',
document: doc
});
}
if (!newItem.title) newItem.title = journaltitle;
newItem.complete();
}
function doWeb(doc, url) {
var type = detectWeb(doc, url);
if (type == "multiple") {
var newUrl = doc.evaluate('//base/@href', doc, null, XPathResult.ANY_TYPE, null).iterateNext().nodeValue;
var elmts = getSearchResults(doc);
var elmt = elmts.iterateNext();
var links = new Array();
var availableItems = {};
do {
var link = doc.evaluate(".//a/@href", elmt, null, XPathResult.ANY_TYPE, null).iterateNext().nodeValue;
var searchTitle = doc.evaluate(".//a", elmt, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
availableItems[newUrl + link] = searchTitle;
} while (elmt = elmts.iterateNext());
Zotero.selectItems(availableItems, function (items) {
if (!items) {
return true;
}
var uris = new Array();
for (var i in items) {
uris.push(i);
}
ZU.processDocuments(uris, scrape);
});
} else {
scrape(doc, url);
}
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://www.sudoc.abes.fr/DB=2.1/CMD?ACT=SRCHA&IKT=1016&SRT=RLV&TRM=labor",
"items": "multiple"
},
{
"type": "web",
"url": "http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=147745608",
"items": [
{
"itemType": "book",
"title": "Souffrance au travail dans les grandes entreprises",
"creators": [
{
"firstName": "Jacques",
"lastName": "Delga",
"creatorType": "editor"
},
{
"firstName": "Fabrice",
"lastName": "Bien",
"creatorType": "author"
}
],
"date": "2010",
"ISBN": "978-2-7472-1729-3",
"language": "français",
"libraryCatalog": "Library Catalog - www.sudoc.abes.fr",
"numPages": "290",
"place": "Paris, France",
"publisher": "Eska",
"attachments": [
{
"title": "Worldcat Link",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Link to Library Catalog Entry",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Library Catalog Entry Snapshot",
"mimeType": "text/html",
"snapshot": true
}
],
"tags": [
"Conditions de travail -- France",
"Harcèlement -- France",
"Psychologie du travail",
"Stress lié au travail -- France",
"Violence en milieu de travail"
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=156726319",
"items": [
{
"itemType": "book",
"title": "Zotero: a guide for librarians, researchers and educators",
"creators": [
{
"firstName": "Jason",
"lastName": "Puckett",
"creatorType": "author"
}
],
"date": "2011",
"ISBN": "978-0-83898589-2",
"language": "anglais",
"libraryCatalog": "Library Catalog - www.sudoc.abes.fr",
"numPages": "159",
"place": "Chicago, Etats-Unis",
"publisher": "Association of College and Research Libraries",
"shortTitle": "Zotero",
"attachments": [
{
"title": "Worldcat Link",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Link to Library Catalog Entry",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Library Catalog Entry Snapshot",
"mimeType": "text/html",
"snapshot": true
}
],
"tags": [
"Bibliographie -- Méthodologie -- Informatique"
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=093838956",
"items": [
{
"itemType": "thesis",
"title": "Facteurs pronostiques des lymphomes diffus lymphocytiques",
"creators": [
{
"firstName": "Brigitte",
"lastName": "Lambert",
"creatorType": "author"
},
{
"firstName": "Pierre",
"lastName": "Morel",
"creatorType": "contributor"
}
],
"date": "2004",
"language": "français",
"libraryCatalog": "Library Catalog - www.sudoc.abes.fr",
"numPages": "87",
"numberOfVolumes": "1",
"place": "Lille, France",
"type": "Thèse d'exercice",
"university": "Université du droit et de la santé",
"attachments": [
{
"title": "Worldcat Link",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Link to Library Catalog Entry",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Library Catalog Entry Snapshot",
"mimeType": "text/html",
"snapshot": true
}
],
"tags": [
"Leucémie chronique lymphocytaire à cellules B -- Dissertations universitaires",
"Leucémie lymphoïde chronique -- Thèses et écrits académiques",
"Lymphocytes B -- Dissertations universitaires",
"Lymphocytes B -- Thèses et écrits académiques",
"Lymphome malin non hodgkinien -- Dissertations universitaires"
],
"notes": [
{
"note": "<div><span>Publication autorisée par le jury</span></div>"
}
],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=127261664",
"items": [
{
"itemType": "journalArticle",
"title": "Mobile technology in the village: ICTs, culture, and social logistics in India",
"creators": [
{
"firstName": "Sirpa",
"lastName": "Tenhunen",
"creatorType": "author"
}
],
"date": "2008",
"ISSN": "1359-0987",
"issue": "3",
"language": "anglais",
"libraryCatalog": "Library Catalog - www.sudoc.abes.fr",
"pages": "515-534",
"place": "London, Royaume-Uni",
"publicationTitle": "Journal of the Royal Anthropological Institute",
"publisher": "Royal Anthropological Institute",
"shortTitle": "Mobile technology in the village",
"volume": "14",
"attachments": [
{
"title": "Link to Library Catalog Entry",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Library Catalog Entry Snapshot",
"mimeType": "text/html",
"snapshot": true
}
],
"tags": [
"Communes rurales -- Et la technique -- Aspect social -- Inde",
"Inde -- Conditions sociales -- 20e siècle",
"Téléphonie mobile -- Aspect social -- Inde"
],
"notes": [
{
"note": "<div><span>Contient un résumé en anglais et en français. - in Journal of the Royal Anthropological Institute, vol. 14, no. 3 (Septembre 2008)</span></div>"
}
],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=128661828",
"items": [
{
"itemType": "film",
"title": "Exploring the living cell",
"creators": [
{
"firstName": "Véronique",
"lastName": "Kleiner",
"creatorType": "author"
},
{
"firstName": "Christian",
"lastName": "Sardet",
"creatorType": "author"
}
],
"date": "2006",
"ISBN": "0-8153-4223-3",
"abstractNote": "Ensemble de 20 films permettant de découvrir les protagonistes de la découverte de la théorie cellulaire, l'évolution, la diversité, la structure et le fonctionnement des cellules. Ce DVD aborde aussi en images les recherches en cours dans des laboratoires internationaux et les débats que ces découvertes sur la cellule provoquent. Les films sont regroupés en 5 chapitres complétés de fiches informatives et de liens Internet.",
"language": "anglais",
"libraryCatalog": "Library Catalog - www.sudoc.abes.fr",
"place": "Meudon, France",
"publisher": "CNRS Images",
"runningTime": "180 min",
"attachments": [
{
"title": "Worldcat Link",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Link to Library Catalog Entry",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Library Catalog Entry Snapshot",
"mimeType": "text/html",
"snapshot": true
}
],
"tags": [
"Biogenèse",
"Biologie cellulaire",
"Cell membranes",
"Cells",
"Cells -- Evolution",
"Cells -- Moral and ethical aspects",
"Cellules",
"Cellules -- Aspect moral",
"Cellules -- Évolution",
"Cytologie -- Recherche",
"Cytology -- Research",
"Membrane cellulaire",
"QH582.4",
"Ultrastructure (biologie)"
],
"notes": [
{
"note": "<div><span>Les différents films qui composent ce DVD sont réalisés avec des prises de vue réelles, ou des images microcinématographiques ou des images de synthèse, ou des images fixes tirées de livres. La bande son est essentiellement constituée de commentaires en voix off et d'interviews (les commentaires sont en anglais et les interviews sont en langue originales : anglais, français ou allemand, sous-titrée en anglais). - Discovering the cell : participation de Paul Nurse (Rockefeller university, New York), Claude Debru (ENS : Ecole normale supérieure, Paris) et Werner Franke (DKFZ : Deutsches Krebsforschungszentrum, Heidelberg) ; Membrane : participation de Kai Simons, Soizig Le Lay et Lucas Pelkmans (MPI-CBG : Max Planck institute of molecular cell biology and genetics, Dresden) ; Signals and calcium : participation de Christian Sardet et Alex Mc Dougall (CNRS / UPMC : Centre national de la recherche scientifique / Université Pierre et Marie Curie, Villefrance-sur-Mer) ; Membrane traffic : participation de Thierry Galli et Phillips Alberts (Inserm = Institut national de la santé et de la recherche médicale, Paris) ; Mitochondria : participation de Michael Duchen, Rémi Dumollard et Sean Davidson (UCL : University college of London) ; Microfilaments : participation de Cécile Gauthier Rouvière et Alexandre Philips (CNRS-CRBM : CNRS-Centre de recherche de biochimie macromoléculaire, Montpellier) ; Microtubules : participation de Johanna Höög, Philip Bastiaens et Jonne Helenius (EMBL : European molecular biology laboratory, Heidelberg) ; Centrosome : participation de Michel Bornens et Manuel Théry (CNRS-Institut Curie, Paris) ; Proteins : participation de Dino Moras et Natacha Rochel-Guiberteau (IGBMC : Institut de génétique et biologie moléculaire et cellulaire, Strasbourg) ; Nocleolus and nucleus : participation de Daniele Hernandez-Verdun, Pascal Rousset, Tanguy Lechertier (CNRS-UPMC / IJM : Institut Jacques Monod, Paris) ; The cell cycle : participation de Paul Nurse (Rockefeller university, New York) ; Mitosis and chromosomes : participation de Jan Ellenberg, Felipe Mora-Bermudez et Daniel Gerlich (EMBL, Heidelberg) ; Mitosis and spindle : participation de Eric Karsenti, Maiwen Caudron et François Nedelec (EMBL, Heidelberg) ; Cleavage : participation de Pierre Gönczy, Marie Delattre et Tu Nguyen Ngoc (Isrec : Institut suisse de recherche expérimentale sur le cancer, Lausanne) ; Cellules souches : participation de Göran Hermerén (EGE : European group on ethics in science and new technologies, Brussels) ; Cellules libres : participation de Jean-Jacques Kupiec (ENS, Paris) ; Cellules et évolution : participation de Paule Nurse (Rockefeller university, New York)</span></div><div><span> </span></div>"
}
],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=098846663",
"items": [
{
"itemType": "map",
"title": "Wind and wave atlas of the Mediterranean sea",
"creators": [],
"date": "2004",
"ISBN": "2-11-095674-7",
"language": "anglais",
"libraryCatalog": "Library Catalog - www.sudoc.abes.fr",
"publisher": "Western European Union, Western European armaments organisation research cell",
"attachments": [
{
"title": "Worldcat Link",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Link to Library Catalog Entry",
"mimeType": "text/html",
"snapshot": false
},
{
"title": "Library Catalog Entry Snapshot",
"mimeType": "text/html",
"snapshot": true
}
],
"tags": [
"Méditerranée (mer) -- Atlas",
"Météorologie maritime -- Méditerranée (mer) -- Atlas",
"Vagues -- Méditerranée (mer) -- Atlas",
"Vent de mer -- Méditerranée (mer) -- Atlas",
"Vents -- Méditerranée (mer) -- Atlas"
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=05625248X",
"items": [
{
"itemType": "audioRecording",
"title": "English music for mass and offices (II) and music for other ceremonies",
"creators": [
{
"firstName": "Ernest H.",
"lastName": "Sanders",
"creatorType": "author"
},
{
"firstName": "Frank Llewellyn",
"lastName": "Harrison",