Pp. 101 (no. 99)
This code sample is adapted from Clifford B. Anderson and Joseph C. Wicentowski, XQuery for Humanists (College Station: Texas A&M University Press, 2020), 101. Download this code sample in its raw form. View the source on GitHub.
xquery version "3.1";
declare context item := document {
<list>
<book date="2015">Interdisciplining Digital Humanities</book>
<book date="2013">Hacking the Academy</book>
<book date="2016">New Companion to Digital Humanities</book>
<book date="2013">Macroanalysis</book>
<book date="2013">Emergence of the Digital Humanities</book>
<book date="2014">Digital Critical Editions</book>
<book date="2015">Digital Humanities</book>
</list>
};
declare variable $list := ./list;
let $titles := $list/book/text()
let $phrase := "Digital Humanities"
for $title in $titles
return
if (fn:contains($title, $phrase)) then
"A book about Digital Humanities"
else
"A book about something else"