[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] complicated xslt question
Hi! I'm trying to write XSL for a statistics page. (see XML below) Each site has four values to analyse: v1, v2, v3 and v4. The result of the transformation should be a set of tables for each month and one summarizing table. First I need to calculate sum of each value. For example for March it is v1_sum=100+100. Next I need to find maximum value among summarized values of v1. This is v1_max=max(200,330)=330 Here is an example: March | v1 v2 v3 v4 ----------------------- site1 | 100 200 300 400 site2 | 100 200 300 400 ----------------------- sum | 200 400 600 800 April | v1 v2 v3 v4 ----------------------- site1 | 110 210 310 410 site2 | 110 210 310 410 site2 | 110 210 310 410 ----------------------- sum | 330 630 930 1230 SUMMARY ----------------------- v1_max | 330 v2_max | 630 v3_max | 930 v4_max | 1230 I know how to find maximum among v1 values. <xsl:variable name="v1_max"> <xsl:for-each select="month/@v1"> <xsl:sort data-type="number" order="descending"/> <xsl:if test="position()=1"><xsl:value-of select="."/></xsl:if> </xsl:for-each> </xsl:variable> But in the case described I need to find the max in the set of values that has to be built first. Does anyone have any suggestions how to do that? Thanks! XML ***************** <?xml version="1.0" encoding="UTF-8"?> <stats> <month name="March, 2008"> <site id="1" v1="100" v2="200" v3="300" v4="400"/> <site id="2" v1="100" v2="200" v3="300" v4="400"/> </month> <month name="April, 2008"> <site id="1" v1="110" v2="210" v3="310" v4="410"/> <site id="2" v1="110" v2="210" v3="310" v4="410"/> <site id="3" v1="110" v2="210" v3="310" v4="410"/> </month> </stats>
|
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
|