Finally figured out the xmlns issue
I was initially trying to create an xmlns attribute on the root element. This turns out to be the wrong approach. I found confirmation of this on the mulberrytech xslt list and xslt FAQ:
"What you can't do is to use xsl:attribute name="xmlns:xyz". Namespaces are not attributes."
http://www.stylusstudio.com/xsllist/200501/post30340.html
"xmlns is NOT an attribute"
http://www.stylusstudio.com/xsllist/200408/post50470.html
"namespace attributes show up on the namespace axis, not on the attribute axis."
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d6682e2140
Jeni Tennison suggests that
[quote]
To create an html element with no prefix and in the XHTML namespace, you need to declare the XHTML namespace as the default namespace within your stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
[/quote]
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d6682e1669
Following this approach, I added the TEI namespace to the root of the stylesheet. Initially, I figured this wasn't working (looking at the document in Firefox, as it was rendered by Cocoon), and I hacked around for ages trying to figure out why there was no xmlns attribute; eventually I realized that you have to view the source of the page to see it, because in its default rendering of an XML document with no style, Firefox suppresses the xmlns attribute!