Skip to content

Instantly share code, notes, and snippets.

@davidamichelson
Last active August 16, 2016 16:33
Show Gist options
  • Save davidamichelson/a216712476d7a07405316510344a2738 to your computer and use it in GitHub Desktop.
Save davidamichelson/a216712476d7a07405316510344a2738 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 $doc in fn:collection('/db/apps/srophe-data/data/persons/tei')//tei:person
let $name := $doc/tei:persName[@xml:lang='en'][contains(@syriaca-tags,"#syriaca-headword")]
let $gedsh := $doc/tei:persName[@xml:lang="en-x-gedsh"]
let $uri := replace($doc/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}<persName type="label">GEDSH:</persName>{$gedsh}</p>
return
local:download-xml($results, "allnamesbis.xml")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment