|
Subject: RE: [xsl] For-each loop or recursion From: "Aron Bock" <aronbock@xxxxxxxxxxx> Date: Sat, 14 May 2005 03:22:37 +0000 |
I have the following data (leaves in parallel branches): mystruct/myarray1[i]/myvar/var2 and mystruct/myarray2[i]/myvar/var3
I need to implement the find the first occurence of : <xsl:if test="position() != last() and number(var2) = number(var2[position()+1]) and number(var3) = number(var3[position()+1])"> <value-of select="position()"> </xsl:if>
<mystruct>
<myarray>
<myvar>22</myvar>
<myvar>2</myvar>
<myvar>3</myvar>
<myvar>5</myvar>
<myvar>77</myvar>
<myvar>78</myvar>
<myvar>1</myvar>
</myarray>
</mystruct><node> <myvar>2</myvar> </node>
A few questions to XSLT gurus: 1) Does it make sense to do in the for-each loop or it will require a recursion ? All I need is to get the position of the 1st occurrence. How would that recursion look like?
2) Will I be able to get a node from the parallel branch in for-each loop ? Something like: <xsl:for-each mystruct/myarray1[i]/myvar> <xsl:if test=" ...and number(../../myarray2[i]/myvar/var3) = number((../../myarray2[i]/myvar/var3)[position()+1]) and..."> <value-of select="position()"> </xsl:if> </xsl:for-each>) I know it looks awful :-(
3) Is there a way to somehow start the for-each loop from position other than 1 ? Like with j>1: <xsl:for-each mystruct/myarray1[i]/myvar[j]> .... </xsl:for-each>
I am using XSLT 1.x
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] For-each loop or recursion, Oleg Konovalov | Thread | Re: [xsl] For-each loop or recursio, David Carlisle |
| [xsl] For-each loop or recursion, Oleg Konovalov | Date | RE: [xsl] Question about the key() , omprakash . v |
| Month |