|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Average result out of scope to then sort elements
Hi list, I've a problem and I can't find a good solution. I try to paint
all "x" elements sorting by their average result of all their "z" childrens
but a have the variable out of scope. I know that I can't utilize variables
out of their scope(for each loop) in my XSL but I don't know how do this.
I do this with this XML:
XML
<x id="1">
<y>
<z price="32">
<z price="45">
<z price="67">
<y>
</x>
<x id="2">
<y>
<z price="36">
<z price="46">
<z price="37">
<y>
</x>
<XSL>
......
<xsl:for-each select="X">
<xsl:for-each select="y">
<!-- I calculate here the average of their
children-->
<xsl:variable name="resultz"
select='format-number(sum(z/@preciouni) div count(z/@preciouni), "#.00")' />
</xsl:for-each>
<xsl:sort select="$resultz" data-type="number"
order="descending"/> <!--Sort x elements by their average-->
<xsl:value-of select="@id"/>
<xsl:value-of select="$resultz"/>
</xsl:for-each>
Any suggestion, please?
Regards
Frank
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








