Created
June 30, 2016 02:14
-
-
Save wsalesky/a60b12eaea9846c50b8a168319947b85 to your computer and use it in GitHub Desktop.
Update persNames in attestations with headwords and @ref
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 "3.0"; | |
| import module namespace functx="http://www.functx.com"; | |
| declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
| declare function local:parse-name($name){ | |
| if($name/child::*) then | |
| string-join(for $part in $name/child::* | |
| order by $part/@sort ascending, string-join($part/descendant-or-self::text(),' ') descending | |
| return $part/text(),' ') | |
| else $name/text() | |
| }; | |
| for $r in collection('/db/apps/srophe-data/data/persons/tei')//tei:event[@type="attestation"] | |
| let $id := $r/ancestor::tei:person/tei:idno[@type='URI'][starts-with(.,'http://syriaca.org')] | |
| let $original := $r | |
| let $title := $r/descendant::tei:title | |
| let $author := | |
| <persName ref="{$id}">{local:parse-name($r/ancestor::tei:person/tei:persName[@syriaca-tags='#syriaca-headword'][@xml:lang='en'][1])}</persName> | |
| let $new-content := | |
| <p xml:lang="en" xmlns="http://www.tei-c.org/ns/1.0"> | |
| {($author, ' is commemorated in ', $title,'.')} | |
| </p> | |
| return update replace $r/child::* with $new-content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment