RE: [xsl] Merging Data

Subject: RE: [xsl] Merging Data
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Fri, 30 Apr 2004 22:31:20 +0200
> -----Original Message-----
> From: James Paul [mailto:jpaul@xxxxxxxxxxx]
>  
<snip />
> Does anyone have a recommended approach for tackling this issue?
>
>

Hi,

In plain English:
Define an xsl:key to approach the items by their item_number, apply
templates to those items whose generate-id() matches that of the first node
returned by the key when given that particular item_number, and inside the
items matching template, copy the item_number and then copy all other
children of the nodes returned by the key.

In XSLT, something in this direction:

<xsl:stylesheet ...>

<xsl:key name="by-number" match="ITEMS"
         use="ITEM_NUMBER" />

<xsl:template match="/">
  <xsl:apply-templates select="ITEMS[generate-id()=
                         generate-id(key('by-number',ITEM_NUMBER))]" />
</xsl:template>

<xsl:template match="ITEMS">
  <xsl:copy-of select="ITEM_NUMBER" />
  <xsl:copy-of select="key('by-number',ITEM_NUMBER)/*[
                 not(name()='ITEM_NUMBER')]" />
</xsl:template>

</xsl:stylesheet>

HTH!

Greetz,

Andreas

Current Thread