Sorting & duplicates

A.T.

Usenet Archive
Joined
Jul 22, 2004
Messages
4
Reaction score
0
Have an XSL file that flags duplicate id's, by painting cells blue and by adding the word "duplicate" to a new column at the end of the table. It also sorts the id's. Would like to have the output file retain these qualities, but also sort the document(using the duplicate column) so that duplicates come at the beginning.

XML file
<root>
<version size="16">
<id>A1</id>
<type>mac</type>
</version>
<version size="16">
<id>A1</id>
<type>mac</type>
</version>
<version size="32">
<id>A2</id>
<type>pc</type>
</version>
</root>
XSL file
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="/">
<html>
<head>
<title>Version Information</title>
</head>
<body>
<table border="1" align="center"
cellPadding="1"
cellSpacing="1">
<tr>
<th>Id</th>
<th>Size</th>
<th>Type</th>
<th>Duplicate</th>
</tr>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>

<xsl:template match="root">
<xsl:apply-templates select="version">
<xsl:sort select="id"/>
</xsl:apply-templates>
</xsl:template>

<xsl:template match="version">
<tr align="center">
<xsl:choose>
<xsl:when test="child::id=preceding::id">
<td bgcolor="blue">
<xsl:value-of select="id"/>
</td>
</xsl:when>
<xsl:eek:therwise>
<td><xsl:value-of select="id"/></td>
</xsl:eek:therwise>
</xsl:choose>
<td><xsl:value-of select="@size"/></td>
<td><xsl:value-of select="type"/></td>
<xsl:choose>
<xsl:when test="child::id=preceding::id">
<td>duplicate</td>
</xsl:when>
<xsl:eek:therwise/>
</xsl:choose>
</tr>
</xsl:template>
</xsl:stylesheet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top