Posted 2004-06-19T13:23:00+01:00 in recipe xslt

Doh! XSLT complexity

<xsl:template match="h1">
    Heading: <xsl:value-of select="text()"/>
</xsl:template> 

is different from

<xsl:template match="html:h1">
    Heading: <xsl:value-of select="text()"/>
</xsl:template> 

Even when you have defined xmlns="http://www.w3.org/1999/xhtml" and xmlns:html="http://www.w3.org/1999/xhtml" on the xsl:stylesheet element.

Because the XSLT Recommendation says The default namespace is not used for unprefixed names. Most of the time this is isn't a problem. Only when you're transforming from multiple source documents, you'll find yourself defining different (default) namespaces.