Code:
<?xml version="1.0" encoding="UTF-8"?>
<passengergroup>
<passengerList>
<passDetails>
<route>LONDON</route>
<lastname>RAY</lastname>
<firstname>DONALD</firstname>
<country>UK</country>
</passDetails>
<seatDetails>
<SeatNo>1A</SeatNo>
</seatDetails>
<customervalue>good</customervalue>
</passengerList>
<passengerList>
<passDetails>
<route>LONDON</route>
<lastname>RAY</lastname>
<firstname>DONALD</firstname>
<country>UK</country>
</passDetails>
<seatDetails>
<SeatNo>1B</SeatNo>
</seatDetails>
<customervalue>good</customervalue>
</passengerList>
<passengerList>
<passDetails>
<route>DELHI</route>
<lastname>RATHORE</lastname>
<firstname>ALAN</firstname>
<country>IND</country>
</passDetails>
<seatDetails>
<SeatNo>2C</SeatNo>
</seatDetails>
<customervalue>okey</customervalue>
</passengerList>
<passengerList>
<passDetails>
<route>DELHI</route>
<lastname>RATHORE</lastname>
<firstname>ALAN</firstname>
<country>IND</country>
</passDetails>
<seatDetails>
<SeatNo>2D</SeatNo>
</seatDetails>
<customervalue>okey</customervalue>
</passengerList>
</passengergroup>
XSLT CODE
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="text" />
<xsl:template name="fixWidth">
<xsl:param name="width"/>
<xsl:param name="data"/>
<xsl:param name="dataLength">
<xsl:value-of select="fn:min( ( fn:number($width), fn:string-length($data) ) )"/>
</xsl:param>
<xsl:param name="paddingLength">
<xsl:value-of select="$width - $dataLength"/>
</xsl:param>
<xsl:call-template name="padding">
<xsl:with-param name="count" select="$paddingLength"/>
</xsl:call-template>
<xsl:value-of select="fn:substring($data,1,fn:number($dataLength))"/>
</xsl:template>
<xsl:template name="padding">
<xsl:param name="count"/>
<xsl:if test="$count > 0">
<xsl:text> </xsl:text>
<xsl:call-template name="padding">
<xsl:with-param name="count" select="$count - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="passengergroup" />
</xsl:template>
<xsl:template match="passengergroup">
<xsl:if test="passengerList/customervalue='good'">
<xsl:for-each-group select="passengerList"
group-by="concat (passDetails/route, ' ',passDetails/firstname,' ',passDetails/lastname)">
<xsl:value-of select="current-grouping-key()" />
<xsl:text> </xsl:text>
<!-- <xsl:call-template name="fixWidth">
<xsl:with-param name="width">4</xsl:with-param>
<xsl:with-param name="data">
<xsl:value-of select="current-group()/seatDetails/SeatNo" separator=" " />
</xsl:with-param>
</xsl:call-template>-->
<xsl:value-of select="current-group()/seatDetails/SeatNo" separator=" " />
<xsl:value-of select="'
'" />
</xsl:for-each-group>
</xsl:if>
<xsl:if test="passengerList/customervalue!='good'">
<xsl:for-each-group select="passengerList"
group-by="concat(passDetails/route, ' ',passDetails/firstname,' ',passDetails/country)">
<xsl:value-of select="current-grouping-key()" />
<xsl:text> </xsl:text>
<xsl:value-of select="current-group()/seatDetails/SeatNo" separator=" " />
<xsl:value-of select="'
'" />
</xsl:for-each-group>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Output
I fixed it.....its worked