[xsl] removing duplicate tags (xslt2.0)

Subject: [xsl] removing duplicate tags (xslt2.0)
From: "Robby Pelssers" <robby.pelssers@xxxxxxxxx>
Date: Fri, 14 Jan 2011 08:51:40 +0100
Hi all,

I would like to go from

BEFORE:
<RefMaterial LocalKeyRef="Capacitor_BGD502_1" Weight="05.80" Unit="mg">
  <Application Subst_ID="2619" ApplCode="34"/>
  <Application Subst_ID="5360" ApplCode="24"/>
  <Application Subst_ID="2619" ApplCode="34"/>
</RefMaterial>

to

AFTER:
<RefMaterial LocalKeyRef="Capacitor_BGD502_1" Weight="05.80" Unit="mg">
  <Application Subst_ID="2619" ApplCode="34"/>
  <Application Subst_ID="5360" ApplCode="24"/>
</RefMaterial>

in the most efficient way.

Currently I'm using nested grouping but i was wondering if this is the best
way.

  <xsl:template match="RefMaterial">
    <RefMaterial>
      <xsl:apply-templates select="@*"/>
      <xsl:for-each-group select="Application" group-by="@Subst_ID">
        <xsl:variable name="substanceId" select="current-grouping-key()"/>
        <xsl:for-each-group select="current-group()" group-by="@ApplCode">
          <Application Subst_ID="{$substanceId}"
ApplCode="{current-grouping-key()}"/>
        </xsl:for-each-group>
      </xsl:for-each-group>
    </RefMaterial>
  </xsl:template>

Kind regards,
Robby Pelssers

Current Thread