I am trying to convert 1 XML into another and want to increment the variable as many times the loop executes.
XML Code-
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
Want output as-
<root>
<singer>
singer no. 1
[B]<!--want this no. to be changed as many times the loop executes-->[/B]<title>Empire Burlesque</title>
</singer>
<singer>
singer no. 2
<!--not able to get this value through variable-->
<title>Hide your heart</title>
</singer>
</root>
XSLT-
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="num">1</xsl:variable>
<xsl:template match="/">
<root>
<xsl:apply-templates/>
</root>
</xsl:template>
<xsl:template match="catalog">
<xsl:for-each select="cd">
<singer>
singer no. <xsl:value-of select="$num">
<xsl:copy-of select="title"/>
</singer>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I have no clue how i could i do this. Please advise.