[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Average result out of scope to then sort elements

Subject: [xsl] Average result out of scope to then sort elements
From: "Fran" <franciscojose@xxxxxxxxxxx>
Date: Wed, 21 Jan 2004 16:20:16 +0100

 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:
 <x id="1">
     <z price="32">
     <z price="45">
     <z price="67">
<x id="2">
     <z price="36">
     <z price="46">
     <z price="37">

      <xsl:for-each select="X">

		<xsl:for-each  select="y">
                       <!-- I calculate here the average of their
                          <xsl:variable name="resultz"
select='format-number(sum(z/@preciouni) div count(z/@preciouni), "#.00")' />

           <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"/>

Any suggestion, please?

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread