Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2013, 07:59 AM
Registered User
 
Join Date: Jul 2013
Posts: 6
Thanks: 1
Thanked 1 Time in 1 Post
Default XSLT groping based on three columns in xslt 1.0 or 2.0

Code:
<passengergroup>
<passengerList>
	<passDetails>
		<route>LONDON</route>
		<lastname>RAY</lastname>
	</passDetails>
	<seatDetails>
		<SeatNo>1A</SeatNo>
	</seatDetails>
	<customervalue>good</customervalue>
</passengerList
<passengerList>
	<passDetails>
		<route>LONDON</route>
		<lastname>RAY</lastname>
	</passDetails>
	<seatDetails>
		<SeatNo>1B</SeatNo>
	</seatDetails>
	<customervalue>good</customervalue>

   </passengerList
   <passengerList>
	<passDetails>
                 <route>DELHI</route>
	    <lastname>RAY</lastname>
	</passDetails>
	<seatDetails>
	    <SeatNo>2C</SeatNo>
	</seatDetails>
	<customervalue>okey</customervalue>
     </passengerList>
     <passengerList>
		<passDetails>
			<route>DELHI</route>
			<lastname>RAY</lastname>
		</passDetails>
		<seatDetails>
			<SeatNo>2D</SeatNo>
		</seatDetails>
		<customervalue>okey</customervalue>
		
     </passengerList>
     </passengergroup>

XSLT CODE
Code:
<xsl:for-each select="passengergroup/passengerList">
	<xsl:if test="customervalue='good'
		<xsl:value-of select="route"/><xsl:text> </xsl:text>
		<xsl:value-of select="customervalue"/><xsl:text> </xsl:text>
		<xsl:value-of select="seatDetails/SeatNo"/>
</for-each>

<xsl:for-each select="passengergroup/passengerList">
<xsl:if test="customervalue='okey'
	<xsl:value-of select="route"/><xsl:text> </xsl:text>
	<xsl:value-of select="customervalue"/><xsl:text> </xsl:text>
	<xsl:value-of select="seatDetails/SeatNo"/>
</for-each>
It will produce output like this

LONDON good 1A
LONDON good 1B
DELHI okey 2C
DELHI okey 2D

But i need the output like this

LONDON good 1A 1B
DELHI okey 2C 2D

Here am getting LONOND

I dont want to print the LONDON and DELHI again and again for the corresponding seats. if the route has multiple seat It has to come to like this
LONDON AB 1A 1B 1C 1D 2B 2F 3F 3G ........ Please help me..Really I tried lot..I am unable to do that..It might be silly question to you. But I dont know..answer this.

Last edited by santhakumar; July 15th, 2013 at 11:29 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
skip creating tag based on conditions sudheer.raju XSLT 3 December 20th, 2011 06:56 AM
select the group of rows based on the three XML fields and with these conditions. CCPuser XSLT 3 October 22nd, 2010 09:11 AM
select the group of rows based on the three XML fields and with conditions. CCPuser BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 1 October 22nd, 2010 09:06 AM
Display or hide ModalPopupExtender based on client-site conditions Dmitriy ASP.NET 3.5 Professionals 5 August 20th, 2009 01:04 PM
selection based on conditions rajesh_css XSLT 3 October 2nd, 2008 08:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.