[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Match values from XML-file A with values from XML-

Subject: Re: Match values from XML-file A with values from XML-file B
From: Adam Turoff <ziggy@xxxxxxxxx>
Date: Thu, 24 May 2001 13:09:24 -0400
xml matching code
On Thu, May 24, 2001 at 06:37:35PM +0200, "Sellmer-Brüls, Barbara" wrote:
> 
> [source documents snipped]
>
> 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  :-( 

This is quite workable.

First, you want to load up the second document (B.xml), so you have
it around when processing the first document (A.xml).  This should
be done at the top level.

 <xsl:variable name="doc" select="document('B.xml')"/>

Then, when processing the report template (A.xml), refer back to the
second document, and select out the relevant portions.

	<xsl:template match="category">
	 <!-- keep track of the code we want -->
	 <xsl:variable name="code" select="@code"/>

	 <!-- select products with that category code -->
	 <xsl:variable name="products"
	     select="$doc/export/product[class/category/category/@code=$code]"/>

	 <!-- process this category...-->
	 <category code="{$code}">
	  <!-- ...and process each product matching this category -->
	  <xsl:apply-templates select="$products"/>
	 </category>
	</xsl:template>

That's it.  Of course, you'll need to define templates to match 
<product/>, but that's to be expected.

Hope this helps,

Z.


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.