[xsl] Merging Data

Subject: [xsl] Merging Data
From: "Kevin Bird" <kevin.bird@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 5 Aug 2004 18:19:36 +0100
Hi Everyone

I need to combine two sets of data (File A and File B). The structure is as
follows (snippet):

FILE A:
<supplements>
<supp>
	<supp-desc>Half Board</supp-desc>
	<supp-price>#10</supp-price>
</supp>
<supp>
	<supp-desc>All Inclusive</supp-desc>
	<supp-price>#20</supp-price>
</supp>
<supp>
	<supp-desc>Sea View</supp-desc>
	<supp-price>#3</supp-price>
</supp>
...
</supplements>

FILE B:
<supplements>
<supp>
	<supp-desc>Half Board</supp-desc>
	<supp-price>#20</supp-price>
</supp>
<supp>
	<supp-desc>All Inclusive</supp-desc>
	<supp-price>#40</supp-price>
</supp>
<supp>
	<supp-desc>Balcony</supp-desc>
	<supp-price>#5</supp-price>
</supp>
...
</supplements>

REQUIRED OUTPUT:
<supplements>
<supp>
	<supp-desc>Half Board</supp-desc>
	<supp-price source="filea">#10</supp-price>
	<supp-price source="fileb">#20</supp-price>
</supp>
<supp>
	<supp-desc>All Inclusive</supp-desc>
	<supp-price source="filea">#20</supp-price>
	<supp-price source="fileb">#40</supp-price>
</supp>
<supp>
	<supp-desc>Sea View</supp-desc>
	<supp-price source="filea">#3</supp-price>
	<supp-price source="fileb">-</supp-price></supp>
<supp>
	<supp-desc>Balcony</supp-desc>
	<supp-price source="filea">-</supp-price>
	<supp-price source="fileb">#5</supp-price></supp>
...
</supplements>

DESCRIPTION:
I need to compare <supp> nodes based on the text value of <supp-desc>. If the
<supp> exists in both files then the <supp-price> node from File B is added
underneath the <supp-price> node from File A (a "source" attribute is also
added). If the <supp> exists in one file but not the other, a <supp-price>
node with the text value of "-" is added. "Sea View" and "Balcony" are
examples of <supp> being present in one file only.

Any suggestions on how best to achieve the desired result will be greatly
appreciated.


--
Kevin Bird

Current Thread