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

Re: function for getting filename

Subject: Re: function for getting filename
From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx>
Date: 01 Sep 2006 13:00:13 +0100
functions for getting file names
>>>>> "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

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.