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

Re: Problem in grouping and filering.

Subject: Re: Problem in grouping and filering.
From: "Jay Bryant" <jay@xxxxxxxxxxxx>
Date: Mon, 16 Jan 2006 10:28:37 -0600
filering
You don't need the FO stuff, though. (I grabbed one of my existing files to
modify it for your problem and forgot to trim out that namespace.)

Replace
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">

with
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Sorry about that.

Jay Bryant
Bryant Communication Services



----- Original Message ----- 
From: "Jay Bryant" <jay@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, January 16, 2006 9:45 AM
Subject: Re:  Problem in grouping and filering.


> You have a very common duplicate problem, the solution to which is in the
> FAQ here:
> http://www.dpawson.co.uk/xsl/sect2/N2696.html
>
> In your case, you need something like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
>
>   <xsl:output method="xml" indent="yes"/>
>
>   <xsl:template match="hotels">
>     <unique-longtext1s>
>       <xsl:for-each select="rate-codes/ref[not(longtext1 =
> following::longtext1)]">
>         <xsl:copy-of select="longtext1"/>
>       </xsl:for-each>
>     </unique-longtext1s>
>   </xsl:template>
>
> </xsl:stylesheet>
>
>
> Tested with Saxon.
>
> Jay Bryant
> Bryant Communication Services
>
> ----- Original Message ----- 
> From: "Bamanie Kumarasena" <bkumarasena@xxxxxxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Monday, January 16, 2006 12:43 AM
> Subject:  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 &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

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.