|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: working with multiple inputs 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
|
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








