I want to know how to loop over the attribute of the looping element in xslt. I have following xml structure:
<catalog>
<cd v="1">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd v="2">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
And my xslt is as follows:
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="../cd/@v"/></td>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
What happens with this xslt is that, it fetches the attribute for cd from the first tag only. So for all the rows the value will be 1. How can i get it to iterate over the other attribute values also if there are more elements? Am i doing something wrong?