Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Eliminating duplicate entries

Reply
Thread Tools

Eliminating duplicate entries

 
 
A.T.
Guest
Posts: n/a
 
      07-22-2004
I have an XML document that looks like the following, except that it
has about 30,000 entries.
<root>
<version id="A-0000">
<!many elements within- removed for ease of reading>
</version>
<version id="A-0000">
</version>
<version id="A-0001">
</version>
</root>


I want to create a stylesheet where a flag goes up when there are
duplicates like:
<version id="A-0256">
</version>
<version id="A-0256">
</version>

I'm trying to use

<xsl:template match="version">
<xsl:choose>
<xsl:when test="preceding::node()=node()">
<td bgcolor="blue"><xsl:value-of select="id"/></td>
</xsl:when>
<xsltherwise>
<td><xsl:value-of select="id"/></td>
</xsltherwise>
</xsl:choose>
<xsl:apply-templates select="version"/>
</xsl:template>

but I can't seem to get the test="" part of it to work. Please help.
 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      07-22-2004

<xsl:template match="version">
<xsl:choose>
<xsl:when test="preceding::node()=node()">

your currnt node is version so the above test is testing if _any_
preceding node anywhere in the document (of any type, element, text,
comments, ..) is equal to any child node of the current node.

The current node apparently only has one child a text node consisting of
a newline character so you are asking if any previous node has string
value being a newline.

You want to know if the previous sibling element is equal to the current
node
so that's
<xsl:template match="version">
<xsl:choose>
<xsl:when test="preceding-sibling::*=.">

or
<xsl:template match="version">
<xsl:choose>
<xsl:when test="preceding-sibling::*[1]=.">

if your input is already sorted and you only need check teh immediately
preceding element.


David
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eliminating duplicate information in selected sorted rows Matt B XML 6 10-08-2005 07:56 PM
Is there a program for eliminating duplicate picture files? WF Computer Support 4 02-23-2005 09:13 PM
Tying up Port Login table entries with Port Table Entries in CISCO SNMP John Ramsden Cisco 0 07-24-2004 04:03 PM
Eliminating duplicates entries from a list efficiently Paul Python 9 07-07-2004 04:43 AM
Newbie question: eliminating entries in dict sean Python 5 11-26-2003 09:17 AM



Advertisments