xsl-list
[Top] [All Lists]

RE: problems with copying duplicate nodes

2005-06-29 02:49:36

I read quite a few of the earlier posts on this topic
and tried to work out a solution but it aint working.
Snippets of my code are shown below:

input.xml

<TABLE>
    <TR>
       <TD>Checking existence of Wood</TD>
       <TR>
          <TD>Found values for Wood</TD>
          <TD> The values are x y z</TD>
          <TD>Found values for Wood</TD>
          <TD> The values are x y z</TD>
       </TR>
    </TR>
    <TR>
       <TD>Checking existence of Tree</TD>
       <TR>
          <TD>Found values for Tree</TD>
          <TD> The values are a b c</TD>
       </TR>
    </TR>
</TABLE>

Is that legal HTML?
 

I want to eliminate the duplicate <TD>s inside TABLE
/TR/TR whenever they occur. I tried two solutions but
none of them eliminate the duplicate entries.

You basically want to key on the value of the <TD> and then only process
those <TD>'s that occur first in the key eg:

<xsl:key name="tds" match="TD" use="."/>

and then:

<xsl:template match="TD">
  <xsl:if test="generate-id() = generate-id(key('tds',.)[1])">
     ...

Check out David Pawson's FAQ:
http://www.dpawson.co.uk/xsl/sect2/N2696.html

cheers
andrew

--~------------------------------------------------------------------
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>