xsl-list
[Top] [All Lists]

RE: Merging Data

2004-04-30 13:31:20
-----Original Message-----
From: James Paul [mailto:jpaul(_at_)quadrem(_dot_)com]
 
<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



<Prev in Thread] Current Thread [Next in Thread>
  • Merging Data, James Paul
    • RE: Merging Data, Andreas L. Delmelle <=