Hi everybody,
this is my first translator for JurPC a german it-law journal, which
publishes IT related articles and court cases. My code might not be
nice but it is working ;).
I tested the code as good as I could and found no real issues.
Comments and feedback is highly appreciated.
Best Regards,
Olli
REPLACE INTO translators VALUES ('b662c6eb-e478-46bd-
bad4-23cdfd0c9d67', '1.0.0b4.r5', '', '2008-06-10 14:29:38', '0',
'100', '4', 'JurPC', 'Oliver Vivell', '
http://www.jurpc.de/',
' function detectWeb(doc, url) {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
if (prefix == ''x'') return namespace; else return null;
} : null;
var doctype = doc.evaluate(''//meta/@doctype'', doc, null,
XPathResult.ANY_TYPE, null).iterateNext().textContent;
if (doctype == "Aufsatz"){
return "Aufsatz";
}else{
return "Rechtsprechung";
}
}',
'function doWeb(doc, url) {
var articles = new Array();
Zotero.debug("Hello");
if (detectWeb(doc, url) == "Aufsatz") {
// Aufsatz gefunden
Zotero.debug("Ok, we have an JurPC Article");
var authors = ''//meta/@Author''
var title = ''//meta/@Title''
var webdoktext = ''//meta/@WebDok''
var authors = parseDoc(authors,doc);
var title = parseDoc(title,doc);
var webabs = webdoktext.substr(webdoktext.lastIndexOf("Abs."),
webdoktext.length);
//Zotero.debug(doctype);
Zotero.debug(webdoktext);
var year = url.substr(28, 4);
//Get Year & WebDok Number from Url
var webdok = url.substr(32, 4);
var suche = webdok.indexOf("0");
if (suche == 0){
webdok = url.substr(33, 3);
suche = webdok.indexOf("0");
if(suche == 0){
webdok = url.substr(34, 2);
suche = webdok.indexOf("0");
}
//Zotero.debug(suche);
if(suche == 0){
webdok = url.substr(35, 1);
suche = webdok.indexOf("0");
}
}
var re = /<[^>]*>/
Zotero.debug(re);
title = title.replace(re,"");
title = title.replace(re,"");
title = title.replace(re,"");
Zotero.debug(title);
var newArticle = new Zotero.Item(''journalArticle'');
newArticle.title = title;
newArticle.journal = "JurPC";
newArticle.journalAbbreviation = "JurPC";
newArticle.year = year;
newArticle.volume = "WebDok " + webdok + "/" + year;
newArticle.pages = webabs ;
newArticle.url = url;
var aus = authors.split("/");
for (var i=0; i< aus.length ; i++) {
Zotero.debug(aus[0]);
newArticle.creators.push(Zotero.Utilities.cleanAuthor(aus[i],
"author"));
}
newArticle.complete();
}else{
// Dokument ist ein Urteil
var gericht = ''//meta/@Gericht''
var ereignis = ''//meta/@Ereignis''
var datum = ''//meta/@Datum''
var aktz = ''//meta/@aktz''
var titel = ''//meta/@Title''
var webdok = ''//meta/@WebDok''
try{
var gericht = parseDoc(gericht,doc);
var ereignis = parseDoc(ereignis,doc);
var datum = parseDoc(datum,doc);
var aktz = parseDoc(aktz,doc);
var webdok = parseDoc(webdok,doc);
var titel = parseDoc(titel,doc);
} catch (e) { var titel = doc.evaluate(''//meta/@Titel'', doc, null,
XPathResult.ANY_TYPE, null).iterateNext().textContent;}
//Zotero.debug(titel);
// Informationen an Zotero übergeben
var newCase = new Zotero.Item(''case'');
newCase.court = gericht;
newCase.caseName = titel;
newCase.title = titel;
newCase.shortTitle = "WebDok " + webdok;
newCase.dateDecided = ereignis + " , " + aktz;
newCase.url = url;
newCase.journalAbbreviation = "JurPC";
//Zotero.debug(newCase.codeNumber);
Zotero.debug(newCase);
newCase.complete();
}
}
function parseDoc(xpath, doc) {
var content = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE,
null).iterateNext().textContent;
return content;
}');