Project

Profile

Help

Bug #4630 » eliminate-duplicates-with-key2.xsl

Martin Honnen, 2020-07-03 14:43

 
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xpath-default-namespace="http://example.com/ns1"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:strip-space elements="*"/>
<xsl:output indent="yes"/>
<xsl:key name="foo-group" match="foo" use="key"/>
<xsl:template match="foo[. is key('foo-group', key)[1]]">
<xsl:copy>
<xsl:apply-templates select="*, (key('foo-group', key) => tail())/(* except key)"/>
</xsl:copy>
</xsl:template>
<xsl:template match="foo[not(. is key('foo-group', key)[1])]"/>
</xsl:stylesheet>
(1-1/2)