Skip to content

Instantly share code, notes, and snippets.

@timathom
Last active November 22, 2023 15:08
Show Gist options
  • Save timathom/7fd44b43de1fa72162cd59cf755c3d91 to your computer and use it in GitHub Desktop.
Save timathom/7fd44b43de1fa72162cd59cf755c3d91 to your computer and use it in GitHub Desktop.
Issue in BaseX 11.0 beta?
let $data := map {
"warner bros": [map {
"match": "true",
"uri": "http://id.loc.gov/authorities/names/n50028315 http://id.loc.gov/authorities/names/n85138180 http://id.loc.gov/authorities/names/no2003017455",
"index-type": "x",
"entry-id": "60021fec-672e-4f09-a160-197c1e2c97e1",
"tags": "710",
"lookup": "warner bros",
"source": <key>warner bros</key>,
"file": "lcnaf-2023"
}],
"land tenure": [map {
"match": "true",
"uri": "http://id.loc.gov/authorities/subjects/sh00006381 http://id.loc.gov/authorities/subjects/sh85074312",
"index-type": "n",
"entry-id": "66c9c5c4-0932-405d-9e2a-eec9eea4dcd3",
"tags": "650",
"lookup": "land tenure",
"source": <key>land tenure</key>,
"file": "lcsh"
}],
"catholic church--doctrinal and controversial works": [map {
"match": "true",
"uri": "http://id.loc.gov/authorities/subjects/sh85021093 http://id.loc.gov/authorities/subjects/sh85021103",
"index-type": "x",
"entry-id": "feb5005f-dc33-4ba9-b767-8adc5965f078",
"tags": "610",
"lookup": "catholic church--doctrinal and controversial works",
"source": <key>catholic church--doctrinal and controversial works</key>,
"file": "lcsh"
}]
}
let $lookups := <lookups>
<d a="http://id.loc.gov/authorities/subjects/sh00006381" d="false" s="true" t="Topic">
<a>Land tenure</a>
<n>land tenure</n>
<v>Tenure of land</v>
<x>tenure of land</x>
</d>
<d a="http://id.loc.gov/authorities/subjects/sh85074312" d="false" s="false" t="Topic">
<a>Land tenure</a>
<n>land tenure</n>
<v>Land ownership</v>
<x>land ownership</x>
<v>Feudal tenure</v>
<x>feudal tenure</x>
<v>Freehold</v>
<x>freehold</x>
<v>Landownership</v>
<x>landownership</x>
<v>Land question</v>
<x>land question</x>
<v>Agrarian tenure</v>
<x>agrarian tenure</x>
<v>Tenure of land</v>
<x>tenure of land</x>
</d>
<d a="http://id.loc.gov/authorities/names/n50028315" t="CorporateName" u="false">
<a>Warner Bros. Pictures (1923-1967)</a>
<n>warner bros pictures 1923-1967</n>
<v>Warner Brothers</v>
<x>warner brothers</x>
<v>Warner Bros.</v>
<x>warner bros</x>
<v>Warner Bros. Productions Corp.</v>
<x>warner bros productions corp</x>
<v>Warner Bros.-First National Picture</v>
<x>warner bros-first national picture</x>
<v>Warner Brothers Pictures (1923-1967)</v>
<x>warner brothers pictures 1923-1967</x>
</d>
<d a="http://id.loc.gov/authorities/names/n85138180" t="CorporateName" u="false">
<a>Warner Bros.-Seven Arts</a>
<n>warner bros-seven arts</n>
<v>Warner Bros.</v>
<x>warner bros</x>
<v>Warner Brothers</v>
<x>warner brothers</x>
<v>Warner Brothers-Seven Arts</v>
<x>warner brothers-seven arts</x>
</d>
<d a="http://id.loc.gov/authorities/names/no2003017455" t="CorporateName" u="false">
<a>Warner Bros. Pictures (1969- )</a>
<n>warner bros pictures 1969-</n>
<v>Warner Communications Inc. Warner Bros. Pictures (1969- )</v>
<x>warner communications inc warner bros pictures 1969-</x>
<v>Warner Brothers</v>
<x>warner brothers</x>
<v>Warner Bros.</v>
<x>warner bros</x>
<v>Warner Brothers Pictures (1969- )</v>
<x>warner brothers pictures 1969-</x>
<v>AOL Time Warner. Warner Bros. Pictures (1969- )</v>
<x>aol time warner warner bros pictures 1969-</x>
</d>
<d a="http://id.loc.gov/authorities/subjects/sh85021093" d="false" s="false" t="ComplexSubject">
<a>Catholic Church--Controversial literature</a>
<n>catholic church--controversial literature</n>
<v>Catholic Church--Doctrinal and controversial works</v>
<x>catholic church--doctrinal and controversial works</x>
</d>
<d a="http://id.loc.gov/authorities/subjects/sh85021103" d="false" s="false" t="ComplexSubject">
<a>Catholic Church--Doctrines</a>
<n>catholic church--doctrines</n>
<v>Catholic Church--Doctrinal and controversial works</v>
<x>catholic church--doctrinal and controversial works</x>
</d>
</lookups>
return
array {
map:for-each($data, fn($k, $v) {
for $m in $v?*[contains(?uri, " ") and ?match = "true"]
for $uri in tokenize($m?uri, "\s")
let $source := $m?source
let $auth := $lookups/d[@a = $uri]
for $a in $auth
let $lookup := $a/@t
let $subdiv :=
if ($a/@s)
then xs:boolean($a/@s)
else false()
return (
if (($source[@tag] or $source[self::key]) and $subdiv = false())
(: The entries for "catholic church--doctrinal and controversial works"
only return if the $subdiv variable is referenced below. They should
always be returned for this condition. Works correctly in BaseX 10.6. :)
then ($m(:, $subdiv :))
else ()
)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment