This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Getting at original document from inside document()
- To: "Phil Endecott" <spam-from-xsl-list at chezphil dot org>
- Subject: Re: [xsl] Getting at original document from inside document()
- From: Jeni Tennison <jeni at jenitennison dot com>
- Date: Tue, 23 Oct 2001 14:56:35 +0100
- CC: XSL-List at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <200110231324.f9NDOca15577@shelob.julianhaight.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Phil,
> I was hoping that something like document('')/book/@title would get
> the answer, but it looks like this gets the stylesheet, not the
> original input document.
Whenever I have a stylesheet that deals with multiple documents, I
have a global variable to hold the root node of the source XML
document:
<xsl:variable name="source" select="/" />
This guarantees that I can get back to the information from the
original source document no matter where I am. So you can use:
$source/book/@title
to get the title of the book.
> Maybe there is a case for adding something to the next XSL to do
> this?
While I think this particular problems can be addressed as above, I
agree that it's often helpful to be able to get hold of the URI for
the source document, and even the stylesheet, for example to add
comments like:
<!-- transformed from source.xml by my favourite XSLT processor -->
Perhaps a base-uri() function or extending the system-property()
function:
system-property('xsl:source-uri')
system-property('xsl:stylesheet-uri')
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list