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

Re: working with multiple inputs simultaneously

Subject: Re: working with multiple inputs simultaneously
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Wed, 3 Oct 2001 09:21:16 -0400
document working simultaneously
[Irene Hall]

> I am attempting to transform an XML file dependent on the content of a
> second XML file. It goes Ok until I am in a situation where I require to
do
> a nested for-each with the outside for-each being based on one XML input
> and the inside for-each based on the other XML input. I cannot get the
> inside loop to run as once inside the outside for-each there appears to be
> no recognition of the other XML document. I have combed  M Kay's "XSLT
> Reference" but it doesn't appear to cover anything remotely like this. Is
> this because it is impossible to do ?
>

It is possible, and not hard.  When you use xsl:for-each, the processor
changes the context so that the current node becomes the node you gave to
the xsl:for-each.  That is why your template is not recognizing the "other"
document.

You can make this work by creating a variable for each document:

<xsl:variable name='doc1' select='.'/>
<xsl:variable name='doc2' select='document("second-xml-file.xml")'/>

You can then do things within for-each loops like this:

<xsl:for-each select='$doc2'>
    <xsl:value-of select='$doc1/docname/@id'/>
   <!-- And so on...-->
</xsl:for-each>

If you do not want to use the entire tree of the first document, create a
variable for the part that you are interested and use it the same way.

Cheers,

Tom P



 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.