Skip to content

Instantly share code, notes, and snippets.

@wsalesky
Forked from davidamichelson/exportallpersnames
Last active August 15, 2016 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsalesky/e95523ebe819f8c24bfc26ffe1796799 to your computer and use it in GitHub Desktop.
Save wsalesky/e95523ebe819f8c24bfc26ffe1796799 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']contains([@syriaca-tags,"#syriaca-headword")]]
let $en := $name/tei:persName[@xml:lang="en"]
let $gedsh := $name/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")
@davidamichelson
Copy link

Hmm that didn't work, but I think this did: https://gist.github.com/davidamichelson/a216712476d7a07405316510344a2738

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment