Rewriting XSLT from scratch for v3 of the site
The XSLT for the last version of the site had grown slowly by accretion, and it was overly complicated; basic page setup was handled in three different places, depending on whether the document was an Image Markup doc, a text doc from the collection, or a site information page; and there was a lot of unnecessary code carried over from other projects.
Since we're now doing a redesign, this is an opportune time to rewrite all this code, so I've been making a start. The first thing to do is to centralize the code which handles the basic page layout (title, menu, any footer, etc.), and the head tag with all its CSS and JavaScript file links. I've centralized all of this in index.xsl, so all XHTML rendering now calls this file.
The main XSL file then imports six others, and lays out the page; then it branches based on the type of document that's being rendered, calling special functions that will handle a text (prose/verse) document, or an IMT document. I'm also making some use of the @mode attribute to provide different templates to handle the same TEI element depending on whether it's part of a site document, or a collection doc.