xsl-list
[Top] [All Lists]

Re: local extremums

2003-03-19 02:30:26
Hi again,

I think this has a slight better chance of success :)
The most important thing is to change value-of() with number() as the first gives the string value, the last it's numerical value (better for finding extrema).

If there is something wrong with this code, I would like to hear it myself.

<xsl:template
match="Range[number(@Cnt)&gt;number(./previous-sibling/@Cnt) and
number(@Cnt)&lt;value-of(./next-sibling/@Cnt)]">
 <xsl:call-template name="IsLocalMaximum"/>
</xsl:template>

<xsl:template
match="Range[not(number(@Cnt)&gt;number(./previous-sibling/@Cnt)
and number(@Cnt)&lt;value-of(./next-sibling/@Cnt))]">
 <xsl:choose>
</xsl:when test="position()=1 and number(@Cnt)&gt;number(./next-sibling/@Cnt)]><xsl:call-template name="IsLocalMaximum"/><xsl:when> </xsl:when test="position()=last() and number(@Cnt)&lt;number(./previous-sibling/@Cnt)]><xsl:call-template name="IsLocalMaximum"/><xsl:when> <xsl:otherwise><xsl:call-template name="IsNotLocalMaximum"/></xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template name="IsLocalMaximum">
 <!-- Do your stuff here -->
</xsl:template>

<xsl:template name="IsNotLocalMaximum">
 <!-- Do your other stuff here -->
</xsl:template>

Ragulf

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail


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