This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Testing file existence
- From: Steve Ball <Steve dot Ball at zveno dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 03 Sep 2002 09:15:53 +1000
- Subject: Re: [xsl] Testing file existence
- Organization: Zveno Pty Ltd
- References: <OE40Qm6XI0UBELSyLtq00009a5a@hotmail.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Eduardo Andrés Alfonso Sierra wrote:
I wanna include some images in the html file generated from a xml file using
a stylesheet but I want to do that only if these images exists.
How can I test if a file (no xml) exists on my misk.
I'm using the XT processor.
For the benefit of those not using XT, there are at least
two ways so solve this:
1. Use an extension function. Most XSLT processors provide
a means of defining extensions. Personally, I use libxslt
and have a wrapper for it for the Tcl scripting language.
To test file existence (or get a file mod time, etc)
I call out to a Tcl script via an extension function.
2. There may be other ways depending on the framework you
have set up. For example, if you are running a web server
then you could set up a CGI(-like) URL that returns the
file existence information as a small XML document.
Then use the document() function to retrieve that info.
This is essentially a Web Service. It would be nice to be
able to use SOAP for this purpose, but SOAP doesn't
play nicely with XSLT :-(
It goes without saying that security issues must be
considered...
2.5 Pass filesystem information to the stylesheet as
a parameter. You could have some code create a listing
of the filesystem (most probably the sub-hierarchy you're
interested in, rather than the entire tree), pop that
in a file, pass the filename to the stylesheet as a
parameter and then use document() to pull in that file.
Just some ideas...
Steve Ball
--
Steve Ball | XSLT Standard Library | Training & Seminars
Zveno Pty Ltd | Web Tcl Complete | XML XSL Schemas
http://www.zveno.com/ | TclXML TclDOM | Tcl, Web Development
Steve.Ball@zveno.com +---------------------------+---------------------
Ph. +61 2 6242 4099 | Mobile (0413) 594 462 | Fax +61 2 6242 4099
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list