Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] function for getting filename

From: "andrew welch" <andrew.j.welch@--------->
To:
Date: 9/1/2006 11:28:00 AM
On 01 Sep 2006 12:01:18 +0100, Colin Paul Adams
<colin@xxxxxxxxxxxxxxxxxx> wrote:
>>>>> "andrew" == andrew welch <andrew.j.welch@xxxxxxxxx> writes:



    andrew> On 9/1/06, Frank Marent <frank.marent@xxxxxxxxxxx> wrote:
    >> i'm struggling again and again over this point:
    >>
    >> is there a function in xslt that gives me the clean filename of
    >> the processed xml file? like
    >>
    >> 'myfile.xml' 'test.xml' 'anyfilename.xml'
    >>
    >> i do *not* need the document-uri. only the filename of the
    >> current processed xml file.

    andrew> In xslt 2.0 I use:



    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.

I think its safe to use on all nodes except namespace nodes:



http://www.w3.org/TR/xpath-datamodel/#acc-summ-base-uri



Regarding xml:base you should get whatever's defined in the xml:base
shouldn't you?  In which case it's what the XML author intended, and
may be what you need to know at that point, depending on your
requirements.

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.

Indeed, but in the general case you'll be fine with
tokenize(base-uri(.),'/')[last()]


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