[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Variable containing unique values
Hi, I tried this and David's solution but when I try to do an <xsl:for each select="$unique-dates"> I get an error Can not convert #RTREEFRAG to a NodeList! From Xalan. I tried using <xsl:for-each select="xalan:nodeset($unique-dates)"> with the namespace but that gives an error with fop 0.94 [ERROR] FOP - Exception <javax.xml.transform.TransformerException: java.lang.NoS uchMethodException: For extension function, could not find method org.apache.xml .dtm.ref.DTMNodeIterator.nodeset([ExpressionContext,] ).>javax.xml.transform.Tra nsformerException: java.lang.NoSuchMethodException: For extension function, coul d not find method org.apache.xml.dtm.ref.DTMNodeIterator.nodeset([ExpressionCont ext,] ). Anyone any idea how to overcome this? Thanks Jan <xsl:variable name="unique-dates"> <xsl:for-each select ="REPORT/Rollover/RolloverForecast/summaryAccount/element[generate-id()= generate-id(key('e',rolloverDate)[1])]"> <xsl:sort select="."/> <xsl:value-of select="." /><xsl:if test="position() != last()">,</xsl:if> </xsl:for-each> </xsl:variable> <fo:table space-after="10pt"> <fo:table-column column-width="8cm" border-after-style="solid" border-after-width="1pt" border-top-style="solid" border-top-width="1pt"/> <fo:table-column column-width="3cm" border-after-style="solid" border-after-width="1pt" border-top-style="solid" border-top-width="1pt"/> <fo:table-column column-width="3cm" border-after-style="solid" border-after-width="1pt" border-top-style="solid" border-top-width="1pt"/> <fo:table-body> <xsl:for-each select="xalan:nodeset($unique-dates)"> -----Original Message----- From: Mukul Gandhi [mailto:gandhi.mukul@xxxxxxxxx] Sent: 21 May 2008 17:01 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: Variable containing unique values Following is a XSLT 1.0 solution to this problem based on Muenchian grouping technique: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" /> <xsl:key name="x" match="rolloverDate" use="." /> <xsl:template match="/"> <xsl:for-each select="//rolloverDate[generate-id() = generate-id(key('x',.)[1])]"> <xsl:value-of select="." /><xsl:if test="position() != last()">,</xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> If you want to store the unique data list in a variable, you can do: <xsl:variable name="uniqueDates"> <xsl:for-each select="//rolloverDate[generate-id() = generate-id(key('x',.)[1])]"> <xsl:value-of select="." /><xsl:if test="position() != last()">,</xsl:if> </xsl:for-each> </xsl:variable> PS: The values in this example are comma separated. On Wed, May 21, 2008 at 7:29 PM, Hesselberth, Jan <Jan.Hesselberth@xxxxxxxxxxxxxxxxxx> wrote: > 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> -- Regards, Mukul Gandhi 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 ______________________________________________________________________
|
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
|