Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > For-each or recursion in XSLT

Reply
Thread Tools

For-each or recursion in XSLT

 
 
Oleg Konovalov
Guest
Posts: n/a
 
      05-14-2005
Hi,

I am new to XSLT, modifying somebody else's code:

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>

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

Thank you in advance,
Oleg.


 
Reply With Quote
 
 
 
 
Danny
Guest
Posts: n/a
 
      06-04-2005

I don't think you've worded your query well and concise enough, all I can
tell is that you want to iterate some nodes using XSL but not using the
1st node in the as the starting point or so.

Danny

On Fri, 13 May 2005 20:06:58 -0700, Oleg Konovalov <(E-Mail Removed)>
wrote:

> Hi,
>
> I am new to XSLT, modifying somebody else's code:
>
> 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>
>
> 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
>
> Thank you in advance,
> Oleg.
>
>




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
va_arg... recursion: changing arguments and the using recursion jononanon@googlemail.com C Programming 8 04-26-2012 08:37 PM
XSLT: recursion (with key?) vs nesting call-template shaun roe XML 3 09-28-2005 08:11 PM
For-each or recursion in XSLT Oleg Konovalov Java 1 06-04-2005 02:02 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
XSLT recursion with signals Leo Kirch XML 1 10-28-2003 08:49 AM



Advertisments