Back from Greece, which means, back to the database project! As I’ve written before, this whole experience is a learning process for me–I’m learning about functions, where they’re called, how they hook up with other bits and bobs to display data in specific ways. This should be fairly straightforward, and I’m trying to make it even more so by hacking rather than writing from the ground up–but my first attempt (well, the first attempt that didn’t break the application and require mad undo-ing) doesn’t work as I expected it to. I was trying to use existing functions to display the entire <body> of my XML files, but the way the Shakespeare app that I’m tweaking is set up, only parts of the whole file can be displayed–scenes, for instance. This is probably both for demo and for reading purposes–long plays need to be broken down into smaller parts for ease of reading. I don’t have the length problem, as each of my XML files are excerpts. So, I defined a function MAIN in TEI2HTML.XQL that I’m calling in VIEW-WORK.HTML, which is what currently displays the header information and the outline (which dynamically links to the acts/scenes).
declare function tei2:main($main as element (tei:body)) {let $mainTitle := $main//tei:headlet $epigraph := $main//tei:epigraphlet $mainText := $main//tei:div[@main]return<div xmlns=”http://www.w3.org/1999/xhtml” class=”main-text”><h3>{$mainTitle/tei:head/text()}</h3><h4>{$epigraph/tei:epigraph/text()}</h4><p>{for $p in $mainText/tei:div[@main]return<p>{$p/tei:p/text()}</p>}</p></div>};
<div xmlns=”http://www.w3.org/1999/xhtml” data-template=”templates:surround” data-template-with=”templates/page.html” data-template-at=”main”><div class=”col-md-12″><div id=”content”><a href=”.” class=”nav-link” data-template=”app:copy-params”><i class=”glyphicon glyphicon-chevron-up”/> Back to Search and Work List</a><div data-template=”app:work”><div data-template=”app:header”/><div data-template=”app:outline” data-template-details=”yes”/> <!– eliminates/SHOWS THE OUTLINE IN PLAYS AND POEMS –><div data-template=”app:main”/> <!– TEST FUNCTION TO DISPLAY THE MAIN BODY not working –><!– <div class=””><div data-template=”templates:include”data-template-path=”johnson.xml”/></div> –></div></div></div></div>
<ul><li class=”imprint“>Printed for R. and J. Dodsley, London. 3v. 12°. 1754. Add Pages.. </li><li class=”imprint“>University of Michigan ECCO-TCP, Public domain electronic facsimile copy. http://name.umdl.umich.edu/004853488.0001.000. 15 August 2014. . </li></ul></div><table class=”poem-list“></table> <!– eliminates/SHOWS THE OUTLINE IN PLAYS AND POEMS –><!– TEST FUNCTION TO DISPLAY THE MAIN BODY not working –><!– <div class=””><div data-template=”templates:include”data-template-path=”johnson.xml”/></div> –></div>
Under advice, I changed the data-template attribute “app:main()” to
“tei2:main,” and got an error (progress!) reading:
templates:NotFound No template function found for call tei2:main [at line 189, column 85, source: c:eXist-dbwebappWEB-INFdataexpathreposhared-0.4.0contenttemplates.xql]
I opened templates.xql, and see where the error was reported; not quite sure what that means, yet, but something happened!
Then, I moved the main() from tei2html.xql to app.xql, and changed the attribute back to app:main(). Back to the drawing board–nothing happens, though the header is displayed. So, I commented out these lines:
declare function app:main($node as node(), $model as map(*)) {
tei2:tei2html($model("main")/tei:body)
};
This causes the same error as above. So, I changed the first few lines of the function in app.xql to the following:
declare function app:main($node as node(), $model as map(*)) {
let $mainTitle := $main//tei:head
let $epigraph := $main//tei:epigraph
let $mainText := $main//tei:div[@main]
This resulted in another–but a different–error:
err:XPDY0002 variable '$main' is not set. [at line 79, column 24, source: /db/apps/NiC/modules/app.xql]
I’m not sure what any of this means, but to help diagnose the issue, I’m going to try to move the working header() function from tei2html.xql to app.xql, with the idea that it will show me something by either working or not working.
I think I need to backtrack and take a break!
LikeLike