Subject: Re: [xsl] Finding the position of node in foreign node list From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Fri, 4 Mar 2005 13:15:10 +1100 |
David C. and Joris already showed possible solutions. The time complexity of these ssolutions would most probably be close to: O(count($A) * count($B)) If $A and $B are sufficiently large, more efficient algorithms exist, e.g. with time complexity close to: O(log($A) * count($B) ) See for example the implementation of set:leading() (in EXSLT for MSXML4) at: http://www.xml.com/pub/a/2003/08/06/exslt.html?page=2 Cheers, Dimitre Novatchev. On Thu, 3 Mar 2005 22:18:31 +0200, Jan Rademan <jrademan@xxxxxxxxxxx> wrote: > Hi > > Here is a problem I'm playing around with: > > I have two variables containing two sets of nodes. > > $A contains 5 elements A,B,C,D,E of element type Service > > $B contains a subset of A$ e.g 2 elements B and D > > I am using them to create a table which looks like this > > A B C D E (Table header, which comes from $A) > B D (First table row, which comes from $B) > > $B is reset though a for-each loop, which then loops to fill the table: > > A B C D E > B D > A C D > E > and so on. > > The for each which runs through the table, builds the table by running > though each element in $A and checking to see if it exists in $B. If so, the > value written. > > I need to determine the positional value of the element being written, as it > occurs in the in the variable $B > > If I just use the postion function, I get the position value from the > superset variable $A > > so I get output like this: > > A B C D E > 2 4 > 1 3 4 > 5 > > The ouput I am looking for should rather list the position as it occurs in > the subset variable $B: > > A B C D E > 1 2 > 1 2 3 > 1 > > Any ideas how I can find out what the position of the current node is in a > foreign node set? (As opposed to the position in the current node set) > > Thanks. > > Jan Rademan
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Finding the position of n, Joris Gillis | Thread | [xsl] XSL count function., c p |
[xsl] get an   in theoutput ht, Nestor Urquiza | Date | RE: [xsl] get an   in theoutput, Jarno.Elovirta |
Month |