Re: [xsl] local extremums

Subject: Re: [xsl] local extremums
From: bix_xslt@xxxxxxxxxxx
Date: Wed, 19 Mar 2003 01:40:39 -0600
> >It sounds like you want to recurse (or iterate) on the list of <Range>
> elements in a particular
> ><Country> until the list is empty!  I must not be understanding you
right,
> because that
> >doesn't give you any result.  Unless in line 3 you want to *output* (not
> discard) the maximum
> >and the two nearest neighbors.
>
> Sorry for my awful english.
>
> I need to output every Range one by one and mark those who is local
> maxumums (not only one, but every) as bold.
> Yes, I suppose I need a recurse function which can do this.

It would be helpful if you would provide your expected output.  I.e. What is
your definition of a local maximum for a given node, and provide an
example...

Here is some XSL that you may find helpful.  It removes the maxium and its
two closest sibling nodes (i.e. before and after) of the original list.
Hopefully, you can modify this to suit your needs.  Note that I believe this
requires xslt version 1.1 or higher.

        <x:variable name="nodes">
            <x:for-each select="//PoketTourList/Country/Range">
                <x:sort data-type="number" order="descending"
select="./@Cnt"/>
                <x:if test="position() = 1">
                    <x:variable name="cnt" select="@Cnt"/>
                    <x:variable name="thisNode"
select="//PoketTourList/Country/Range[@Cnt = $cnt]"/>
                    <x:variable name="lastNode"
select="$thisNode/preceding-sibling::*[1]"/>
                    <x:variable name="nextNode"
select="$thisNode/following-sibling::*[1]"/>
                    <x:copy-of select="$lastNode"/>
                    <x:copy-of select="$thisNode"/>
                    <x:copy-of select="$nextNode"/>
                </x:if>
            </x:for-each>
        </x:variable>

        <x:variable name="excludedNodes">
            <x:for-each select="//PoketTourList/Country/Range">
                <x:variable name="currentNode" select="."/>
                  <x:choose>
                      <x:when test="$currentNode/@Cnt = $nodes//@Cnt"><!--
do nothing --></x:when>
                      <x:otherwise><x:copy-of
select="$currentNode"/></x:otherwise>
                  </x:choose>
            </x:for-each>
        </x:variable>

        <x:copy-of select="$excludedNodes"/>



bix

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


Current Thread