xsl-list
[Top] [All Lists]

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

2005-05-30 23:28:12
Hi Ahsan,
   Making a strange guess to the difficulty you are
facing, here is the XSLT I think that should solve the
problem .. 

<?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" indent="yes" />
  
<xsl:template match="/">
  <groups>
    <xsl:for-each select="//*[(position() mod 2) =
0]">
        <group>
          <xsl:copy-of select="(preceding::*[1] |
ancestor::*[1]) | (preceding::*[2] | ancestor::*[2])"
/>
        </group>
    </xsl:for-each>
  </groups>  
</xsl:template>
  
</xsl:stylesheet>

Regards,
Mukul

--- Ahsan Ali <doubleletter(_at_)gmail(_dot_)com> wrote:
Thanks Mukul.

In this case, how do I refer to the _two_ elements
selected.. Using
'.', I can display only the second element...

Regards,

Ahsan

On 5/31/05, Mukul Gandhi <mukul_gandhi(_at_)yahoo(_dot_)com>
wrote:
Hi Ahsan,
   Please try this XSL, for processing every two
elements ..

   <xsl:for-each select="//*[(position() mod 2) =
0]">
     <!-- Processing you wish -->
   </xsl:for-each>

Regards,
Mukul

--- Ahsan Ali <doubleletter(_at_)gmail(_dot_)com> wrote:
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>
--~--



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam
protection around
http://mail.yahoo.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>
--~--



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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>
--~--