Last active
December 18, 2015 22:09
-
-
Save caschwartz/5852392 to your computer and use it in GitHub Desktop.
XQuery - Query to find TEI documents lacking biographies and insert correct biographies
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"; | |
| (: 4/17/13 Query to find TEI documents lacking biographies and insert correct biographies :) | |
| declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
| declare namespace localtei = "http://digital.library.ptsem.edu/lectures/tei"; | |
| declare namespace dc = "http://purl.org/dc/elements/1.1/"; | |
| let $teiDocs := fn:collection() | |
| let $noBioAuthors := for $teiDoc in $teiDocs | |
| let $creator := $teiDoc/tei:TEI/tei:teiHeader/localtei:metadata/dc:creator | |
| let $note := $teiDoc/tei:TEI/tei:text/tei:body/tei:note | |
| where fn:not($note[@type = "bio"]) | |
| return $creator | |
| let $withBioAuthors := for $teiDoc in $teiDocs | |
| let $creator := $teiDoc/tei:TEI/tei:teiHeader/localtei:metadata/dc:creator | |
| let $note := $teiDoc/tei:TEI/tei:text/tei:body/tei:note | |
| where $note[@type = "bio"] | |
| return $creator | |
| return for $noBioAuthor in $noBioAuthors | |
| for $withBioAuthor in $withBioAuthors | |
| let $bioNote := $withBioAuthor/following::tei:note[@type = "bio"] | |
| let $byline := $noBioAuthor/following::tei:byline | |
| where $noBioAuthor = $withBioAuthor | |
| and $noBioAuthor/following-sibling::dc:date = $withBioAuthor/following-sibling::dc:date | |
| return xdmp:node-insert-after($byline, $bioNote) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment