Hi,
Try this xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/data">
<xsl:for-each select="availability/avail">
<xsl:call-template name="findflt">
<xsl:with-param name="av" select="."/>
<xsl:with-param name="pos" select="position()"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="findflt">
<xsl:param name="av"/>
<xsl:param name="pos"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="preceding::flights/flt">
<xsl:if test="position() = $pos">
<xsl:value-of select="."/>
<xsl:value-of select="$av"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Cheers,
Omprakash.V
Ahsan Ali
<doubleletter@ To:
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
gmail.com> cc: (bcc: omprakash.v/Polaris)
Subject: [xsl] Using xsl:for-each
for every 2 elements ?
05/31/2005
11:29 AM
Please respond
to xsl-list
I mean, could you give me an example of how to co-relate elements in
the two arrays ?
Regards, Ahsan
---------- Forwarded message ----------
From: Ahsan Ali <doubleletter(_at_)gmail(_dot_)com>
Date: May 31, 2005 9:38 AM
Subject: Re: [xsl] Using xsl:for-each for every 2 elements ?
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
I'm afraid I don't follow.. could you kindly give me an example ?
Regards, Ahsan
On 5/31/05, Juergen <xsl(_at_)juergen-zink(_dot_)de> wrote:
Hi Ahsan,
why not try recursion.
Variable flights with nodes flights/flt.
Variable Availability with nodes availability/avail.
Then process the beginning of the (corresponding) nodeset
and call yourself with the rest of the nodeset.
Cheers,
Juergen
----- Original Message -----
From: "Ahsan Ali" <doubleletter(_at_)gmail(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Tuesday, May 31, 2005 7:07 AM
Subject: [xsl] Using xsl:for-each for every 2 elements ?
Hi,
Is it possible to use xsl:for-each for every two elements ?
E.g
----------
<data>
<flights>
<flt>onward</flt>
<flt>return</flt>
<flt>onward</flt>
<flt>return</flt>
</flights>
<availability>
<avail>N</avail>
<avail>Y</avail>
<avail>N</avail>
<avail>Y</avail>
</availability>
</data>
--------
The second part of the problem is that, the above have to be
iterated/grouped using a method that would still allow me to somehow
co-relate the first <avail> in <availability> with the first <flt> in
<flights>. That's my second question.. how to co-relate that since
their in the same level of hierarchy ??
Thanks,
Ahsan
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
This e-Mail may contain proprietary and confidential information and is sent
for the intended recipient(s) only.
If by an addressing or transmission error this mail has been misdirected to
you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction,
dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its
attachment other than by its intended recipient/s is strictly prohibited.
Visit Us at http://www.polaris.co.in
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--