[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: Using xsl:for-each for every 2 elements ?
From: Ahsan Ali <doubleletter@xxxxxxxxx>
Date: Tue, 31 May 2005 11:00:50 +0400
ev values for every element
I'm sorry for the confusion but I believe I erred in that example data:

Here's a precise version

<AirAvail>

  <AvailFlt>
   <name></name>
   <flightno></flightno>
 </AvailFlt>

  <AvailFlt>
   <name></name>
   <flightno></flightno>
 </AvailFlt>

 <FlightAvailStatus>
   <coach>Y</coach>
   <first>Y</first>
   <business>N</business>
 </FlightAvailStatus>

 <FlightAvailStatus>
   <coach>Y</coach>
   <first>Y</first>
   <business>N</business>
 </FlightAvailStatus>

</AirAvail>


For clarity's sake, I'll restate the requirement: I want to group
every 2 AvailFlt elements; at the same time, while displaying the data
of each element, I want to display its availability status in the
corresponding FlightAvailStatus element. The only thing that relates
the two elements is their position (or order)....

I tried the below solution (by OmPrakash) but it gives me no output...

Thanks for your time !

Regards,

Ahsan

On 5/31/05, omprakash.v@xxxxxxxxxxxxx <omprakash.v@xxxxxxxxxxxxx> wrote:
>
>
> Hi,
>
>           This is a modified version of the stylesheet to accoodate for the
> fact that you had asked for every other element to be processed.
>
> I am not sure if I got your requirement right and if someone has answered
> this question already. This is an independent effort and not based on
> anyone else' solution.
>
>
> <?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[(position() mod 2) = 0]">
>
> <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[(position() mod 2) = 0]">
>      <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
>
>
>
>
> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.