[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Duplicate elements. HELP!


Subject: RE: [xsl] Duplicate elements. HELP!
From: "Stoaks, Max" <Stoaks_Max@xxxxxxxxxxxxxxxx>
Date: Sun, 6 Jun 2004 14:24:50 -0700

Thanks Michael,

It works perfectly.

I had also gotten around to:
	<xsl:for-each select="CompanyResults/CompanyResult[not
           (CompanyTitle=preceding::CompanyTitle)]">

Which seems to work as well. But your solution is more succint since I am interested in siblings (same level) only and not ancestors, for example.

Thanx again!
Max

-----Original Message-----
From: Michael Kay [mailto:mhk@xxxxxxxxx]
Sent: Sunday, June 06, 2004 1:39 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Duplicate elements. HELP!


Your wrote

	<xsl:for-each select="CompanyResults/CompanyResult[not
 
(./CompanyTitle=preceding::CompanyResults/CompanyResult/CompanyTitle)]">


No CompanyResult has a preceding CompanyResults, because ancestors of an
element are not included on the preceding axis. Even if they were, this
condition wouldn't work because the CompanyResult children of the
CompanyResults include the element you started from, which is always equal
to itself. 

You want
 
	<xsl:for-each select="CompanyResults/CompanyResult[not
           (CompanyTitle=preceding-sibling::CompanyResult/CompanyTitle)]">

Michael Kay	
 

> -----Original Message-----
> From: Stoaks, Max [mailto:Stoaks_Max@xxxxxxxxxxxxxxxx] 
> Sent: 06 June 2004 18:19
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Cc: Stoaks, Max
> Subject: [xsl] Duplicate elements. HELP!
> 
> Hi,
> 
> I'm trying to ignore duplicate elements and having trouble 
> with the XPath syntax. I'm hoping some kind soul can help...
> 
> 
> Here's my xml:
> <CompanyResults>
> 	<CompanyResult>
> 		<CompanyTitle>IBM</CompanyTitle>
> 		<CompanyContact>Joe</CompanyContact>
> 	</CompanyResult>
> 	<CompanyResult>
> 		<CompanyTitle>IBM</CompanyTitle>
> 		<CompanyContact>Joe</CompanyContact>
> 	</CompanyResult>
> 	<CompanyResult>
> 		<CompanyTitle>Intuit</CompanyTitle>
> 		<CompanyContact>Claudia</CompanyContact>
> 	</CompanyResult>
> 	<CompanyResult>
> 		<CompanyTitle>IBM</CompanyTitle>
> 		<CompanyContact>Joe</CompanyContact>
> 	</CompanyResult>
> </CompanyResults>
> 
> I want to ignore any CompanyResult that has a CompanyTitle 
> that has already occured.
> 
> <xsl:template match="/">
> 	<xsl:for-each select="CompanyResults/CompanyResult[not
>            
> (./CompanyTitle=preceding::CompanyResults/CompanyResult/Compan
> yTitle)]">	
> 			<xsl:value-of select="CompanyTitle"/>	
> 	</xsl:for-each>	
> 
> Any help would be greatly appreciated as I've been pulling my 
> hair out about this...
> 
> I'm using XalanJ 2.6.
> 
> Thanks!
> Max
> 
> 
> --+------------------------------------------------------------------
> 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@xxxxxxxxxxxxxxxxxxxxxx>
> --+--
> 
> 



--+------------------------------------------------------------------
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@xxxxxxxxxxxxxxxxxxxxxx>
--+--



Current Thread
Keywords