[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Help XSL Transformation of Data
Rajesh Jain wrote:
I need help to transform the XML data to plot a graph. I don't understand where above 'row' comes from. <row> <string>CPU</string> <number >20</number> <number >40</number> </row> <row> <string>Memory</string> <number>20</number> <number >10</number> </row> <row> <string>Disk</string> <number >10</number> <number>60</number> </row> </chart_data> And I don't see where data is organized by time. So based on that all I can suggest is
<xsl:output indent="yes"/> <xsl:key name="k1" match="Metrics/*" use="local-name()"/> <xsl:template match="Chart-Data"> <chart_data> <xsl:for-each select="Root/Item/Statistics/Item[1]/Metrics/*"> <row> <string><xsl:value-of select="local-name()"/></string> <xsl:for-each select="key('k1', local-name())"> <number><xsl:value-of select="number(@TotalValue)"/></number> </xsl:for-each> </row> </xsl:for-each> </chart_data> </xsl:template> </xsl:stylesheet> which outputs <chart_data> <row> <string>CPU</string> <number>20</number> <number>40</number> </row> <row> <string>Disk</string> <number>10</number> <number>60</number> </row> <row> <string>Memory</string> <number>20</number> <number>10</number> </row> </chart_data> which is what you described above, with the exception of the first 'row' element in your described output, as I can't relate that to input data. -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|