Fixed a bug I'd introduced (fancy non-XSLT-1 XPath), and a couple of others I'd missed (namespaces). Pages are now working OK, but the HTML5 output is not valid because of tags taht should be self-closing but aren't. Still trying to figure this one out.