To check (and warn about duplication), you can find here
Something along the lines of:
<xsl:for-each-group select="collection(...)//@id" group-by="."> <xsl:if test="count(current-group()) ne 1"> <xsl:message>Id value <xsl:value-of select="current-grouping-key()"/> is duplicated in files <xsl:value-of select="current-group()/document-uri(/)" separator=" and "/></xsl:message> </xsl:if> </xsl:for-each-group>
To change all nodes in the root element.
Regarding removing duplicate rows, you have another one here
It will look like this:
<xsl:stylesheet> <xsl:key name="xyz" match="record[x/y/z]" use="x/y/z" /> <xsl:variable name="noxyzdups" select="/path/to/record[generate-id(.) = generate-id(key('xyz', x/y/z))]" /> ... <xsl:template ... > <xsl:copy-of "exslt:node-set($noxyzdups)" /> </xsl:template> </xsl:stylesheet>
x / y / z is the xpath expression that you want to make unique. It could be concat (x, '-', @y, '-', z) or whatever.
Now I'm not sure if these two examples can be easily adapted to your case, but I just wanted to point out these two sources if that helps.
source share