This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: grouping by child element


> I have a simple list of data coming from a stored proc.  I 
> have a sort set up based on user selection.
> the xml looks like this (using soap request/response method)
> <GetMerchantListResponse>
> <Merchant merchID="some_number">
> 	<merchName>Some_name</merchName>
> 	<merchActive>boolean value</merchActive>
> 	<merchIsoID>ISO ID number</merchIsoID>
> </Merchant>
> </GetMerchantListResponse>

> I have them sorted (initially) by merchIsoID.  What I need to 
> do is group them into tables based on this element.

Have you read the FAQ (follow the link at the bottom of this mail) on
sorting and grouping?
> 
> Below is the xsl i am working with:
> <xsl:template match="/">
> 		<xsl:apply-templates select="//SOAP-ENV:Fault"/>
> 		<xsl:apply-templates select="//GetMerchantListResponse">
> 		<xsl:sort select="//Merchant"/>
> 		</xsl:apply-templates>
> 	</xsl:template>
> 
The "//" at the beginning of the first two expressions is inefficient but
not incorrect. In the <xsl:sort> it is disastrous: it means that instead of
selecting the Merchant part of each GetMerchantListResponse, you are using
the first Merchant in the data as the sort key for each record. 

In any case, Merchant seems an odd choice of sort key as it is a composite
value. Your narrative suggests that you want <xsl:sort
select="Merchant/merchIsoId"/>

Mike Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]