Skip to content

Instantly share code, notes, and snippets.

@davidamichelson
Created August 14, 2016 22:47
Show Gist options
  • Save davidamichelson/eb6984ec8716047a971ae8e20f2332dc to your computer and use it in GitHub Desktop.
Save davidamichelson/eb6984ec8716047a971ae8e20f2332dc to your computer and use it in GitHub Desktop.
xquery version "3.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare function local:download-xml($node, $filename) {
response:set-header("Content-Disposition", concat("attachment;
filename=", $filename))
,
response:stream(
$node,
'indent=yes' (: serialization :)
)
};
let $results :=
for $name in fn:collection('/db/apps/srophe-data/data/persons/tei')//tei:person/tei:persName[@xml:lang='en'][@syriaca-tags="#syriaca-headword" or @syriaca-tags="#syriaca-anglicized #syriaca-headword" or @syriaca-tags="#syriaca-headword #syriaca-anglicized"]
let $gedsh := $name/ancestor::tei:person/descendant::tei:persName[@xml:lang="en-x-gedsh"]
let $uri := replace($name/ancestor::tei:TEI/descendant::tei:idno[1],'/tei','')
let $id := xs:integer(replace($uri,'http://syriaca.org/person/',''))
order by $id
return <p><idno>{$uri}</idno>{$name}{$gedsh}</p>
return
local:download-xml($results, "allnames.xml")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment