I have got an XSLT that looks like this:
Define namesapce in XSLT, i.e.:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:r="http://www.castiron.com/response" exclude-result-prefixes="r">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:param name="month"/>
<xsl:copy>
<xsl:apply-templates select="@* | node()">
<xsl:with-param name="month" select="$month"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="r:month">
<xsl:param name="month"/>
<month xmlns="http://www.castiron.com/response">
<xsl:choose>
<xsl:when test="$month">
<xsl:value-of select="$month"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</month>
</xsl:template>
<xsl:template name="splitMonths">
<xsl:param name="months"/>
<xsl:variable name="firstMonth" select="substring-before($months,',')"/>
<xsl:variable name="month">
<xsl:choose>
<xsl:when test="$firstMonth">
<xsl:value-of select="$firstMonth"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$months"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="otherMonths" select="substring-after($months,',')"/>
<xsl:if test="$month">
<xsl:apply-templates>
<xsl:with-param name="month" select="$month"/>
</xsl:apply-templates>
</xsl:if>
<xsl:if test="$otherMonths">
<xsl:call-template name="splitMonths">
<xsl:with-param name="months" select="$otherMonths"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="r:payload">
<payload xmlns="http://www.castiron.com/response">
<xsl:call-template name="splitMonths">
<xsl:with-param name="months" select="r:sets/r:month"/>
</xsl:call-template>
</payload>
</xsl:template>
</xsl:stylesheet>
That's because the rule match="month"
is a different to match="{http://www.castiron.com/response}month"
. They have the same node name but since they're in different namespaces they're considered different nodes.