473,785 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

For-each or recursion in XSLT

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="positio n()">
</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="positio n()">
</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.
Jul 20 '05 #1
1 1562

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 <ol*****@yahoo. com>
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="positio n()">
</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="positio n()">
</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/
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9423
by: Xerxes | last post by:
Hi, is there any script to authenticate an email address entered in a form field? I used the php mail() function, using the following (where my email field on the form is called "email"): $email = explode('@',$email); $mailhost = $email; $mailhost=$mailhost.".";
4
6429
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as well as some color coding, etc. Having trouble finding the same in an editor that'll run on OS X. -- Floydian Slip(tm) - "Broadcasting from the dark side of the moon"
0
2894
by: Verizon | last post by:
Has anybody ever heard of support for the book: "Secure PHP Development" by: Mohammed J. Kabir I'm trying to run one of his PHP solutions called "Web Forms Manager" I haven't been able to get it up and running. Thanks in advance!
0
2019
by: panic | last post by:
If you are not familiar with the palm DB apps I am refering to, they are applications that allow you to graphically create a db by adding fields(columns) and then creats a form so you can enter the info, and also you can display it in row form. So I am looking for a program that would be a type of online record keeper, where you can via the web, create a database, or table, add fields, and be able to add records, and view them in a a...
0
3570
by: Robert Freund | last post by:
I've been looking for a good and free code beautifier that runs on linux. About the only ones I found where Trita (www.trita.com), which costs money and only runs on windows. The other one was Beautify PHP (www.bierkandt.org/beautify) which does not offer all the features I'd like to have. I'm also more interested in something that is not written in php itself because I want to reformat large amounts of code quite often, and I guess...
33
9874
by: Frank | last post by:
What is the best IDE for developing PHP applications? What do you use and why? Thanks.
4
5968
by: john Q | last post by:
I found a PHP based email obfuscator for use in websites, where the source HTML (PHP, actually) file doesn't contain the actual email address in the Mailto tag, but generates it and that generated page (containing a full and conventional Mailto: tag) is what is ultimately presented to the user. The intent is to thwart Spam bots and spiders, by NOT having the email address in the original HTML Source, but ultimately presenting it to...
0
2024
by: Mr.Bogi | last post by:
Is anyone aware of an open source report generation library for php/mysql? Basically a freeware/opensource alternative to Crystal Reports. thanks
0
2199
by: Alex | last post by:
Bottom line: would like to get a weblog and bulletin board going. Would like to use phpBB2 and movabletype. I have movabletype working using mysql. Apache and php were on my linux red hat 7.2 out of the box it seems. hello.php worked with the original setup. Somewhere along the time of installing MySQL database & DBD::mysql and a php-mysql rpm my hello.php stopped working and is now just showing text-source in the web browser.
5
2231
by: ChronicFatigue | last post by:
Hello My current host has register_globals switched on in their php.ini file. Would it be prudent for me to design code which works when register_globals is switched off in case I switch hosts in the future? If I dont is it normally straightforward to edit the code so that a script can be run with register_globals off in the future? Just trying to future proof my work abit.
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10151
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.