xsl-list
[Top] [All Lists]

RE: Duplicate elements. HELP!

2004-06-06 13:39:05
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>
--+--






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