A
A.T.
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>
<xsltherwise>
<td><xsl:value-of select="id"/></td>
</xsltherwise>
</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>
<xsltherwise/>
</xsl:choose>
</tr>
</xsl:template>
</xsl:stylesheet>
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>
<xsltherwise>
<td><xsl:value-of select="id"/></td>
</xsltherwise>
</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>
<xsltherwise/>
</xsl:choose>
</tr>
</xsl:template>
</xsl:stylesheet>