Last active
December 21, 2015 14:48
-
-
Save caschwartz/6322052 to your computer and use it in GitHub Desktop.
XQuery - Query to list unique PTS collection names (taken from MARC 730 fields)
This file contains hidden or 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
| xquery version "1.0-ml"; | |
| (: 8/21/13 Query to list unique PTS collection names (taken from MARC 730 fields) :) | |
| declare namespace ia = "http://my.local.namespace"; | |
| declare namespace m = "http://www.loc.gov/MARC21/slim"; | |
| (: Finds unique collection names other than Benson and Torrance :) | |
| let $collNames := fn:distinct-values(for $doc in fn:collection()[1 to 10000] | |
| let $marc := $doc/ia:doc/ia:metadata/ia:marc/m:record | |
| let $collections := $marc/m:datafield[@tag = "730"][@ind2 = " "] | |
| for $collection in $collections | |
| let $collectionString := fn:normalize-space($collection) | |
| where fn:not(fn:matches($collectionString, "Benson|Torrance")) | |
| (: Tests for keywords found in PTS collection names to filter out other values :) | |
| and fn:matches($collectionString, "collection|library", "i") | |
| (: Removes final period from collection names :) | |
| return fn:replace($collectionString, "\.$", "")) | |
| (: Creates alphabetic sequence of collection names before using a positional variable :) | |
| let $sortedNames := for $collName in $collNames | |
| order by $collName | |
| return $collName | |
| (: Return collection names as numbered list :) | |
| for $sortedName at $count in $sortedNames | |
| return <p>{$count}. {$sortedName}</p> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment