$pteamcodestore=<xsl:value-of select="teamcode" />
That's not how you bind a variable in XSLT. Use
<xsl:variable name="pteamcodestore" select="teamcode"/>
(Or select="$teamcode")
I suspect there are other bugs in your code concerning context, but without a source document or real code, as distinct from fragments, I can't be sure.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference