xsl-list
[Top] [All Lists]

Re: [xsl] identify lowest value within a range of elements

2006-05-26 04:42:44

I wrote: 

   something like

   <xsl:template match="price">
   <xsl:param name="range" select="../price"/>
   <xsl:param name="rangename" select="'default'"/>
   <xsl:copy>
   <xsl:if test="empty($range[number(.) &lt; number(current())])">
   <xsl:attribute name="lowest" select="$rangename"/>
   </xsl:if>
   <xsl:copy-of select="node()"/>
   </xsl:copy>
   </xsl:template>

   and

   <xsl:apply-templates select="price">
     <xsl:with-param name="rangename" select="'range1'"/>
     <xsl:with-param name="range" select="price[position[&lt; 5]"/>
   </xsl:apply-templates>


That redoes the search for the lowest value each cell which isn't very
sensible, better would be


   something like

   <xsl:template match="price">
   <xsl:param name="lowest" select="0"/>
   <xsl:param name="rangename" select="'default'"/>
   <xsl:copy>
   <xsl:if test="[$lowest= number(current())])">
   <xsl:attribute name="lowest" select="$rangename"/>
   </xsl:if>
   <xsl:copy-of select="node()"/>
   </xsl:copy>
   </xsl:template>

   and


   <xsl:apply-templates select="price">
     <xsl:with-param name="rangename" select="'range1'"/>
     <xsl:with-param name="lowest" select="min(price[position()&lt; 
5]/number(.))"/>
   </xsl:apply-templates>


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--