XML
<swift>
<message>
<block2 type="input">
<messageType>102</messageType>
<receiverAddress>BKTRUS33XBRD</receiverAddress>
<messagePriority>N</messagePriority>
</block2>
<block3>
<tag>
<name>32</name>
<value>praveen</value>
</tag>
<tag>
<name>42</name>
<value>pubby</value>
</tag>
</block3>
<block4>
<tag>
<name>77</name>
<value>pravz</value>
</tag>
<tag>
<name>77</name>
<value>pubbypravz</value>
</tag>
<tag>
<name>99</name>
<value>USA</value>
</tag>
<tag>
<name>99</name>
<value>UK</value>
</tag>
<tag>
<name>76</name>
<value>shanmu</value>
</tag>
</block4>
</message>
</swift>
XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:param name="count" select="000001"></xsl:param >
<xsl:template match="/">
<xsl:for-each select ="swift/message">
<xsl:variable name="newtype">
<xsl:choose>
<xsl:when test="block2[@type = 'input']">
<xsl:value-of select=" concat('O', block2/messageType,block2/messagePriority )"/>,<xsl:text/>
</xsl:when>
<xsl:when test="block2[@type = 'output']">
<xsl:value-of select=" concat('I', block2/messageType,block2/messagePriority )"/>,<xsl:text/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:for-each select ="/swift/message/block3/tag[name='32']">
<xsl:variable name = "first-val" select="value"/>
<xsl:for-each select ="/swift/message/block4/tag[name='77']">
<xsl:value-of select="concat($count,',',$first-val, ',',value)"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
i need to copy the data of which were i have declared name of "newtype" required the data should print in place of this bellow line
<xsl:value-of select="concat($newtype,',',$first-val, ',',value)"/>
but above which was showing wrong because variable name was declared out of the scope so can any modify make me to reach that ouput please
the above i have hot coded this value 000001 but needed increment for every record
Expected Output
O102N,000001,praveen,pravz,USA
O102N,000002, praveen,pubbypravz,UK