You have
<xsl:template
match="/t:categories/t:category[@name=$categoryName]/t:subcategory[@name=$subcategoryName]">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:element name="product">
so that template copies the t:subcategory
element which is in a namespace but then creates a product
element inside in no namespace. That way the serializer of the result tree needs to add <product xmlns="">
to make sure the element is serialized as created. If you want to create the product
element in the same namespace as the subcategory
element then make sure you either have
<xsl:stylesheet xmlns="http://www.products.com" ...>
on the root element of your stylesheet (to put all elements created in that namespace) or use
<xsl:element name="product" namespace="http://www.products.com">...</xsl:element>
or simply a literal
<product xmlns="http://www.products.com">...</product>
Of course as you create other elements as well the same applies to them, if you go by the second suggestion you need e.g. <xsl:element name="provider" namespace="http://www.products.com">
as well. But using literal result elements or even the right default namespace on the root element of the stylesheet makes it easier.