xsl-list
[Top] [All Lists]

RE: Duplicate elements. HELP!

2004-06-06 14:24:50
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(_at_)mhk(_dot_)me(_dot_)uk]
Sent: Sunday, June 06, 2004 1:39 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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(_at_)gsb(_dot_)stanford(_dot_)edu] 
Sent: 06 June 2004 18:19
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





--+------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



<Prev in Thread] Current Thread [Next in Thread>