473,382 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Eliminating duplicate entries

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>
<xsl:otherwise>
<td><xsl:value-of select="id"/></td>
</xsl:otherwise>
</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.
Jul 20 '05 #1
1 1546

<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
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul | last post by:
Can anyone suggest an efficient way to eliminate duplicate entries in a list? The naive approach below works fine, but is very slow with lists containing tens of thousands of entries: def...
0
by: Gary Lundquest | last post by:
I have an application with MS Access 2000 as the front end and MySQL as the back end. All was well until I upgraded the MySQL (Linux) server. The Problem: I insert data into a cumulative table....
1
by: Gary Lundquest | last post by:
It appears to me that MySQL version 4 returns an error messge when doing an Insert that results in duplicate entries. Version 3 did NOT return an error - it dropped the duplicate entries and ran...
3
by: andreas.maurer1971 | last post by:
Hi all, since a few years I use the following statement to find duplicate entries in a table: SELECT t1.id, t2.id,... FROM table AS t1 INNER JOIN table AS t2 ON t1.field = t2.field WHERE...
6
by: Matt B | last post by:
Can somebody help me with this please... I have an xml file along the lines of <results> <result status="Pass"> <person name="Fred"/> <subject name="English" /> </result> <result...
5
by: Chris Lasher | last post by:
Hello Pythonistas! I'm looking for a way to duplicate entries in a symmetrical matrix that's composed of genetic distances. For example, suppose I have a matrix like the following: A B ...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
5
jamesd0142
by: jamesd0142 | last post by:
My manager and I where looking at some complex code to eliminate duplicate records in a database table. then it hit me how its done easily... so i thought i'd share it... In English:...
4
by: ramdil | last post by:
Hi All I have table and it have around 90000 records.Its primary key is autonumber field and it has also have date column and name, then some other columns Now i have problem with the table,as my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.