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

RE: How to get out the document()-file

Subject: RE: How to get out the document()-file
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Tue, 27 Jul 2004 12:13:05 -0400
.data document
> From: Roger [mailto:oxyme@xxxxxxxxxx]
>
> I have the following problem. I have an external xml-data-document
> (list.xml) from which I read a list of elements using the document()
> function. I want use a for-each-selection for all those elements, to
> display them all in a row. Inside the for-each, I need to use data
from
> the original xml-data-document (data.xml).
>
> Now I don't get any data displayed from the data.xml document inside
the
> for-each. I've used an absolute path to get to the root of the
data.xml
> file, but that doesn't seem to work. I've checked the absolute path
> outside of the for-each, and there it works fine. So I suppose I'm
> trapped into the list.xml document. How do I get out? Any ideas?

This is a common situation.  While you are within the for-each block,
the context comes from the external document, so path expressions refer
to it, not to the original source document.  The solution is to create a
global variable for the source document, like this -

<xsl:variable name='source-doc' select='/'/>

You can use this variable, which contains all the nodes from the source
document, within the for-each loop.  Note that you may want to be more
specific than "/", depending on your needs.

Cheers,

Tom P

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.