xsl-list
[Top] [All Lists]

[xsl] removing duplicate tags (xslt2.0)

2011-01-14 01:51:55

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>