Subject: Re: [xsl] function for getting filename From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx> Date: 01 Sep 2006 13:00:13 +0100 |
>>>>> "Andrew" == andrew welch <andrew.j.welch@xxxxxxxxx> writes: >> andrew> tokenize(base-uri(.), '/')[last()] >> That's not sound - . might not be the document node - if it's >> an element with an xml:base attribute in scope, then you may >> get something very spurious indeed. Andrew> I think its safe to use on all nodes except namespace Andrew> nodes: Andrew> http://www.w3.org/TR/xpath-datamodel/#acc-summ-base-uri Andrew> Regarding xml:base you should get whatever's defined in Andrew> the xml:base shouldn't you? In which case it's what the Andrew> XML author intended, and may be what you need to know at Andrew> that point, depending on your requirements. The OP's requirements were the filename, not the base-uri. if his requirements were indeed the XMl author's view of the base-uri, then it would be perfect. >> If the OP is invoking a transformation from the command line, >> then he can pass in the file name as a parameter. That is >> reliable. Andrew> Indeed, but in the general case you'll be fine with Andrew> tokenize(base-uri(.),'/')[last()] Well, no. (and not even with document-uri substituted for base-uri). What you get is the last path segment, plus possible query parameters and fragment identifier, from the base, or document, uri. In general, this has no realtion to a file name. In the case of a file: uri, even then it is not sound. If you want the file name, and you get instead a fragment identifier tacked on a file name, you don't get what you want. So a further tokenization is necessary to remove query parameters and fragment identifier. If it's not a file uri, then all bets are off. -- Colin Adams Preston Lancashire
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] function for getting file, andrew welch | Thread | Re: [xsl] function for getting file, David Carlisle |
Re: [xsl] function for getting file, andrew welch | Date | Re: [xsl] function for getting file, David Carlisle |
Month |