Subject: RE: [xsl] Variable containing unique values From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 21 May 2008 15:32:36 +0100 |
I don't know where you've been looking, but this code doesn't make sense at all. Sorting a sequence is never going to reduce the number of items in the sequence. (And the path expression used in xsl:sort should almost never begin with "/", because that would typically mean that every item has the same sort key - or in your case, no sort key at all). First decide whether you're using XSLT 1.0 or 2.0. This kind of thing is MUCH easier in 2.0. In XSLT 2.0, use xsl:for-each-group. In XSLT 1.0, use Muenchian grouping, described at http://www.jenitennison.com/xslt/grouping Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Hesselberth, Jan [mailto:Jan.Hesselberth@xxxxxxxxxxxxxxxxxx] > Sent: 21 May 2008 15:00 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Variable containing unique values > > I've read the book and looked at the examples but I can't > manage to create a variable containing unique values for my > xml. All I get is a list of all values. > I need a variable containing unique values for rolloverDate. > I've tried all sorts of rules for testing for current > rolloverDate not being equal to previous rollover dates but I > can't get it to work. > Can you help please. > Regards > Jan Hesselberth > > The code I have is > > <xsl:variable name="unique-dates"> > <xsl:for-each > select > ="REPORT/Rollover/RolloverForecast/summaryAccount/element"> > <xsl:sort > select="/rolloverDate[not(preceding::rolloverDate= current())]"/> > <xsl:copy-of select="."/> > </xsl:for-each> > </xsl:variable> > > The xml snippet looks like > > <summaryAccount id="12345"> > <isAutomatedRollover>N</isAutomatedRollover> > <element id="1"> > <rolloverDate>2008-04-04</rolloverDate> > </element> > <element id="2"> > <rolloverDate>2008-04-04</rolloverDate> > </element> > </summaryAccount> > <summaryAccount id="12346"> > <isAutomatedRollover>Y</isAutomatedRollover> > <element id="1"> > <rolloverDate>2008-04-22</rolloverDate> > </element> > </summaryAccount> > <summaryAccount id="12347"> > <isAutomatedRollover>Y</isAutomatedRollover> > <element id="1"> > <rolloverDate>2008-04-22</rolloverDate> > </element> > <element id="2"> > <rolloverDate>2008-04-17</rolloverDate> > </element> > </summaryAccount> > > > > LEGAL NOTICE The information contained in this e-mail and > any attachments are private and confidential. This message > is solely intended for a particular recipient, if you are not > the intended recipient you are prohibited from storing, > copying, disseminating or using the information in any way. > If you received this e-mail in error please notify the sender > immediately. E-mail transmission cannot be guaranteed to be > secure or error-free as information could be intercepted, > corrupted, lost, destroyed, arrive late or incomplete, or > contain viruses. The sender therefore does not accept > liability for any errors, viruses or omissions in the > contents of this message, which arise as a result of > transmission. This e-mail is not intended to create legally > binding commitments on behalf of Northern Rock plc, nor do > its contents reflect the corporate views or policies of > Northern Rock plc. Northern Rock plc, Registered Office > Northern Rock House Gosforth Newcastle upon Tyne NE3 4PL. > Registered in England, number 3273685. Telephone No: 0191 > 2857191 Northern Rock plc is authorised and regulated by the > Financial Services Authority for deposit-taking; advising on > and arranging mortgages and general insurance; and for > introducing life assurance and investments. > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit > http://www.messagelabs.com/email > ______________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Variable containing unique va, Hesselberth, Jan | Thread | RE: [xsl] Variable containing uniqu, Hesselberth, Jan |
[xsl] Variable containing unique va, Hesselberth, Jan | Date | Re: [xsl] Variable containing uniqu, David Carlisle |
Month |