Re: [xsl] function for getting filename

Subject: Re: [xsl] function for getting filename
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 1 Sep 2006 13:11:22 +0100
> So a further tokenization is necessary to remove query parameters and
> fragment identifier.

this is true in general (as well as the observation that there may be no
file at all) but I've found editing base-uri like this to be very useful
in xslt2 stylesheets where it would be very hard to do the xslt1-thing
of passing in the filename as a parameter as the stylesheet is iterating
over a collection() so you don't really have any external control over
which input documents are being processed. Although I do know in those
cases that the uri will be file: without any # or / part.

I'd probably do replace(base-uri(/),'.*/','') to remove the path
component rather than tokenize and last() but it probably doesn't make
much difference really. You could add |[\?#].* to the regex to also
remove query and fragment identifiers if they were a possibility.


David

Current Thread