[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] limit count() to nodes with a position() < the postion of the current node
Subject: Re: [xsl] limit count() to nodes with a position() < the postion of the current node From: "M. David Peterson" <conners_dad@xxxxxxx> Date: Tue, 9 Sep 2003 01:44:47 -0600 |
yes, this all makes sense now... Thank you for your help. I will get this together, test it, and respond with the results for future reference. Best Regards, M. ----- Original Message ----- From: "Zink, Juergen" <Juergen.Zink@xxxxxxxxxxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, September 09, 2003 1:36 AM Subject: AW: [xsl] limit count() to nodes with a position() < the postion of the current node > Hi, > > the it is a grouping problem. Have a look at www.jenitennison.com > Define a key with > > <xsl:key name="linkCount" match="visit" use="lid"/> > > >History >> Home(2) :: Section 2 > > All Home are now grouped. > Iterate above all the nodes foreach and check if > it is the first element in a group. Then you can > print (output) the element. > > <xsl:for-each select="//visit"> > > <xsl:if test="generate_id(key('linkCount',lid))=generate-id(.)"> > > Or you can count the number of items in the group. > with count(key('linkCount', lid)) to get the (2) after Home > > >History >> Home(2) :: Section 2 > > The code is not tested. Hope it works. > > Kind regards, > > Juergen > > -----Ursprüngliche Nachricht----- > Von: M. David Peterson [mailto:conners_dad@xxxxxxx] > Gesendet am: Dienstag, 9. September 2003 08:44 > An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Betreff: Re: [xsl] limit count() to nodes with a position() < the > postion of the current node > > Ah, yes, I see the mistake regarding the position() of the 'lid' node. > > What I am trying to do is this... I have a history file that allows the > user to view the last 5, 10, or 25 links they have visited on the site. > The > > count simply tells the user how many times they have visited that link. > To clean things up for them I want to check during each pass through the > for-each loop if the link in there history file has already been rendered > to > > the output. If it has then I want it to skip over that entry and move on > to > > the next. So, for example, if the history file looked like this... > > <history> > <visit> > <loc>foo</loc> > <subloc>bar</subloc> > <lid>AAA001</lid> > </visit> > <visit> > <loc>foofoo</loc> > <subloc>barbar</subloc> > <lid>AAA002</lid> > </visit> > <visit> > <loc>foo</loc> > <subloc>bar</subloc> > <lid>AAA001</lid> > </visit> > </history> > > Instead of the history output listing all the entries like this (I > previously match the 'lid' to a master file to get the common name for the > link and then display the common name. e.g AAA001 = Home and AAA002 = > Section 2)... > > History >> Home :: Section 2 :: Home > > It would list it like this... > > History >> Home(2) :: Section 2 > > Any ideas? > > Best regards, > > M. > > > > > ----- Original Message ----- > From: "Zink, Juergen" <Juergen.Zink@xxxxxxxxxxxxxxxxxxxx> > To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> > Sent: Tuesday, September 09, 2003 12:07 AM > Subject: AW: [xsl] limit count() to nodes with a position() < the > postion > > of the current node > > > > Hi, > > > > the position of <lid> is the number of preceding siblings. > > In your example should be 4, <loc>, <sub>, <date> sibling before. > > > > Maybe you can use a foreach with select="//lid". > > All the lid elements in a node set in document order. > > Then you can use position() within the loop. > > > > But I don't understand your questions fully. > > What do you want to achieve? > > > > Kind regards, > > > > Juergen > > > > -----Ursprüngliche Nachricht----- > > Von: M. David Peterson [mailto:conners_dad@xxxxxxx] > > Gesendet am: Dienstag, 9. September 2003 07:23 > > An: xsl-list > > Betreff: [xsl] limit count() to nodes with a position() < the postion > > of the current node > > > > Hi all, > > > > Ive got an interesting one for you... > > > > Ive got the following key... > > > > <xsl:key name="linkCount" match="lid" use="."/> > > > > that uses the following xml... > > > > <history> > > <visit> > > <loc>life</loc> > > <subloc>main</subloc> > > <date>9/8/2003 10:49:58 PM</date> > > <lid>AAD001</lid> > > </visit> > > </history> > > > > to give me the total count of all nodes that have the value of the > > current > > > context... > > > > <xsl:value-of select="count(key('linkCount', lid))"/> > > > > This works perfectly as it returns the total count of all nodes that > > have > the same value as the current context node... > > > > But I want to take this one step further and return the count of all > > nodes > > > that have a position() that is less than the position of the current > > node. > > > Taking the position() of the context node out of the equation I thought > > it > > > would as simple as this (I used 5 as a test parameter)... > > > > <xsl:key name="linkCount" match="lid[position() < 5]" use="."/> > > > > I expected it to return the count of the nodes that matched the current > > context node as long as there postion was less than 5. But it didn't. > > It > > > returned the total count for the entire xml tree. > > > > So, my questions are... 1)What do I need to change to get the above > > example > > > > to work and 2)How could I then take it one step further and use the > > position() of the current context node as the parameter to test against > > > the position() of the test nodes? > > > > Your help is much appreciated! > > > > Best Regards, > > > > M.David > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > > > **************************************************************************** > * > > Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte > > Informationen. Wenn Sie nicht der richtige Adressat sind oder diese > > eMail irrtuemlich erhalten haben, informieren Sie bitte sofort den > > Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren > > sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. > > > > This e-mail may contain confidential and/or privileged information. > > If you are not the intended recipient (or have received this e-mail > > in error) please notify the sender immediately and destroy this e-mail. > > Any unauthorized copying, disclosure or distribution of the material > > in this e-mail is strictly forbidden. > > > **************************************************************************** > * > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > ***************************************************************************** > Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte > Informationen. Wenn Sie nicht der richtige Adressat sind oder diese > eMail irrtuemlich erhalten haben, informieren Sie bitte sofort den > Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren > sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. > > This e-mail may contain confidential and/or privileged information. > If you are not the intended recipient (or have received this e-mail > in error) please notify the sender immediately and destroy this e-mail. > Any unauthorized copying, disclosure or distribution of the material > in this e-mail is strictly forbidden. > ***************************************************************************** > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
AW: [xsl] limit count() to nodes wi, Zink, Juergen | Thread | RE: [xsl] Automatically copying an , David . Pawson |
Re: [xsl] Re: following-sibling on , Vidar S. Ramdal | Date | [xsl] sum() with decimal-separator , m . friedrich |
Month |
Keywords