|
[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-
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








