Today a basic display, tomorrow the world?

Thanks in very large part to the patience and availability of a couple of awesome open source developers, I have a basic application that displays the texts in the collection with header info! I haven’t started on formatting, searching, exporting, or incorporating the page images, but soon. Also, I learned where to put the .PNG file for your application icon so it’s visible in the exist-db dashboard (here, as ICON.PNG: C:eXist-dbwebappWEB-INFdataexpathrepoNiC-0.1 — or whatever your app is called). For some reason there’s an empty “title” in the work list, though, which I have to figure out. I also want to add a sort by author and type feature. That should be pretty easy to do, right? Right.

ss11
An icon!
ss12
Frong page
ss13
Sample text

I also was able to add a console module, so I can see what’s getting called where–thanks especially to @wolfgangm. Overall, I’ve been working on simplifying the code so it makes more sense to me and so I can learn how to follow it from point to point. My new XQL page to view the work–like the screen shot above of The Memoirs of Emma Courtney–looks like this:

module namespace tei2=”http://exist-db.org/xquery/app/tei2html”;
import module namespace console=”http://exist-db.org/xquery/console”;

declare namespace tei=”http://www.tei-c.org/ns/1.0″;

declare function tei2:tei2html($nodes as node()*) {
for $node in $nodes
return
typeswitch ($node)
case text() return
$node
case element(tei:TEI) return
tei2:tei2html($node/*)
case element(tei:teiHeader) return
tei2:header($node)
case element(tei:front) return
tei2:front($node)
case element(tei:body) return
tei2:body($node)
case element(tei:p) return
<p xmlns=”http://www.w3.org/1999/xhtml”&gt;{$node}</p>
case element(tei:span) return
$node/string()
case element() return
tei2:tei2html($node/node())
default return
$node/string()
};

declare function tei2:header($header as element(tei:teiHeader)) {
let $titleStmt := $header//tei:titleStmt
let $pubStmt := $header//tei:publicationStmt
let $sourceDesc := $header//tei:sourceDesc

return
<div xmlns=”http://www.w3.org/1999/xhtml&#8221; class=”text-header”>
<h1>{$titleStmt/tei:title/text()}</h1>
<h2>By {$titleStmt/tei:author/text()}</h2>

{
for $resp in $titleStmt/tei:respStmt
return
<p>{$resp/tei:resp/text()}: {$resp/tei:name/text()} </p>
}

{ tei2:tei2html($pubStmt/*) }
<p><ul>
{
for $publisher in $sourceDesc/tei:imprint
return
<li class=”imprint”>{$publisher/tei:publisher/text()}, {$publisher/tei:pubPlace/text()}. {$publisher/tei:extent/text()}. {$publisher/tei:date/text()}. {$publisher/tei:biblScope/text()}. {$publisher/tei:note/text()}</li>
}
</ul></p>
</div>
};

declare function tei2:front($front as element (tei:front)) {
let $frontTitle := $front//tei:head
let $epigraph := $front//tei:epigraph
let $quote := $front//tei:quote
let $bibl := $front//tei:bibl

return
<div xmlns=”http://www.w3.org/1999/xhtml&#8221; class=”main-text-frontmatter”>
<h3>{$frontTitle/text()}</h3>
{
console:log($epigraph),
for $cit in $epigraph
return
<blockquote>{$quote/tei:l/text()}<br/>–{$bibl/text()}</blockquote>
}
</div>
};

declare function tei2:body($body as element (tei:body)) {
let $para := $body//tei:p

return
<div xmlns=”http://www.w3.org/1999/xhtml&#8221; class=”main-text”>
{
console:log($para),
for $para in $body/* (: without the slash asterisk nothing returns–why? : )
return
<p>{$para//text()}</p> (: adding an extra slash shows the text of the span anas inside each p; with one slash, content of spans are dropped. why? tag is stripped. : )
}
</div>
};

declare %private function tei2:get-id($node as element()) {
($node/@xml:id, $node/@exist:id)[1]
};

I know what most of this means, too! (The private function, not so much, nor the logic behind the asterisk and the extra slash in the context above. But still.) So, progress. Yay!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: