[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

Subject: Average result out of scope to then sort elements
From: "Fran" <franciscojose@xxxxxxxxxxx>
Date: Wed, 21 Jan 2004 16:20:16 +0100
out of scope
 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.