Skip to content

Instantly share code, notes, and snippets.

@CanOfBees
Created May 6, 2020 03:13
Show Gist options
  • Save CanOfBees/3fb5ff6976ac8788eb0f50f07cc97def to your computer and use it in GitHub Desktop.
Save CanOfBees/3fb5ff6976ac8788eb0f50f07cc97def to your computer and use it in GitHub Desktop.
Ugly xq for pulling titles / collection information for TDH
declare namespace tei = "http://www.tei-c.org/ns/1.0";
"### TDH Contributing Repositories: ###",
"### TDH Titles: ###",
for $TEI in //tei:TEI
let $TEIid := $TEI/@xml:id/data()
let $TEIbibl := $TEI/tei:teiHeader/descendant::tei:bibl
order by $TEIid
return(
try {
out:tab() || $TEIbibl/tei:title/text()/normalize-space(.)
}
catch * {
'error [' || $err:code || ']: ' || $err:description || ' (' || $err:value || ') '
}
),
out:nl(),
"### TDH Collections: ###",
for $TEI in //tei:TEI
let $TEIid := $TEI/@xml:id/data()
let $TEIbibl := $TEI/tei:teiHeader/descendant::tei:bibl
let $TEIcoll := $TEIbibl/tei:note[@type='collection']/text()/normalize-space(.)
order by $TEIid
group by $TEIcoll
return(
out:tab() || $TEIcoll,
for $t in $TEI
return
try {
out:tab() || out:tab() || $t/tei:teiHeader/descendant::tei:bibl/tei:title/normalize-space(.)
}
catch * {
'error [' || $err:code || ']: ' || $err:description || ' (' || $err:value || ') '
}
(: "#### " || $TEIcoll || " ####",
for $t in $TEI
order by $TEIid
return(
$TEIbibl/tei:title/text()/normalize-space(.)
) :)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment