Well, I can't tell why the stylesheet is selecting an attribute that doesn't exist. But given that it does so, it's fairly obvious why it's behaving the way that it does. The backslash characters come from this:
<xsl:value-of select="$path" />\<xsl:value-of select="@name" />
If both $path and @name are empty, then all you are left with is the "\" in between; next time through it adds another "\", and so on.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference