Commit cfe00a35 authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Generic approach for info retrieval from indices

parent 657177c4
......@@ -57,7 +57,7 @@ declare variable $index-info:psn-map :=
"regular-name" : string-join($entry/tei:persName[not(@type)], ", "),
"birth" : string($entry/tei:birth),
"death" : string($entry/tei:death),
"occupuation" : string($entry/tei:occupation),
"occupation" : string($entry/tei:occupation),
"occs-in-nbs" : ""
}
));
......@@ -74,55 +74,18 @@ declare variable $index-info:wrk-map :=
));
(: generic functions :)
declare function index-info:get-full-ref($ref as xs:string,
$index-type as xs:string) as xs:string {
let $main-entry := local:get-main-entry($ref, $index-type)
return map:get($main-entry, "regular-name")
declare function index-info:get-info-about($index-type as xs:string,
$term as xs:string, $info as xs:string) as xs:string* {
local:get-main-entry($term, $index-type) => map:get($info)
};
declare function index-info:get-occs($ref as xs:string,
$index-type as xs:string) as xs:string* {
let $main-entry := local:get-main-entry($ref, $index-type)
return map:get($main-entry, "occs-in-nbs")
};
(: index specific functions :)
(: events :)
declare function index-info:get-event-place($ref as xs:string) as xs:string {
let $main-entry := local:get-main-entry($ref, "eve")
return map:get($main-entry, "place")
};
(: places :)
declare function index-info:get-place-sub-ref($ref as xs:string) as xs:string* {
let $main-entry := local:get-main-entry($ref, "plc")
return map:get($main-entry, "subref-of")
};
(: persons :)
declare function index-info:get-birth-date($ref as xs:string) as xs:string* {
local:get-main-entry($ref, "psn") => map:get("birth")
};
declare function index-info:get-death-date($ref as xs:string) as xs:string* {
let $main-entry := local:get-main-entry($ref, "psn")
return map:get($main-entry, "death")
};
declare function index-info:get-occupation($ref as xs:string) as xs:string* {
let $main-entry := local:get-main-entry($ref, "psn")
return map:get($main-entry, "occupation")
};
(: auxiliary functions :)
declare function index-info:get-full-maps() {
$index-info:wrk-map
};
declare function local:get-main-entry($ref as xs:string,
$index-type as xs:string) as map()* {
let $key := substring-after($ref, ":")
......
......@@ -882,19 +882,19 @@ $index-type as xs:string) as attribute()* {
for $iii in 1 to $no-of-refs
let $ref := $refs[$iii]
return
(attribute {"full-ref-" || $iii} {index-info:get-full-ref($ref, $index-type)},
attribute {"occs-" || $iii} {index-info:get-occs($ref, $index-type)},
(attribute {"regular-name-" || $iii} {index-info:get-info-about($index-type, $ref, "regular-name")},
attribute {"occs-" || $iii} {index-info:get-info-about($index-type, $ref, "occs-in-nbs")},
switch ($index-type)
case "eve" return
attribute {"place-" || $iii} {index-info:get-event-place($ref)}
attribute {"place-" || $iii} {index-info:get-info-about($index-type, $ref, "place")}
case "org" return
()
case "plc" return
attribute {"subref-of-" || $iii} {index-info:get-place-sub-ref($ref)}
attribute {"subref-of-" || $iii} {index-info:get-info-about($index-type, $ref, "subref-of")}
case "psn" return
(attribute {"birth-" || $iii} {index-info:get-birth-date($ref)},
attribute {"death-" || $iii} {index-info:get-death-date($ref)},
attribute {"occupation-" || $iii} {index-info:get-occupation($ref)})
(attribute {"birth-" || $iii} {index-info:get-info-about($index-type, $ref, "birth")},
attribute {"death-" || $iii} {index-info:get-info-about($index-type, $ref, "death")},
attribute {"occupation-" || $iii} {index-info:get-info-about($index-type, $ref, "occupation")})
case "wrk" return
()
default return
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment