Last active
August 29, 2015 14:01
-
-
Save mjlassila/a7378e7bd5ad2cdb8dc6 to your computer and use it in GitHub Desktop.
For filtering Fennica items without holdings
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
declare option output:method "text"; | |
declare option output:item-separator "\n"; | |
declare function local:filter-leader($string as xs:string) as xs:boolean? { | |
if(substring($string,7,1) eq 'a'and substring($string,8,1) eq 'm') then | |
boolean(1) | |
else() | |
}; | |
declare function local:filter-holdings-949($fields as node()*) as xs:boolean?{ | |
let $match_collection:= | |
for $field in $fields | |
let $has_j_field:= $field/subfield[@code="j"] | |
return | |
if (contains($field/subfield[@code="j"],'121') | |
and $field/subfield[@code="j"] | |
and contains($field/subfield[@code="e"],'check_holding')) then | |
boolean(1) | |
else () | |
return | |
if (count($match_collection)>=1) then | |
boolean(1) | |
else() | |
}; | |
declare function local:no-holdings-949($fields as node()*) as xs:boolean?{ | |
let $match_collection:= | |
if (count($fields) eq 0) then | |
boolean(1) | |
else () | |
return | |
if (count($match_collection)>=1) then | |
boolean(1) | |
else() | |
}; | |
declare function local:filter-008($string as xs:string) as xs:boolean? { | |
let $year:= | |
if(matches(substring($string,8,4),'\d{4}')) then | |
xs:int(substring($string,8,4)) | |
else(0) | |
let $language:=xs:string(substring($string,16,2)) | |
return | |
if(($year gt 1900 and $year le 1993) and $language eq 'fi') then | |
boolean(1) | |
else() | |
}; | |
for $record in /OAI-PMH/ListRecords/record/metadata/record | |
where (local:filter-008(data($record/controlfield[@tag="008"])) | |
and local:filter-leader(data($record/leader)) | |
and local:filter-holdings-949($record/datafield[@tag="949"])) | |
return concat($record/controlfield[@tag="001"],'
') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment