Your first template is only matching elements in the somenamespace
namespace. The other namespaces (othernamespace
,thirdnamespace
) are matched by the identity transform (last template) and are output as-is.
To strip all elements that aren't in the somenamespace
namespace, add this template:
<xsl:template match="*[not(namespace-uri()='somenamespace')]" priority="1"/>