[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: local extremums

Subject: Re: local extremums
From: bix_xslt@xxxxxxxxxxx
Date: Wed, 19 Mar 2003 01:40:39 -0600
x when test
> >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

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.