RE: [xsl] Problem in grouping and filering.

Subject: RE: [xsl] Problem in grouping and filering.
From: "Arun Sinha" <arunsinha666@xxxxxxxxxxx>
Date: Mon, 16 Jan 2006 06:54:49 +0000
Hi,

Well ! I am not sure whether it is going to help you or not but
dont you think it should be

<xsl:if test="$count &lt; 4">

instead of

<xsl:if test="$count &lt; 3">

Cheers.

Arun


From: Bamanie Kumarasena <bkumarasena@xxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Problem in grouping and filering.
Date: Mon, 16 Jan 2006 12:43:36 +0600

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 &lt; 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.

Current Thread