Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] function for getting filename

From: Colin Paul Adams <colin@------------------>
To:
Date: 9/1/2006 12:00:00 PM
>>>>> "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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent