[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Problem in grouping and filering.
Hi, I am having the following XML ( similar one). I need to filter out the minimum unique 3 rates. But I have no way of keeping a count in XSL , so I count by the preceding:: node. This counts with the duplicate value. Is there a way to do this ? The XML I have : rates.xml --------- <hotels> <rate-codes> <rateperday>100</rateperday> <ref> <id>3</id> <longtext1>Daily Leisue Rate</longtext1> <longtext2></longtext2> </ref> </rate-codes> <rate-codes> <rateperday>103</rateperday> <ref> <id>7</id> <longtext1>Discounted Leisure Rate</longtext1> <longtext2></longtext2> </ref> </rate-codes> <rate-codes> <rateperday>107</rateperday> <ref> <id>8</id> <longtext1>Discounted Leisure Rate</longtext1> <longtext2></longtext2> </ref> </rate-codes> <rate-codes> <rateperday>120</rateperday> <ref> <id>96</id> <longtext1>Celebration Package - Lowry Hotel</longtext1> <longtext2></longtext2> </ref> </rate-codes> ........ </hotels> I need to get all the unique rate details sorted according to rateperday and filtered the first 3 rates. rates.xsl ----------- <xsl:template match="hotels"> <xsl:variable name = "uniquelist" select = "rate-codes[not(ref/longtext1=following::rate-codes/ref/longtext1)]"/> <xsl:for-each select="$uniquelist"> <xsl:sort select="rateperday" data-type="number" order="ascending"/> <xsl:variable name="count"><xsl:value-of select="(count(preceding::rate-codes))"/></xsl:variable> <xsl:if test="$count < 3"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> </xsl:template> This is the xsl which I have, here I use the count:: preceding , but it counts the duplicates also. Please send me a quick response as this is quite urgent. The output I want is Daily Leisue Rate Discounted Leisure Rate Celebration Package - Lowry Hotel But the output I get is: Daily Leisue Rate Discounted Leisure Rate Thanks, Bamanie. -- Bamanie Kumarasena Software Engineer ( JAVA) Open World Lanka (Pvt) Ltd, 41 Dutugamunu Street, Pamankada, Dehiwala, LK Tel: +94 11 4403904 Ext. 114 Fax: +94 11 2854815 http://www.openworld.org/ CONFIDENTIALITY NOTICE The information contained in this message is confidential, intended only for the use of the individual or the entity named as recipient. If the reader of this message is not that recipient, you are notified that any dissemination, distribution or copy of this message is strictly prohibited. If you have received this message in error, please immediately notify us by telephone on the number above. Your co-operation is appreciated.
|
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
|