xsl-list
[Top] [All Lists]

Re: Using xsl:for-each for every 2 elements ?

2005-05-30 23:10:25
Hi Ahsan,

sorry, variables in template calls are called parameter.
Assuming you are in <data>. Code not tested

     <xsl:call-template name="Loop">
       <xsl:with-param name="Flights" select="flights/flt"/>
       <xsl:with-param name="Availibility" select="availability/avail"/>
     </xsl:call-template>

<xsl:template name="Loop">
 <xsl:param name="Flights"/>
 <xsl:param name="Availibility"/>
 <xsl:choose>
   <xsl:when test="count($Flights)=0">
   </xsl:when>
   <xsl:otherwise>
     <! -- do processing of $Flights[1] and $Availibility[1] -->
     <xsl:call-template name="Loop">
       <xsl:with-param name="Flights" select="$Flights[position()!=1]"/>
<xsl:with-param name="Availibility" select="$Availibility[position()!=1]"/>
     </xsl:call-template>
   </xsl:otherwise>
 </xsl:choose>
</xsl:template>

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:38 AM
Subject: Re: [xsl] Using xsl:for-each for every 2 elements ?


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>
--~--


--~------------------------------------------------------------------
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>
--~--