-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #543 from nationalarchives/feature/grc-subdivisions
Add methods to set/get jurisdiction of a document, for GRC subdivisions
- Loading branch information
Showing
7 changed files
with
201 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
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
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
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,37 @@ | ||
xquery version "1.0-ml"; | ||
|
||
declare namespace akn = "http://docs.oasis-open.org/legaldocml/ns/akn/3.0"; | ||
declare namespace uk = "https://caselaw.nationalarchives.gov.uk/akn"; | ||
|
||
declare variable $uri as xs:string external; | ||
declare variable $content as xs:string external; | ||
declare variable $proprietary-node := document($uri)/akn:akomaNtoso/akn:*/akn:meta/akn:proprietary; | ||
declare variable $jurisdiction-node := $proprietary-node/uk:jurisdiction; | ||
|
||
declare function local:delete($uri) | ||
{ | ||
xdmp:node-delete($jurisdiction-node) | ||
}; | ||
|
||
declare function local:edit($uri, $content) | ||
{ | ||
xdmp:node-replace( | ||
$jurisdiction-node, | ||
<uk:jurisdiction>{$content}</uk:jurisdiction> | ||
) | ||
}; | ||
|
||
declare function local:add($uri, $content) | ||
{ | ||
xdmp:node-insert-child( | ||
$proprietary-node, | ||
<uk:jurisdiction>{$content}</uk:jurisdiction> | ||
) | ||
}; | ||
|
||
if (fn:boolean( | ||
cts:search(doc($uri), | ||
cts:element-query(xs:QName('uk:jurisdiction'),cts:and-query(()))))) then | ||
if ($content = "") then local:delete($uri) else local:edit($uri, $content) | ||
else | ||
local:add($uri, $content) |
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
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
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