[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: local extremums
Evgenia, It may be more helpful if you were to provide XSLT with your list below. Part of the difficulty you are having is deciding which nodes you wish to keep and which nodes to throw out. Unfortunately, the english you have provided is not precise enough to explain which nodes you are interested in. > 2. determine the maximum @Cnt of this list In step 2, I believe you intend to capture the following line: > <Range PriceFrom="400" PriceTo="500" Cnt="1135"/> > 3. cast away this maximum and two his nearest neighbours However, the two nearest neighbors in step 3 can be interpreted in several different ways: > <Range PriceFrom="350" PriceTo="400" Cnt="585"/> > <Range PriceFrom="500" PriceTo="600" Cnt="787"/> or > <Range PriceFrom="250" PriceTo="300" Cnt="751"/> > <Range PriceFrom="500" PriceTo="600" Cnt="787"/> or <Range PriceFrom="300" PriceTo="350" Cnt="684"/> <Range PriceFrom="350" PriceTo="400" Cnt="585"/> <Range PriceFrom="500" PriceTo="600" Cnt="787"/> <Range PriceFrom="600" PriceTo="700" Cnt="586"/> to name just a few. > 4. if line isn't empty than goto step 1 > So I need a list with any flag showing Range is local extremum or not. > Or I need a way to go throw whole list and determine if each Range is local > extremum or not on every step. And step 4 does not clearly specify what 'line' means. More than likely you will need to setup a few variables in your xslt file to capture a maximum count and then the two next maximums. You can group your xml range elements using the xsl <sort> element. However, I would suggest that if you want to group them, you iterate over the list and add some zeros in front of your numbers. For example, the first range element has a Cnt="0". I would iterate over your list and make that number Cnt="000". And any number less than 100 I would add a single zero. This will make it easier for the xsl <sort> element as it will group the numbers (0, 2345, 12, 342, 9) in a strange order (0, 12, 2345, 342, 9). If you add zeros (0000, 2345, 0012, 0342, 0009) then you should get the expected order (0000, 0009, 0012, 0342, 2345). And if you need to convert them back to their original values, use the number() function. Something like the following should remove the maximum value and the two following nodes: <xsl:variable name="maxValue"> <xsl:for-each select="//PocketTourList/Country/Range"> <xsl:sort order="descending" select="@Cnt"/> <x:copy-of select="*[position() > 2]"/> </xsl:for-each> </xsl:variable> Hope that helps! bix XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|