Created
May 22, 2014 15:28
-
-
Save EdWarga/adecf5aa75ef4ca3aa57 to your computer and use it in GitHub Desktop.
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
xquery version "3.0"; | |
declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance"; | |
declare namespace mods="http://www.loc.gov/mods/v3"; | |
let $doc := fn:doc("/db/Divinity/MODS-JournalArticles-2014-05-21.xml") | |
let $modsCollection := $doc/mods:modsCollection/mods:mods | |
let $journal := $modsCollection/mods:relatedItem/mods:titleInfo[fn:not(@type)]/mods:title/text() | |
for $titles in fn:distinct-values($journalTitle) | |
let $count := fn:count($journal [. = $titles]) | |
return fn:string-join(($titles, $count), ', ') | |
(: | |
I found the FLOWR statement here - http://stackoverflow.com/questions/15122641/count-number-of-word-occurrences-in-strings-using-xquery | |
It seems to work. I understand the logic behind it, but the construction doesn't make 100% sense to me. | |
:) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks good! I'd change $journal to $journals to indicate that it contains a sequence of journal titles. Line 11 gets the distinct journal titles and line 12 filters the number of titles in the sequence matching a particular journal name and gets the count. This is exactly the approach we discussed yesterday in my office.