Skip to content

Instantly share code, notes, and snippets.

@davidamichelson
Created September 5, 2014 18:51
Show Gist options
  • Save davidamichelson/d2dd0a0a8feea13041e0 to your computer and use it in GitHub Desktop.
Save davidamichelson/d2dd0a0a8feea13041e0 to your computer and use it in GitHub Desktop.
Update to Persons from GESDH Abstracts
xquery version "3.0";
declare namespace tei="http://www.tei-c.org/ns/1.0";
for $abstracts in doc('/db/apps/persons/data/working-files/gedsh-abstracts-in-correction-20140729.xml')//row[Type='person']
let $id := concat('person-',$abstracts/SRP_ID[1]/text())
let $abstract-text := $abstracts/Abstract
let $note := $abstracts/Not_Useful/text()
let $auth := $abstracts/Author/text()
let $title := $abstracts/Headword/text()
let $alt-name := $abstracts/Alternate_Name>/text()
let $ptr := concat('http://syriaca.org/bibl/',$abstracts/Bibl_ID/text())
return
for $docs in collection('/db/apps/persons/data/tei')/id($id)[1]
let $rec-id := substring-after($id,'person-')
(: let $newAbstract :=
<note xmlns="http://www.tei-c.org/ns/1.0" type="abstract" xml:id="abstract-en-{$rec-id}">
{if(string-length($note) gt 0) then
(<Not_Useful>{$note}</Not_Useful>,
<quote source="#bib{$rec-id}-1">{$abstract-text}</quote>)
else <quote source="#bib{$rec-id}-1">{$abstract-text}</quote>
}
</note> :)
let $bibl := $docs//tei:bibl[tei:ptr[@target = 'http://syriaca.org/bibl/1']]
let $resp :=
<respStmt xmlns="http://www.tei-c.org/ns/1.0">
<resp>Proofreading of GEDSH abstracts and addition of confessions and alternate names from GEDSH by</resp>
<name type="person"
ref="http://syriaca.org/documentation/editors.xml#ngibson">Nathan P. Gibson</name>
</respStmt>
let $persName :=
<persName xmlns="http://www.tei-c.org/ns/1.0" xml:id="name{$rec-id}-{count($docs//tei:persName)}" xml:lang="en" source="#bib{$rec-id}-1">{$alt-name}</persName>
let $change :=
<change xmlns="http://www.tei-c.org/ns/1.0" who="http://syriaca.org/documentation/editors.xml#dmichelson" when="{current-date()}">ADDED: Abstracts, citation, additional names and confessions from GEDSH.</change>
return
(
update insert $change preceding $docs//tei:teiHeader/tei:revisionDesc/tei:change[1]
(: update value $docs//tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:date with current-date(),
update insert $resp following $docs//tei:teiHeader//tei:respStmt[last()],
(: update insert $newAbstract following $docs//tei:person/tei:persName[last()],:)
update insert
for $new-aff in $abstracts/Affiliation
return <state xmlns="http://www.tei-c.org/ns/1.0" type="confession" source="#bib{$rec-id}-1">{$new-aff/text()}</state>
preceding $docs//tei:bibl[1] :)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment