<xsl:apply-templates select="message"/>
should be either
<xsl:apply-templates select="msg:message"/>
or simply:
<xsl:apply-templates/>
It's best in these situations to reduce the size of the input XML and
stylesheets to the smallest possible examples showing the problem.
Not only does it make it more likely someone will spend the time
trying to help (rather than wading through lines and lines of code)
you will often find the solution during the reduction process.