[xsl] Match values from XML-file A with values from XML-file B

Subject: [xsl] Match values from XML-file A with values from XML-file B
From: "Sellmer-Brüls, Barbara" <B.Sellmer-Bruels@xxxxxxxxxxx>
Date: Thu, 24 May 2001 18:37:35 +0200
Hello,

I have written a lot of stylesheets, BUT
there is a problem I cannot solve without producing a - as I think - too
copious XSL.

I've got 2 XML files:

file A: contains a structured list of codes that shall be used to collect
data from XML file B

example file A:
<class>
	<chapter no="1" heading="Chapter 1">
		<category goc="*" code="SCA1" />
		<category goc="*" code="SCA2"/>
		<category goc="*" code="SCB1"/>
	</chapter>
	
	<chapter no="2" heading="Chapter 2">
		<category goc="*" code="SCC5"/>
		<category goc="*" code="SCB7" />
	</chapter>
</class>

For each chapter I need to collect all products from file B that have a code
matching one of the codes in the current chapter. The result of all products
matched by the miscellanious codes for this chapter shall be sortet, eg. by
their ID.

file B:
<export>

   <product @id="ISBN-1">
      ... more elements ...
      <class>
	<category code="SCA">
		<category code="SCA1" />
		<category code="SCA2"/>
	</category>
	<category code="SCB">
		<category code="SCB9"/>
	</category>
      </class>
   </product>

   <product @id="ISBN-2">
      ... more elements ...
      <class>
	<category code="SCA">
		<category code="SCA9"/>
	</category>
	<category code="SCB">
		<category code="SCB7"/>
	</category>
      </class>
   </product>

   <product @id="ISBN-3">
      ... more elements ...
      <class>
	<category code="SCB">
		<category code="SCB1"/>
		<category code="SCB7"/>
	</category>
      </class>
   </product>

</export>

Idea 1:
The stylesheet operates on file A (codes) and selects products from file B.
Somehow I feel that there must be an elegant solution, but I don't know how
to match n codes from the chapter code list to m codes within each product
od the export file, AND sort the complete result of each chapter  :-( 

Idea 2:
The stylesheet operates on file B (products), where all chapters are defined
and product-templates are matched if there are nodes with the corresponding
codes. I find this alternative quit labourious.

Does anyone have any idea??
Many thanks
Barbara
----
mailto:b.sellmer-bruels@xxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread