[Home] [By Thread] [By Date] [Recent Entries]
Satish wrote:
I am working on a stylesheet to process my XML data but can't seem to resolve duplicates successfully. With XSLT 2.0 it sounds as if you could for-each-group, with XSLT 1.0 I would use Muenchian grouping to eliminate duplicates. Here's a simplified analogy of my XML Then with XSLT 1.0 I would define keys
<xsl:output method="html" indent="yes"/> <xsl:key name="k1" match="book" use="@authorId"/> <xsl:key name="k2" match="book" use="concat(@authorId, '|', @id)"/> <xsl:variable name="authorsList"> <xsl:apply-templates select="//author" mode="group"/> </xsl:variable> <xsl:template match="/"> <html> <xsl:copy-of select="$authorsList"/> <body>
<table>
<tr>
<td>Library Name</td>
...
</tr>
</table>
</body>
</html>
</xsl:template><xsl:template match="author" mode="group"> <LibraryAuthor authName="{@name}"> <xsl:apply-templates select="key('k1', @id)[generate-id() = generate-id(key('k2', concat(current()/@id, '|', @id))[1])]" mode="group"/> </LibraryAuthor> </xsl:template> <xsl:template match="book" mode="group">
<LibraryBook name="{@name}" authId="{@authorId}"/>
</xsl:template></xsl:stylesheet> The <xsl:copy-of select="$authorsList"/> is just for debugging, you probably want to process that variable further although with XSLT 1.0 you will then need to use exsl:node-set or similar first. -- Martin Honnen --- MVP Data Platform Development http://msmvps.com/blogs/martin_honnen/
|

Cart



