Re: [xsl] get the current xml file name

Subject: Re: [xsl] get the current xml file name
From: "Colin Adams" <colinpauladams@xxxxxxxxxxx>
Date: Tue, 08 Aug 2006 09:31:40 +0100
Yeah, I realized I had missed off the / just after I posted.

But Owen has just pointed out that uoi must be using XSLT 2.0, so using resolve-uri is much neater.

As to why there is no way to tell what the current XML file name is then:

1) There may not be an initial context node at all - you can simply pass an initial template, and operate on atomic values only.
2) - given the context item is set, and it's a node, then you can get it's base-uri from base-uri (.). But a file name? Why must it have come from a file?


The inputs to an XSLT transformation do not include any files.

From: Frank Marent <frank.marent@xxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] get the current xml file name
Date: Tue, 8 Aug 2006 09:58:46 +0200

colin

you saved my day. that works! with a small change

document(concat(document-uri(/),'/../','nextfile.xml'))

'/../' instead of '../' and a little bit wondering why there is no function available in xslt to get the current xml file name. thanks also to abel for his contribution... no i can't use parameters in this case, i forgot to mention.

frank


Am 08.08.2006 um 08:42 schrieb Colin Adams:



I would think something like:


document (concat(document-uri(/),'../','nextfile.xml')) should do the trick.

If you are using XSLT 2.0, you can use the resolve-uri function which will be a bit neater.

From: Frank Marent <frank.marent@xxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] get the current xml file name
Date: Tue, 8 Aug 2006 08:18:37 +0200

hi

this is my first (xslt-beginner) question to this list, hoping my question is not been answered 1 mio times. i was searching in the archive to avoid this. :-)

i'm looking for a function that helps me to read and process several .xml files by document(). the problem is that when i say

document('nextfile.xml')

the document() function tries to read the xml file in the path of the current xslt (!) file. and that's not working for me. so i want to redirect the document() function to the path of the directory of the current .xml file.

how can i do that?

document-uri(/)

reports the whole (!) uri of the current xml file. that includes the path i'm looking for, like

file:/C:/somewhere/anywhere/whereami/myfile.xml

and that's fine. but how can i now cut off 'myfile.xml' when 'myfile.xml' is always changing and i have no idea of this filename in the xslt and replace it with 'nexfile.xml'?

i thought to find a function to

get the current xml file name

to be able to extract that file from the uri-path-string. but i could not find anything about this. also trying to find a function to find the last '/' in a string and extracting from that with substring-after (). uahh.

i hope to find help here. any hint is very appreciated!

from switzerland
frank


_________________________________________________________________
Windows Live Messenger has arrived. Click here to download it for free! http://imagine-msn.com/messenger/launch80/?locale=en-gb


_________________________________________________________________
Download the new Windows Live Toolbar, including Desktop search! http://toolbar.live.com/?mkt=en-gb


Current Thread