I am beginner in XSLT and using it to transform XML to XML through Java.Source XML:\[code\]<Response> <Data> <Book name="A" value="http://stackoverflow.com/questions/13859798/1"/> <Book name="B" value="http://stackoverflow.com/questions/13859798/2"/> <Book name="C" value="http://stackoverflow.com/questions/13859798/1"/> </Data> <Result> <Prices> <Price type="A" value="http://stackoverflow.com/questions/13859798/100"/> <Price type="B" value="http://stackoverflow.com/questions/13859798/60"/> <Price type="C" value="http://stackoverflow.com/questions/13859798/40"/> </Prices> </Result></Response>\[/code\]XSLT:\[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xslutput method="xml" indent="yes" /> <xsl:template match="/"> <xsl:element name="Books"> <xsl:variable name="BookType" select="//@type" /> <xsl:attribute name="Total"> <xsl:value-of select="sum(//Price[@type=$BookType]/@value)"/> </xsl:attribute> </xsl:element> </xsl:template></xsl:stylesheet>\[/code\]Output XML:\[code\]<Books Total="200"/>\[/code\]Expected Output XML:\[code\]<Books Total="260"/>\[/code\]In source XML i receive no of book and its price but they are not relevant.\[code\]<Price>\[/code\] tag indicates the price of one book. I need to calculate the total price of all the books as below\[code\]Price of one book x no of booksFor A : 100 x 1 = 100For B : 60 x 2 = 120For C : 40 x 1 = 040------------------------Total Price is = 260\[/code\]Please help.