-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translator for the UK National Archives case law archive.
Available at https://caselaw.nationalarchives.gov.uk/. This follows the example of the existing [BAILII](https://www.bailii.org/) translator for formatting UK case law as zotero entries, and relies on the LegalDocXML representation of each case made available on the national archives site as a canonical source of metadata. It will import individual judgments, as well as allowing 'multiple' import on search result and collection pages.
- Loading branch information
1 parent
3ad35cf
commit 01ad22c
Showing
1 changed file
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
"translatorID": "5c0588e6-561f-4ab3-bb13-4f72bf049ca8", | ||
"label": "National Archives (UK) Find Case Law", | ||
"creator": "Tim Cowlishaw <[email protected]>", | ||
"target": "https?:\\/\\/caselaw\\.nationalarchives\\.gov\\.uk\\/", | ||
"minVersion": "5.0", | ||
"maxVersion": "", | ||
"priority": 100, | ||
"inRepository": true, | ||
"translatorType": 4, | ||
"browserSupport": "gcsibv", | ||
"lastUpdated": "2023-12-11 14:59:32" | ||
} | ||
|
||
function detectWeb(doc, url) { | ||
Check warning on line 15 in National Archives (UK) Find Case Law.js GitHub Actions / Lint, Check, Test
|
||
if (isJudgment(doc)) { | ||
return "case"; | ||
} | ||
else if (isResultsList(doc)) { | ||
return "multiple"; | ||
} | ||
return false; | ||
} | ||
|
||
function doWeb(doc, url) { | ||
if(isJudgment(doc)) { | ||
return scrape(doc, url); | ||
} else if(isResultsList(doc)) { | ||
Check warning on line 28 in National Archives (UK) Find Case Law.js GitHub Actions / Lint, Check, Test
|
||
items = ZU.getItemArray(doc, doc.querySelector("ul.judgment-listing__list"), /\/[a-zA-Z0-9]+/) | ||
Check failure on line 29 in National Archives (UK) Find Case Law.js GitHub Actions / Lint, Check, Test
|
||
return Z.selectItems(items, function(items) { | ||
Check failure on line 30 in National Archives (UK) Find Case Law.js GitHub Actions / Lint, Check, Test
|
||
if (items) ZU.processDocuments(Object.keys(items), scrape); | ||
}); | ||
} | ||
} | ||
|
||
function isJudgment(doc) { | ||
return doc.querySelector("article.judgment") !== null; | ||
} | ||
|
||
function isResultsList(doc) { | ||
return doc.querySelector("ul.judgment-listing__list") !== null; | ||
} | ||
|
||
function scrape(doc, url) { | ||
const item = new Z.Item("case"); | ||
ZU.doGet(url + "/data.xml", function (text) { | ||
const parser = new DOMParser(); | ||
const xmlDoc = parser.parseFromString(text, "text/xml"); | ||
function xpath(path) { | ||
return ZU.xpathText(xmlDoc, path, { | ||
"akn": "http://docs.oasis-open.org/legaldocml/ns/akn/3.0", | ||
Check failure on line 51 in National Archives (UK) Find Case Law.js GitHub Actions / Lint, Check, Test
|
||
"uk": "https://caselaw.nationalarchives.gov.uk/akn"} | ||
); | ||
} | ||
item.uri = xpath("//akn:FRBRExpression/akn:FRBRuri/@value") | ||
item.title = xpath("//akn:FRBRWork/akn:FRBRname/@value"); | ||
item.dateDecided = xpath('//akn:FRBRWork/akn:FRBRdate[@name="judgment"]/@date'); | ||
item.court = xpath('//uk:court'); | ||
new Array(xpath('//akn:judge/@refersTo')).forEach(function(href) { | ||
if(href !== null) { | ||
const id = href.replace("#", ""); | ||
item.creators.pop({ | ||
lastName: xpath(`//akn:TLCPerson[@eId='${id}']/@showAs`), | ||
creatorType: "author", | ||
fieldMode: true | ||
} ) | ||
} | ||
}); | ||
const ncn = xpath("//uk:cite"); | ||
item.notes.push({ note: `Neutral Citation Number: ${ncn}`}) | ||
item.complete(); | ||
}); | ||
}/** BEGIN TEST CASES **/ | ||
var testCases = [ | ||
{ | ||
"type": "web", | ||
"url": "https://caselaw.nationalarchives.gov.uk/ewhc/qb/2020/3156", | ||
"items": [ | ||
{ | ||
"itemType": "case", | ||
"caseName": "Vardy v Rooney", | ||
"creators": [ | ||
{ | ||
"lastName": "THE HON. MR JUSTICE WARBY", | ||
"creatorType": "author", | ||
"fieldMode": true | ||
} | ||
], | ||
"dateDecided": "2020-11-20", | ||
"court": "EWHC-QBD", | ||
"attachments": [], | ||
"tags": [], | ||
"notes": [ | ||
{ | ||
"note": "Neutral Citation Number: [2020] EWHC 3156 (QB)" | ||
} | ||
], | ||
"seeAlso": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "web", | ||
"url": "https://caselaw.nationalarchives.gov.uk/ewca/civ/2021/567", | ||
"items": [ | ||
{ | ||
"itemType": "case", | ||
"caseName": "Corbyn v Millett", | ||
"creators": [], | ||
"dateDecided": "2021-04-20", | ||
"court": "EWCA-Civil", | ||
"attachments": [], | ||
"tags": [], | ||
"notes": [ | ||
{ | ||
"note": "Neutral Citation Number: [2021] EWCA Civ 567" | ||
} | ||
], | ||
"seeAlso": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "web", | ||
"url": "https://caselaw.nationalarchives.gov.uk/judgments/search?query=Corbyn", | ||
"items": "multiple" | ||
} | ||
] | ||
/** END TEST CASES **/ |