Skip to content

Commit

Permalink
Add NCNs for press summaries and logging of empty citations
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-dxw committed Jan 14, 2025
1 parent 8dd0346 commit 1d17f09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion corb2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Download corb2 from https://github.com/marklogic-community/corb2/releases
Download xcc from https://repo1.maven.org/maven2/com/marklogic/marklogic-xcc/11.1.0/ or https://developer.marklogic.com/products/xcc-2/ (I used maven)
(both into this directory)

`corb migrate-ncn` will run the code, `migrate-ncn.log` will show what it writes to the identifiers
`./corb migrate-ncn` will run the code, `migrate-ncn.log` will show what it writes to the identifiers
14 changes: 11 additions & 3 deletions corb2/migrate-ncn.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,35 @@ import module namespace sem = "http://marklogic.com/semantics"

declare variable $URI external;

let $cite := fn:doc($URI)//uk:cite/text()
let $doc_cite := fn:doc($URI)//uk:cite/text()
let $summary_cite := fn:doc($URI)//uk:summaryOfCite/text()
let $cite := if ($doc_cite) then ($doc_cite) else ($summary_cite)

let $slug := fn:replace(
fn:replace($URI, "\.xml$", "")
, "^/", "")
let $log := ("")
let $uuid := "id-"||sem:uuid-string()
let $log := ($log, "Processing", $URI, $cite, $uuid)
let $node :=

let $node := if ($cite) then (
<identifiers><identifier>
<namespace>ukncn</namespace>
<uuid>{$uuid}</uuid>
<value>{$cite}</value>
<url_slug>{$slug}</url_slug>
</identifier></identifiers>
) else (<identifiers/>)

let $log := ($log, if ($cite) then () else "cite empty at " || $URI)

let $log := ($log, xdmp:quote($node))

let $log := ($log, if
(fn:starts-with($URI, "/failures/") or fn:starts-with($URI, "/collisions/"))
then
"ignored as failure/collision"
else
"set property" || xdmp:document-set-property($URI, $node))
"set property" || xdmp:document-set-property($URI, $node) )

return string-join($log, "&#10;")

0 comments on commit 1d17f09

Please sign in to comment.